I read the article “How to Write Clean Code – Tips and Best Practices” by German Cocca. Cocca calls out several important principles for writing and maintaining clean code. Some of the principles that stood out the most to me were simplicity, effectiveness, efficiency, single responsibility principle, re-usability, and modularization.
In Chapter 8, “Code Smells and Refactoring” from the 2nd edition of the Handbook of Software Engineering Methods by Lara Letaw, the writer provides excellent advice to making code cleaner, recognizing code smells, and refactoring techniques.
One thing I would like to do more often is regularly refactor my code. I want to take a more proactive approach to refactoring code. By viewing code as an evolving product that requires attention and care, I can improve as a developer, and ensure the code is readable, maintainable, and scalable for myself and any other developers working in the codebase.
One example for improvement is breaking long methods into smaller, single purpose ones. The code snippets below show how one function is split into two classes that handle their specific responsibilities:

Source: https://www.freecodecamp.org/news/how-to-write-clean-code/#heading-how-can-i-assess-whether-a-codebase-is-clean-or-not

Source: https://www.freecodecamp.org/news/how-to-write-clean-code/#heading-how-can-i-assess-whether-a-codebase-is-clean-or-not
One thing I absolutely want to avoid doing is overlooking any code smells. Paying attention to indicators, such as overly long methods that need to be broken into smaller chunks, consolidating duplicate code into reusable functions, or issues with documentation–whether it’s missing, outdated, or excessive. I don’t want to rack up the technical debt, so addressing the smells early on will improve the longevity of the codebase and make all developers life’s easier.
Here’s an example of duplicate code, followed by a consolidated and improved version:

By regularly refactoring my code, it will address code smells, and improve the maintainability and scalability of any codebase.
References:
Cocca, German. “How to Write Clean Code – Tips and Best Practices (Full Handbook).” freeCodeCamp, 15 May 2023, https://www.freecodecamp.org/news/how-to-write-clean-code/#heading-how-can-i-assess-whether-a-codebase-is-clean-or-not. Accessed 14 January 2025.
Letaw, Lara. “Code Smells and Refactoring.” Handbook of Software Engineering Methods, 2nd ed. Oregon State University, 2024, https://open.oregonstate.education/setextbook/chapter/code-smells/. Accessed 14 January 2025.