Reputation: 1232
I typically set out an application structure as follows:
+----my_awesome_nodejs_app
| +----app
| | +----app.js
| | +----node_modules
| | +----tomatoes
| | | +----tomatoes.controller.js
| | | +----tomatoes.helper.js
| | | +----tomatoes.model.js
| | | +----tomatoes.route.js
| | +----views
| | | +----tomatoes.pug
| +----public
| | +----tomatoes
| | | +----tomatoes.css
| | | +----tomatoes.js
| +----spec
| | +----tomatoes.spec.js
I'm favoring naming conventions to match that of the front end (e.g. example.com/tomatoes) - as I think it makes it easier to support long-term (although there's probably a better way to do this)
That said - if say, I decided to change tomatoes
to say sausages
- I need to update all my tests, directory names, file names and comments accordingly (not to mention page-specific CSS or JS).
Is this something I just need to accept and factor in when undertaking such an action, or is there another (better) way of being able to do this to allow greater flexibility?
Upvotes: 1
Views: 3740
Reputation: 5380
It is hard to get away from having to perform the changes in all related files without overengineering the solution.
Something that can help is to place all related files for a component/module/part in the same folder, see Relational Structure in this blog post for more information.
In my opinion Relational Structure makes larger projects easier to handle too since you find all related resources at the same place instead of having to search for files scattered around the project to do a change.
Upvotes: 1