Are Rules Necessary?

20 Sep 2018

Do We Really Need to Follow the Rules?

Let’s admit one thing before we get down to the real business: seeing multiple red or yellow marks on the editor window just because you forgot a few spaces in between parenthesis and variables is not the most wonderful sight to see. From my experiences, nothing was more frustrating than getting points marked off assignments just because my indentation was off by a few spaces. I now have established a love-hate relationship with coding standards; as much as I find them tedious and annoying at times, they have helped me learn programming languages and enhanced my understanding of what the lines of codes do in programs.

I believe programming languages provide some flexibility regarding how the work can be done. Essentially, as long as your codes work and perform the right tasks, you can make the variable names whatever you want (even if you name an array of integers ‘goat’, for whatever reason), press the tab key 4 times before a return statement (although that is quite ridiculous), and have all the closing curly braces on one line (}}}})…right? While this is not necessarily illegal and the Eath probably won’t break in half, most of programmers avoid such actions as much as possible and follow coding standards. By following coding standards, it makes things easier for the developers as well as the consumers and viewers. The codes are a lot neater and easier to comprehend when you abide by the coding standards; in my opinion, coding standards even help with tracking down possible mistakes within the program. Here is an example to illustrate my point:

 if (condition) {
    do task1
} else {
    do task1
}
if(condition){do task1;}else{do task1;}

Clearly, the codes written in the first block are easier to understand than those from the second block. One can analyze the codes in the first block a lot faster and find out that it’s performing the same task regardless of the condition and change that, whereas if one encountered the second block, it might take quite long to even figure out what is going on there. Although the examples are extremely simplified, the main point is that we don’t want to see multiple blocks of codes written like the second block.

Similar to how we don’t want to see the monsters who eat Kit Kats the wrong way:

Again, the Earth won’t break in half but… let’s just not be this guy here. Eating Kit Kats by breaking them apart following the shape is so much cleaner, better and respecting whoever made Kit Kats. If the lines are there, why not actually use them? And if we have inspectors for coding standards, why not use them to make sure that our codes are clean and neat?

The First Step

It doesn’t take much to satisfy a beginning programmer; just a program that works and having no error messages pop up. With that being said, using ESLint with IntelliJ IDEA was quite painful at first. As I was writing the functions needed to complete the WOD, the red lines kept showing up telling me that the function or the variable was never used. I found myself repeatedly saying, “OK, just wait!”. I am new to IntelliJ IDEA, so configuring the environment as well as getting ESLint to be quiet about the trivial errors made me want to pull my hair out sometimes. But over the week, I started getting better at handling errors and getting the green checkmark (which led to less frequent hairpulling, of course).

Learning new things always takes me back to the time in my childhood when I was scared to go in the water at the beach and my dad told me, “The first step is always the hardest to take.” When you encounter something for the very first time, it is normal (natural even), to be hesitant and scared of the unexplored and unknown. However, once you take the first step in, everything else just flows through with it and you’ll soon realize that there is nothing to be scared of; since you can’t avoid it, you must somehow manage to enjoy it. Getting used to new materials and environments takes a while, but I’m stoked to see how far I can grow as both a person and a programmer in the future by obtaining new skills and knowledge.