Playing by the rule

01 Sep 2017

In our civilized society, everything has standards to maintain order. Sometimes standard may seem like a murder to individual differences and styles and it’s true. But standards are especially important if the works are meant to be shared and coding is one of them. Coding standards are created to improve both the sharing and learning experience.

Coding standards should not restrict people from their coding style. So a good coding standard should not limit people to only do things in one way and need a good justification for every rule. For example in ESlint for Javascript, it enforces the use of let and const and avoids the use of var at all cost. At first, it just feels like extra work because knowing when to use const and let required more planning than just spam var to everything. But there is a good justification to do the extra work, the difference in the memory usage in large scale can make a huge impact. A coding standard is also essential in a team environment, codes needed to be understandable to other. It can turn into a mess with inconsistent function and variable due to the fact that contributors are not able to understand work from each other.

Getting used to a coding standard is frustrating in the beginning because it feels like everything you are doing is wrong even the smallest thing. When I was using ESlint for Javascript, I always forgot to use single quotation mark instead of double quotation mark. Because I am so used to using double quotation in all the language I learned before and it is hard to change a muscle memory. Which brings me to my next point, get a coding standard when you want to learn a new language. Coding standards are just too important to ignore, so it is better to follow the standard when you start than to change your habit afterward. We all know how difficult it is to change a habit, especially painful when you have to change more than one, which usually is the case for coding. Every rule is created for a reason and usually for a good reason, so as a starter, playing by the rules is always a good choice.