Prompt: What is one thing from the articles that you would like to start doing (more often), and why? What is one thing you want to avoid doing and why?
As a new programmer (or at least a few years in school under my belt), I always thought of keeping code clean. With only coding just for school projects, my experience is thin; thus, I haven’t had any problems merging codes with other team members. Although I always thought that my code was clean until I started reviewing other people based on reviewing before merging for a project. After this, I realized that some people’s code can be messy because of a lack of comments or explanations. That’s why reading both chapters my professor gave us changed my perspective.
Reading Clean Code: A Handbook of Agile Software Craftsmanship by Robert Martin [1] made me realize perspectives that I didn’t think of in terms of cleaning up my code. From various developers and creators, one of the techniques that I would want to start doing is making my code more testable [1]. Creating code that can be separated within acceptance testing can be helpful in the long run for coding projects that might require these instances, especially after merging multiple codes with other teammates.
Another is Martin’s idea to keep your code clean over time, following the idea of the “Boy Scout Rule” [1]. I’ve never really thought about this method of keeping my code clean, I’ve always thought of keeping the code readable to a viewer, and then move on. It never occurred to me how I can always improve/clean up previous codes i just made based on breaking down functions that are too large, remove duplicates, etc. [1].
From reading Refactoring: Improving the Design of Existing Code [2], there are techniques that I would like to avoid in terms of bad coding that I never thought of, such as breaking down longer functions into more straightforward compact functions. I admit that I have written various tasks that were too long, and breaking it down into smaller sections would have been the best approach. Fowler expresses how long functions can create “smelly code,” where the semantic distance between what the function does and how it does it becomes too large, making the code less readable and harder to test [2]. He also emphasizes smaller functions reduce a developer’s load by eliminating the need to understand the internal details every time the function is used [2]. From this example of the smelly code structure of long functions, I would like to compress long functions into smaller ones on a single responsibility. This would improve not only clarity but also enhance testability.
Reference:
[1] R. C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship, 1st ed. Upper Saddle River, NJ: Pearson, 2008, ch. 1.
[2] M. Fowler, Refactoring: Improving the Design of Existing Code, 2nd ed. Boston, MA: Addison-Wesley Professional, 2018, ch. 3.