Choose names that clearly communicate intention and follow established conventions. This applies to variables, functions, methods, and architectural components.
Key practices:
// Instead of:
function NotesUseCase(notesRepository) { ... }
// Prefer:
function NotesService(notesRepository) { ... }
// Instead of:
var proto = module.exports = function(options) { ... }
// Prefer:
function router(options) { ... }
module.exports = router;
// Confusing - same name used for different purposes:
app.router = function() { ... } // Method
this.router = new Router(); // Property
// Better - clearly distinguished names:
app.createRouter = function() { ... } // Method
this._router = new Router(); // Property
// No visibility indication:
this.cache = Object.create(null);
// With visibility indication:
this._cache = Object.create(null);
// Potentially confusing:
app.dispatch = function(res, event, args) { ... }
// More descriptive of actual purpose:
app.dispatchEvent = function(res, event, args) { ... }
// Unclear abbreviation:
res.addTmplVars(options);
// More descriptive:
res.addTemplateVariables(options);
Consistently following these naming conventions improves code readability, maintainability, and helps prevent confusion among team members.
Enter the URL of a public GitHub repository