Cleaning up my code the standard way

07 Feb 2019

My recent experience with coding standards

Earlier this week, my teacher in my software engineering class was excited to introduce us to a development platform that we are going to use for the rest of the semester, IntelliJ. It is a fairly complex development platform that has many customizable features, many of which I haven’t completely learned in my first week of use, I would love to explain the features of IntelliJ as well as its inherent strengths and weaknesses as a platform once I become fully comfortable with it, but this paper’s due today! Haha. Well, I may not know too much about IntelliJ, but my teacher introduced it to us since you can customize its coding standard checks, which check your code in real-time if you have violated a coding standard. The addition we have used to customize our coding standards is a plugin called ESLint, which is where you can make the rules for your standards, which is then used in IntelliJ. Again, here I am pretty unfamiliar with ESLint, most of the setup work to get IntelliJ to work with ESLint included me following instructions to install and change settings to make premade standards work. It is quite embarrasing making this essay really, when my level of expertise on these programs are quite low, and not only will I recommend that you will take my word on these programs with a grain of salt, but ignore any details I have said about them since any of them could be wrong.

Coding standards and its benefits

Well, from here on out, I’m not gonna talk about things I don’t understand , the main point I was trying to make is that the implementation of coding standards played a large part in why we are learning this new platform. If you are unfamiliar with what coding standards are, it is a set of rules that are related to the format of your code. Even if an entire code runs on a single line without any spaces or new lines, It could still be helpful to have those “unnecessary” parts to your code to make them easier to read. Being able to read your code is important because when you are trying to fix a problem in your code, it is much more efficient to fix it if you can spot and understand where the problem is. It is almost like trying to read an essay from someone with bad grammar versus someone with good grammar, it is easier to understand what someone is trying to say if they communicate in a way that follows certain rules of grammar. In an essay, it is also easier to find a certain spot if they divide their essay into multiple paragraphs, where each paragraph covers a different topic. Much is the same when coding.

It is commonly said that if you are working on a collaborative project with a group, having readable code is essential, since if someone is going to write some function and someone else was planning to use it, that someone else better know what parameters they have to use, what it does, and what it returns and if it has different cases that change the outcome of its use. In other words, the code should be formatted in a way that collaborators can understand so that they can use or build upon it, and having organized code is really helpful. When sharing your code with other people, it is probably even more helpful to have comments explaining the functionality and purpose of your code.

I would also like to point out that it is also really helpful to yourself to have organized code. It is not only other people that you have to worry about, if you are making a project by yourself, think of yourself as the sole collaborator for that project. You will have to understand your code and find problem areas if the code doesn’t work. Once you write a decent amount of lines for a program, it is really easy to forget the details and inner working of your code, if you are going to have to refer back to your previous work to remember how it is supposed to be used, having clean code is helpful here too. But most importantly, having readable code is essential when your code isn’t working properly, in this case, your level of understanding will have to be expert, finding out which parts of the code are functional and which parts are letting you down, looking at the symptoms and trying to think back to its possible causes and figuring out why certain factors don’t function the way you wanted it to.

My opinons on coding standards

I do highly recommend implementing coding standards into practice. Once I have successfully went through the time-consuming and confusing process of setting up IntelliJ to properly use ESLint to check my code (it took me a couple tries) I have enjoyed using it. Every time I want to make a new project, I would have to set everything up again, but once the setup work is complete, having a checker is quite nice to have. My code has looked marginally cleaner since I started using IntelliJ. In reality, it had a relatively small impact on my code quality since my code did follow some guidelines, but having the organization be a little stricter has improved it by just that much. Honestly, for me, it is mostly about the satisfaction of having something look organized more-so than it is about me caring about the boost of efficiency that a perfect coding style has. Its practical use only goes so far, but there is a certain pride to having organized code, it makes it seem like you knew what you were doing.