The beauty of conformity

21 Sep 2023

Why does coding style matter?

We have all been through the universal struggle of reading someone else’s code – whether it’s a friend’s code, a (possibly) helpful answer on Stack Overflow, or even our own code from years past, having to navigate strangely formatted code is a common struggle. Before we can even begin comprehending the content of what is written, we have to go through the process of figuring out their coding style. Noticing how they open and close functions, if they have enabled text wrapping, if they are consistent with their indentation, and other styling details are necessary to fully understand what is going on. These can differ for each person, and doing this for every person’s code we read takes valuable time and effort. Conforming to a single coding style standard solves this issue, improving overall neatness and readability of unfamiliar code.

My experiences with freedom of style

In all of the coding classes I have taken, most have enforced a semi-standard coding style. At minimum, instructors inform us of common naming and block separation conventions. With this flexibility, I have experienced both ends of the coding style freedom. Reading a friend’s code with inconsistent indents was frustrating and I spent more energy trying to ignore the misalignment and remember that (in this specific language) indentations did not carry any actual inherent meaning. On the more positive hand, analyzing code that is well-formatted, evenly spaced, and consistent presents less distractions and makes it easier to focus on the actual content. I find using ESLint with Intellij to be convenient, as it automatically checks these small details that I may otherwise miss. I do occasionally find the red underlines detecting “errors” to be annoying and distracting if I am just starting to write my code, but it is a minor price to pay for neat code.

Universal benefit of uniform coding style

I am grateful that we get to experience the ease and convenience of linters through this class. Maintaining a good uniform coding style is important when working in a team, as having to work harder to understand each person’s unique coding style would soak up too much valuable time and potentially cause us to miss errors. As we will be doing more project-oriented work in this class and our future classes, I think good coding style is a valuable quality to recognize and ESLint as a good introduction to how we can maintain that.