Neat Coding

24 Sep 2020

Thoughts on Coding Standard

In this past week, I’ve been introduced to a particular coding standard. I’ve tried the ESLint coding standard with JavaScript, and so far, I’ve been fairly annoyed with it. As I write my code, I follow the basic coding standards already, such as proper indentations and formatting. What makes the ESLint standards painful for me is all of the minor spacing issues. For example, as I create an array, [0,1,2,3], raises a flag with my compiler, stating that it is improperly spaced. The correct way is to add spaces after each element’s comma, such as [0, 1, 2, 3]. I would constantly have to backtrack on my code to fix these small mistakes, even though I think that my original way of writing it is perfectly readable. I feel that our particular coding standard was very strict on how to format code.

My no-spaced array vs ESLint standard spaced array

Should we have Strict Coding Standards?

Its not like coding standards is a bad thing, nor is it too bad to keep fixing these errors. When I first started writing programs, I remember all the mistakes I would make, not properly indenting, not using short-hand methods, and just a general mess of a code. When my lab TAs pointed out that there are ways to properly format the code to make it much easier to read, I was constantly finding myself backtracking to fix these formatting mistakes. But, overtime, it eventually grew on me and I’ve gotten use to properly conforming to the standards that my lab TAs have set out for me, of which I am thankful for them as it makes reading and debugging code a whole world easier. I feel that with strict coding standards, although it will take time to get use to, will allow the user to learn how to properly code without raising a flag.

However, I do think that one big caveat with having everyone follow the same standards is that not everyone will actually follow it. There will be times where you will have to take a look at another person’s code, which is completely out of your expectations to completely conform to the coding standard that you are so used to working with. I can say from experience that from reading a large amount of other people’s code, that I am able to easily determine what is happening in their code without too much of a hindrance, even though their coding standards vary wildly from one to another. I feel that coding standards should be stiff enough to improve readability, but not so much that there is only one way to do something when there are a multitude of valid ways to do it.

Last Thoughts

I honestly believe that there should be a universal coding standard that everyone should follow, and that is proper indentations. It allows for easy reading of functions and loops, making it better to follow and debug if there were a misplaced line. Stricter coding standards should follow on a per organization basis, to allow for easier collaborations between colleagues, but be prepared to see other coding standards and not grow too used to just one coding standards if you plan to work with a variety of codes.