Blog Post #1 – Clean Code/ Code Smells

I’ve heard the terms clean code and code smells before. The terms can be very self evident as clean code is good coding practices and code smells are potential indicators of bad code or coding practices. This is of course a very simplistic explanation of these terms but they are a good way to understand them without getting into details.

I read a few different articles dealing with clean code. I’ll make note of a particular article which listed in a most simplistic manner good practices when it comes to coding. I won’t go over all of them but the overall purpose of clean code is to create code that is easily understandable, follows standard conventions, eliminates unnecessary complexity, and simplifies where possible. A few ways that this can be achieved is to remove unused code, isolate sections of code so that changes don’t cause a cascade effect leading to errors, neatly add comments where necessary, and keep your style consistent. This link below is an excellent list of things to strive for in practice to keep your code clean.
https://gist.github.com/wojteklu/73c6914cc446146b8b533c0988cf8d29

Code smells are indicators that there might be something wrong with your code. It doesn’t mean that there is something wrong or that the coding style is bad necessarily. It just means that there is something present that is potentially indicative of problems with the code. If you see some of these things then they deserve a second look and can perhaps be improved. Some code smells are instantly recognizable as needing correction such as an inconsistent naming convention or poor line alignment. Others might be more insidious such as classes that delegate their work to another class and are in fact not needed. This adds unnecessary complexity to the code. The article that I read contains a list of code smells that cover a range from formatting consistency to class interactivity and code complexity. This too is a good list to be mindful of when coding.
https://blog.codinghorror.com/code-smells/

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *