Writing clean code is a skill every developer strives for, including myself. Looking at code I wrote a year ago can, at times, feel humbling due to poor readability or overly complex logic. One practice I want to embrace more consistently is writing meaningful variable and function names, as highlighted in Robert Martin’s Clean Code. Clear naming reduces the need for excessive comments and makes the purpose of the variable self evident. For example, naming a function ‘calculateMonthlyInterest()’ is far more informative than naming it ‘calc()’ or another vague name. This small but impactful habit improves readability for both the original author and future contributors.
On the other hand, one practice I want to avoid is overcomplicating logic through excessive nesting, a code smell outlined in Martin Fowler’s Refactoring. Deeply nesting loops not only makes code harder to read but also more prone to errors during maintenance. Instead of an overly deep nested ‘if’ statement, restructuring logic using guard clauses or simply breaking it into smaller functions can lead to cleaner and more maintainable code. For example, instead of this:

Lastly, using unit tests is a habit that I plan on prioritizing. While it is not always discussed in articles about clean code, testing complements clean code by verifying that refactored and well structured code behaves as expected. By getting in the routine of writing tests alongside clean code, I can ensure reliability and minimize the risk of introducing bugs during changes. Overall, the principles of clean code and avoiding code smells come down to one essential goal: writing code that’s easy to read, modify, and scale.