Important Coding Standards and Best Practices to Follow
Rajneesh T.
I am a developer building SaaS, and learning materials. Know more about my world at myselfraj.com. Check my Open sources: npmjs.com/~chapeee BATMAN from Mars.
Use meaningful names with correct naming scopes:
Use meaningful names for variables, functions, classes, arguments, modules, packages, directories, etc. The names should be self-explanatory and should convey the purpose of the code.
For Example:
Not to use Unnecessary and unwanted comments,
Comments should be used sparingly and only when necessary. The code should be self-explanatory and easy to understand without comments. However, when adding a code comment, consider following these code comments best practices:
// This function checks if a number is even.
function isEven(number) {
//checking if reminder is equal to zero
if (number % 2 == 0) { //if its equal to zero return true else false
return true;
} else {
return false;
}
}
领英推荐
Write readable code for people:
Code should be written for people to read, not just for machines to execute. It should be easy to read and understand for other developers.
For example bad readable code
// This function checks if a number is even.
function e(n) {
if (n % 2 == 0) {
return true;
} else {
return false;
}
}
// This function checks if a number is even.
function isEven(number) {
//checking if reminder is equal to zero
if (number % 2 == 0) { //if its equal to zero return true else false
return true;
} else {
return false;
}
}
if you compare them you will find differences such as good variable name, current function name that is telling about itself by own, and yes with good and readable comments
Use version control, good developers use version control like git
Version control like git or SVN, etc is essential for managing changes to the codebase. It allows you to track changes, collaborate with others, and revert to previous versions if necessary.
There are many version control tools available, but one of the most popular and widely used is git but the good practice is the same for all types of version controls.
Thats all, This article focusing was solely on good aspects for having strong coding habits and becoming a good developer. In short this article is only for beginers but that does not mean its useless for pro-developers with experiece.