Clean code means more than just having pretty formatting, it means that the code is structured and designed in such a way that any competent developer can easily understand, utilize, and even expand off of it. While reading an article on Clean Code [1], I read a quote from Martin Fowler that sums it up nicely: “Anybody can write code that a computer can understand. Good programmers write code that humans can understand”. One practice that I want to use to improve my own programming skills is to never include hard-coded values when a descriptive constant variable could be used instead. Numerous times when collaborating on an project I have had to guess and suppose what certain numbers or terms were supposed to represent, even sometimes in my own code from long ago. This leads to wasted time and the occasional erroneous assumption. I also commonly over-comment in an attempt to improve clarity, however sometimes this can have the opposite effect as it clutters the file and can make it more difficult to parse.
Code smells are defined as subtle issues with the code that may not disrupt its function at the current time, but could later lead to issues or confusion that could have been easily avoided. A study mentioned in another article I read from medium.com [2], stated that most code smells are generally present early on in development, often originating from a developer trying to cut corners that inevitably lead to high technical debt in the future. I am personally susceptive to “spaghetti code”, or long sections of code with minimal structure that can be difficult to follow, modify, and/or maintain. Just as my writing is prone to run-on sentences and occasionally poor punctuation, I often forgot to properly modularize my code and neglect to create helper functions that reduce the average line length of my functions. This issue is also present in my code comments as mentioned in the previous section, as I tend to ramble on in my comments and fail to limit them to only include helpful information.
Proper utilization of these tips and tricks from programming professionals will greatly improve the quality of my code, as well as help me grow as a developer. The moral of the story is that sometimes putting in more work in the early stages of development can greatly reduce the overall time taken by the project by increasing readability and reducing technical debt.
Citations:
- Codacy. “What Is Clean Code? A Guide to Principles and Best Practices.” Codacy, Qamine Portugal S.A., 29 Oct. 2024, blog.codacy.com/what-is-clean-code.
- Verwijs, Christiaan. “In-Depth: What Scientific Research Has to Say about Technical Debt and Code Smells.” Medium, The Liberators, 29 Aug. 2022, medium.com/the-liberators/on-technical-debt-and-code-smells-ae8de66f0f8b.