Going for Green

07 Feb 2019

Coding standards, you will either love them at first sight or curse the day someone required you to use them, but I think they eventually grow on you.

Beyond Tabs vs Spaces

Although an eternal debate among programmers, using tabs vs spaces is only scratching the surface of what coding standards entail, but it does make for a great episode of Silicon Valley. Coding standards cover all aspects of your code, from formatting, to layout, to naming conventions, and everything in between, all with the intention of improving the readability of your code and allowing it to be easily understood by others. This can become incredibly useful when working on collaborative projects, even more so as the project size grows.

Looking back on my own experiences, over the years I subconsciously got in the habit of following some simple formatting techniques that significantly improved the readability of my programs, which ultimately reduced the time to debug any issues. Although following a coding standard is a rather new concept to me, I can see the benefits to using them.

Impressions on IntelliJ IDEA and ESLint

For my Software Engineering course at UH Manoa, we just started using IntelliJ IDEA. Although I have experience using Microsoft Visual Studio, using an IDE is another new concept for me, having only used Visual Studio for compiling software I developed elsewhere. Some features in IntelliJ IDEA are difficult to get used to when coming from another environment, such as automatically adding closing parentheses and brackets, auto-indenting and auto-complete… I can see these features being useful, especially for those just starting off programming, but it can also cause some confusion if you are not used to it.

Onward and upwards to ESLint, which is a JavaScript coding standard. Getting it to function properly on IntelliJ IDEA took quite a bit of work (for Windows at least), and once it is installed, the plugin is fairly temperamental. IntelliJ IDEA will run the various ESLint tests as you type, which causes all sorts of useless errors to appear that will disappear once you get around to typing the next line or two. One such example is declaring a variable, immediately an error is displayed alerting you to the fact that you haven’t used it anywhere; thank you captain obvious, I just finished declaring it. Another issue is that IntelliJ IDEA will sometimes display a red “x” icon, which means that your code did not pass the ESLint tests, but upon moving your cursor over top of the icon, it will change to a green check mark icon, which means that your code passed the ESLint tests.

Going for Green Check Marks

Moving past some of the issues with implementation, I can see many benefits to having the ESLint tests automatically run on your code. One such benefit is that you fix your code as you code, as opposed to coming back to it hours or days later and trying to remember what your thought process was at the time. ESLint includes formatting guidelines, so another benefit of adhering to it is that you will produce nicely formatted code, which can help you spot issues when debugging. I am also a big fan of visual indicators, so seeing a green check mark in IntelliJ IDEA to let me know my code conforms to ESLint, or another coding standard, is a nice feature (if only it updated properly). All in all, I find coding standards to be very useful and believe that programming classes should do more to emphasize their importance to those just starting off.