Coding Spaces

20 Sep 2018

Everyone has their very own coding style. Having a coding style expresses individuality and professionalism. An efficient style greatly helps in finding debug errors and helps one work with comfort with multiple files. Unlike coding languages that are slightly different you can use the same coding style in all of them.

My Coding Style

My style has been formed from coding in Javascript, C, and C++. As I code I tend to not include as many spaces in my conditions. For instance in my for loops I would type something like ”for(let i=0;i<10;i++)”, on this one line there’s only one space between the “let” and “i”. In addition I also include plenty of comments all over my code files, either on its own line or behind a line with code. If someone else looked at it I bet they would find it very crowded, but it’s the style I find most informative to study my work. Another habit in my style is including numerous newlines. For example in my if/else statements my closing curly bracket would be on a newline on it’s own and then “else” would go on a entirely newline. When I was doing lab assignments for C++, my grader explicitly stated that he wanted no extra empty newlines. He said it was his style of coding and that it was best to have as less lines of code as much as possible. I understand what he was saying and that having less lines of code on one file is best, but I’m fine with taking up more lines of code to be more organized.

Pro Javascript Tool

I recently started using ESLint, a configurable tool that identifies patterns in JavaScript, with Intellij Idea, a java integrated development environment. The biggest change I have to focus on is my spaces, there is literrally a space after every case. One important focus that I felt very different to me was a space every time before every starting curly bracket, it’s very spacious. Using ESLint however is actually very helpful because it displays where my errors are and shows a little lightbulb by the error line that will recommend a fast fix if I click on it. Then it gives me a cute green checkmark on the top right corner when the file is completely in Javascript. When I first tried fixing a file till I got the checkmark it was easy and visible to accomplish, I was very satisfied.

After making a couple projects now, my impression of ESLint is that the files are very clear now. I can see each line of code, I can see where my variables are being stated each time. It’s very neat and organized compared to my own style, and makes me contemplate if I should pick up the habit of using more spaces as well. Well, I’ll still be working with ESlint and I expect that my coding style will be changing to putting more spaces.