I’m a big proponent of keeping a consistent naming standard, even when crossing languages.
True, capitalization and syntax may change, but the standard should remain. Importantly, I have found that naming should play to the strengths of the operating system.
For example, on every operating system you can sort files by name (i.e. in Windows Explorer on Windows, Finder on Mac, and so on for Linux, etc.). With this in mind, naming should be used for a few key benefits:
- Group similar files
- Sort files by age/date
Grouping similar files is an important part of naming. For example, say we have a Users feature. We have a basic add, edit, update, delete and list all capability. In this situation, we want to preface our file names with user so that they are all sorted as a group. A good naming standard would be:
|users||List all Users|
|user_add||Add a User|
|user_edit||Edit a User|
|user_delete||Delete a User|
|user_update||Update a User|
The above standard is superior to one where we put the action first, such as edit_user or add_user. If we put the action first, then all ‘edit’ files will be grouped together: edit_user, edit_company, edit_project.
The grouped approach is superior as we usually are working on the Users feature, or the Companies module, etc. By using the grouped approach all of our files are naturally and automatically sorted by the operating system.
Similar to file names, functions, classes, styles, etc. should be consistently named throughout an application. For example, if we are creating a basic JSON enabled RESTful Web Service with JQuery and a JS library up front, then it’s a huge help to keep names consistent throughout the application (at all layers).
Building on our file names example above, the python def for adding a User should be:
Next, in HTML, we would have a form with a CSS class name that also fits our pattern:
Consistent naming allows us to leverage built in operating systems for sorting files and reduces developer overhead. It makes it easier for software engineers at all layers to know what is above and below them in the software stack.