JavaScript naming conventions when working with nodejs
javascript, naming-conventions, node.js
Solution
The most important thing in your naming convention is consistency. You can figure out pretty much any naming convention as long as it is sane and consistent.
That being said, I would probably be more verbose in my names in this case. Paths might be good enough, but I would rather see `UserRoutes.js`, `UserModel.js` and maybe even `UserLib.js` based on your examples.
In some of my node.js projects, I have even taken to not using a .js extension. My routes for instance would be `user.routes`. It is easy enough to change the syntax highlighting in editors based on different extensions.
Problem
I'm working a lot more with JavaScript in node.js. My application has the following general 'classes' that are used. Server side: - Libraries - Models - Utilities - Routes Client side (backbone.js): - Views - Models - Collections The client side is pretty straight forward. I name all files related to what they are, such as UserModel.js, UserView.js, UserCollection.js, etc. The server-side however, gets more messy. For example: Models are related to MongoDB collections. Each Model is just a wrapper for various functionality. If I have a users collection, I have a collection called `users`, my model is `Users.js`. Libraries I have for example `Users.js` as well, that interacts with the model and contains the majority of logic. However, this really shouldn't be called `Users`, mainly because I'm getting confused now. Routes are simply related to the URL. So if you have `/account/` I would have an `account.js` route - all lowercase. Utilities - I just have one util.js that I don't use much so I'm less concerned and the naming seems fine for it's purpose and size. How would you suggest naming things that are sort of generic like "Libraries", that differentiates them from Models/Routes.