Categories
Uncategorized

Winter 2025 – Blog Post #1

Hello everyone!

This blog post will be dedicated to the concepts of clean code and code smells. Inherently, clean code does not smell or at the least does not smell as bad as other code. As code becomes smellier, the codebases become harder to work with, maintain, and improve. This makes the process of working in these scenarios harder and more expensive. There are many instances of mistakes that can make your code smelly. There are also extensive resources out there to help ensure that your code is as clean as possible. In this blog post, I would like to delve into an aspect of clean code that I am consciously trying to improve as well as a code smell that I will consciously try to avoid.

Clean Code Example

According to Minu Kumari in their Medium article titled “The Craft of Clean Code: Essential Principles of Software Developers,” functions are a main target of implementing clean code. The aspect of functions that I am consciously trying to improve involves conciseness. According to Kumari, developers should try to keep functions short and concise, using less than 20 lines per function (Kumari 2024). It is stated that functions surpassing this line length should be evaluated and attempts should be made to break them down (Kumari 2024). This is a large task for beginners like myself. I’ve been told in previous classes, working on previous assignments, to work toward this goal. It adds a layer of complexity to your planning that must be accounted for. Sometimes, time becomes an issue. I would love to employ this behavior though. Short and concise functions make sense to use. Having specialized units that do specific things would be much more adaptable than jack-of-all-trades functions that do too much.

Code Smell Example

For my research regarding code smells, I discovered a site called Refactoring Guru. This site defines the main types of code smells, breaking them down into general categories, and then breaking those categories down into specific examples. The category that I was interested in is called “Dispensables.” According to Refactoring Guru, dispensables are additions to the code that are pointless and could be removed to make the code cleaner (Refactoring Guru). The specific example of a dispensable that I am interested in trying to avoid involves comments. The page regarding comments goes into detail by establishing that code should be understandable without comments and that comments are not meant to be used “like a deodorant masking the smell of fishy code that could be improved” (Refactoring Guru). I am absolutely guilty of using too many comments, especially ones that do not serve a justifiable purpose. I have been working on this over the past few years and have improved significantly in my comment utilization, but I recognize that I still need to develop this habit. Put in this way, if I can avoid useless comments, that should mean that my code is becoming more readable and understandable, which is desirable regardless.

Overall, as a junior developer with very little experience, there are many aspects of development that I need to learn or need to improve on. Prompts like this that lead to research into clean code and code smells are a step in the right direction. One of the most important things to actually reducing code smell is to constantly remind myself that code can smell in the first place. As a novice, it’s easy to forget, but important to consider.

Thank you for reading my post! Catch ya next time.

Works Cited

Comments. Refactoring.Guru. (n.d.). https://refactoring.guru/smells/comments

Kumari, M. (2024, February 9). The craft of Clean Code: Essential Principles for Software developers. Medium. https://medium.com/@minuray10/the-craft-of-clean-code-essential-principles-for-software-developers-bcfb9ab6fc2f