Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I still don't understand why everyone recommends different folders at the project root for controllers, directives, services, etc... You end up with closely related code being far apart. It's a thoughtless way of dividing up your files based on the most obvious feature rather than how things actually fit together.

My idea of a good modular file structure is that you could delete any random directory and delete it and it would lop off that feature as cleanly as possible. Each directory should represent an angular module, and each module should contain the routing, controllers, services, directives, and tests that it uses. If some of these are used across the app then you can have a "common" module.



Compare Rails and Django. Note that Django apps, which are meant to be made of stand-alone "apps", generally aren't - the apps end up relying on each other too much.

This seems to be because certain of what makes up each set of functionality "bleed" together - models, in particular, all seem to end up relying on each other.

I think the MVC / CDS, etc organizational structures are less about grouping things by feature and more about grouping things by common "bleed" factors (or, more likely, some deeper commonality that then causes the shared amount of "bleed"). Views pretty much never share anything. Controllers share utility functions. Models just go spaghetti.

You can also think of it like a toolbox; I keep all the screws together, rather than keeping all the flat-head screws with the flat-head screwdrivers.

That all said - Yeah, that's an excellent ideal, but it's not one that seems to occur in practice.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: