The Importance of Coding Standards

22 Sep 2022

What are they, and why use them?

Coding standards are to programmers what MLA format is to English teachers. They’re rules about how to format your work so that it’s easier to read and understand. And, they become more effective when they’re part of a set that is widely used - you could make your own set of coding standards, but it wouldn’t be very useful if nobody knew how it worked! MLA format is a great example because nearly everyone knows it, almost to the point of it being annoying: Times New Roman, 12 point font, double-spaced, one-inch margins… The advantage of this is that all papers will look the same and you know what to expect; the same types of info will be in the same spots on every paper. It’d be quite a pain if every paper had a different font, font size, line spacing, etc.

My Experiences

I don’t want to say that I’m super experienced with coding standards (or rather, the lack thereof), but I did help my friends and classmates often in my AP Computer Science class, where the most prominent part of coding standards was probably naming variables something relevant, rather than something like “variable1”. I saw things like entire methods being in a single long line, brackets isolated on a line of their own with an empty line above and below them, inconsistent spacing, and more. It was definitely a struggle to read and understand multiple people’s code (even of the same assignment!) when they were all formatted so differently.

After using ESLint with IntelliJ, I’ve found it very useful. It’s helped me be more precise and consistent with my code For example, using “const” instead in places where I would normally use “let”, or always putting a space between for’s and if’s and the parenthases. When I coded in Java, I would always leave no space between them, just like in methods, but now that I’ve actually used that practice, I see that that small detail in distinguishing for’s and if’s from methods/functions does have an impact on the readability of my code.

Coding Standards in a Bigger Picture

Some argue that coding standards can help one learn a programming language, and I wholly agree. How can you learn and understand more complicated topics if you can’t even understand the code you write? You have to build a strong foundation before you start piling new info on top. If it isn’t strong enough, it will collapse, and you will have to patch that hole in your knowledge and work your way back up to solve the problem (this is why I try to be as thorough as possible with my work). The less time you spend trying to figure out what you wrote, the more time you can spend on learning new concepts. If you’re working in a group, things will go much more smoothly if everyone is consistent with their code. Consistency in general is a good thing, and even if you’re consistenly doing something bad, at least it’s consistent! It can be worked around because it’s predictable. Coding standards are an incredibly important part of Computer Science, and should definitely be taught more in-depth in classrooms.