Choose variable, function, and export names that clearly communicate their purpose and content. Avoid abbreviations and ambiguous terms that could mislead other developers about what the identifier represents.
Key principles:
previousCounter
instead of prevCounter
)ProgressBar
instead of Bar
)Example of unclear naming:
const subProcess = childProcess.spawn('ping', ['8.8.8.8']).stdout;
// Misleading: subProcess actually contains stdout, not the process
exports.Bar = Bar; // Too ambiguous
Example of clear naming:
const subProcess = childProcess.spawn('ping', ['8.8.8.8']);
const stdout = subProcess.stdout;
// Clear: each variable accurately represents what it contains
exports.ProgressBar = ProgressBar; // Specific and clear
This practice prevents confusion during code reviews and maintenance, making the codebase more self-documenting and easier to understand.
Enter the URL of a public GitHub repository