We All Have Standards

08 Feb 2018

ESLint has been extremely useful so far. It has helped me understand the language better, and identify ways to write my code more efficiently. Since it shows errors for redundancy and whether a variable should be declared with let or const, I have been trying to remember these errors, and write my code so that they will not show up the first time. Additionally, having a coding standard can vastly improve readability in a project. Some of the coding standards are small and seem meaningless. Some that come to mind are: no trailing spaces after semicolons or hanging brackets, a space between an if and its condition, and a space between a functions arguments and its starting bracket. However, these small details keep the code clean so that when you come back to the project or someone else works on the project, they can easily understand what was written.

Learning the Language

Having a coding standard can help someone learn a new programming language, but only if it is working with an IDE that actively highlights the errors. Without an IDE that points out these coding standard errors, identifying and correcting mistakes can be troublesome. For instance, if you’re still learning a language like Javascript, you would not be aware of whether you should be declaring variables using let or const. Without an IDE to show you the mistakes, you might write the following code:

  ...
  let array = [];
     
  array.push(0);
  array.push(1);
  array.push(2);
  ...

Coming from a C/C++ background, I assume array should be declared with let because it is changing. However, let is for when a variable is reassigned, which does not happen. IntelliJ will show an ESLint error saying that let needs to be changed to const. There are a lot of small details that a beginner can miss if not using a coding standard-IDE combination. By ESLint standards, there needs to be a newline at the end of the program, or it will report an error. From experience, I can say that having a coding standard does help a beginner learn a programming language since ESLint has done that for me with Javascript.

Improving Group Productivity

In short programs like we have been creating in class, the importance of coding standards is not as apparent. However, on large projects with thousands of lines of code and multiple collaborators, having a set coding standard can help the project move along nicely. This allows separate groups to work within the same files or on related functions, and still understand each others work since they are following the same style and syntax. In a project where the source code is available for viewing by the public, following a coding standard can keep uniformity throughout the code. Say that there is a team working on a project that split into two different groups: one team is using snake_case variable naming and putting curly brackets on its own line, and the other team is using camelCase variable naming and putting brackets on the same line as the function. Although the program may work, it may not look very appealing or be easily read by the people interested in joining or endorsing the project. Having coding standards would force the two groups to write similar code, and have a tidier project.