Categories
CS 461

Clean Code & Code-Smells

What is one thing from the articles that you would like to start doing (more often), and why?

I found an interesting article, “Clean Code Principles: Best Practices for Writing High-Quality Software.”, that lists some of the most important concepts to do our best to adhere to, in order to create and maintain clean code for all parties involved. Some obvious ones that all of us are surely aware of are thing like, “Meaningful names and variables”, or, “keep methods and functions small”, that states that “Small, focused functions and methods are easier to understand, test, and maintain.”

Of course these are crucial for code development. Some other ones from the article that may not be as well known are ones like, “Follow the Open/Closed Principle”. This one I was not fully aware of based off the name. The description goes into the fact that “(…OCP states that software entities should be open for extension but closed for modification. We’ll explain how adhering to this principle enables code to be easily extended without modifying existing code. We’ll discuss techniques such as interfaces, abstractions, and design patterns that facilitate OCP and promote clean code practices.)”.

When it comes to answering the question at hand, the two principles that stick out to me that most that I would like to implement more in my coding style, firstly, would be the “Don’t Repeat Yourself or DRY” principle. I find that I have the bad habit of overlooking where I can implement a function or even an import to save myself the time of having duplicate code, especially in larger projects.

The second principle that sticks out to me that I would like to work on more is Test Driven Development. The main emphasis here is on writing tests before writing a lot of the code. We worked on this quite a lot in SWE 11, but haven’t done much of it in other courses or projects.

What is one thing you want to avoid doing and why?

As the second article, “Code Smells and Refactoring: A Tertiary Systematic Review of Challenges and Observations.”, states:

“In general, developers introduce code smells in software systems when modifications and enhancements are performed to meet new requirements. The code becomes complex and the original design is broken, lowering software quality.”.

This is a concept we mostly only covered in CS361, SWE 1. We covered this when going through the software development and Agile workbook, but did not spend a ton of time on this topic. My take on it that is the gist of the problem is laziness and trying to save time when adding to or modifying software to meet instant needs, as the quote above alludes to.

To answer the second question directly, I wish to avoid making these mistakes, by looking at the project overall when making adjustments to consider the possible development of any code-smells in the future, as a result of changes being made to it after the fact. I think the trick here is thinking more about the lifetime of the project, rather than how many hours are going to be put into the modifications and additions at hand.

Works Cited

Dyankov, Dimitar. “Clean Code Principles: Best Practices for Writing High-Quality Software.” The Coding Hub, 24 May 2023, www.thecodinghub.com/articles/clean-code-principles-best-practices-for-writing-high-quality-software.

Lacerda, Guilherme, et al. “Code Smells and Refactoring: A Tertiary Systematic Review of Challenges and Observations.” Journal of Systems and Software, vol. 167, Sept. 2020, p. 110610, https://doi.org/10.1016/j.jss.2020.110610.