{"id":26,"date":"2025-01-06T21:07:05","date_gmt":"2025-01-06T21:07:05","guid":{"rendered":"https:\/\/blogs.oregonstate.edu\/mattdemichele\/?p=26"},"modified":"2025-01-06T21:07:05","modified_gmt":"2025-01-06T21:07:05","slug":"cs-462-blog-post-1-one-thing-to-do-and-one-thing-to-avoid","status":"publish","type":"post","link":"https:\/\/blogs.oregonstate.edu\/mattdemichele\/2025\/01\/06\/cs-462-blog-post-1-one-thing-to-do-and-one-thing-to-avoid\/","title":{"rendered":"CS 462: Blog Post 1 &#8211; One Thing to Do and One Thing to Avoid"},"content":{"rendered":"\n<p><strong>One Thing I Want To Implement<\/strong><\/p>\n\n\n\n<p>One thing from the articles that I would like to start doing more often is cutting down the amount of redundant code present in my codebases. This is something that I tend to already do at times, but after reading chapter 1 of <em>Clean Code<\/em>, I feel that I need to have much more urgency on this. As Bob Martin points out, clean code is actually a matter of &#8220;professional survival&#8221; (page 5). Put in this way, I need to realize that writing clean code isn&#8217;t something that can be considered optional or a matter of convenience; it&#8217;s actually something that is necessary for the survival of a codebase as a whole, and probably more importantly for me, for my job survival. If I start to write messy code now, I will inevitably reach a point of productivity slowdown that will also inevitably call into question my value to the company. Thus, one of the easiest ways I can avoid falling into this state of unproductivity is to simply stop repeating myself in my code. I&#8217;ve found that I most often repeat myself in code if I am trying to be lazy in the short-term or take the easy way through some task. Usually, it&#8217;s some task that seems pretty harmless. It can be something like creating a new component in Angular. Usually, in a new component, there is a lot of code that is repeated from other components. Instead of simply making the old component code reusable, it&#8217;s tempting to just write it again in the new component. This is generally a shorter process in the short-term, but the end result is that now I have two components that are mostly the same code, but do completely different things. Instead, I could have just reused the first component and would have had half as much code in the codebase. This is something that I clearly need to stop doing, since after all, it is a matter of &#8220;professional survival.&#8221;<\/p>\n\n\n\n<p>To this end, Bob Martin also raised some interesting strategies for writing clean code developed by other luminary programmers. For instance, I really liked the suggestions presented by Dave Thomas, in which we advocates that clean code has &#8220;unit and acceptance tests&#8221; along with &#8220;meaningful names&#8221; and &#8220;minimal dependencies.&#8221; All of these suggestions are not particularly unique; however, they do underlie the fact that writing clean code, while a matter of survival, is not something that is particularly difficult. It is straightforward to give classes and functions clear, descriptive names. It is also straightforward to write a meaningful test for each piece of new code that I introduce into a system. It may be difficult to write tests for old portions of the codebase that I have not authored, but it is not difficult to write tests for new code going forward. Following this principle is something that I will strive to do moving forward.<\/p>\n\n\n\n<p><strong>One Thing I want To Avoid<\/strong><\/p>\n\n\n\n<p>One thing that I want to avoid doing is utilizing excessive comments in my code. Martin Fowler has some particularly salient points on this topic in chapter 3 of <em>Bad Code Smells<\/em>. In the chapter, he highlights that &#8220;comments lead us to bad code&#8221; (page 71). I have certainly found this to be true in my own experience. In fact, I&#8217;ve even found that excessive commenting in my code actually is a symptom of poorly written code. If I feel a need to over-explain something or include really nitty-gritty details about an implementation, then, chances are, the code that I&#8217;ve written is not the most easy to understand implementation possible. As Fowler points out, instead of writing comments to explain a poor implementation, it&#8217;s probably a better idea to first try and refactor the code so that comments are not needed in the first place. Therefore, I want to make an effort in my work moving forward to cut down on the amount of comments I leave and rather search for ways to make comments less necessary.<\/p>\n\n\n\n<p><strong>Works Cited:<\/strong><\/p>\n\n\n\n<p>Fowler, Martin. Refactoring: Improving the Design of Existing Code. 2nd edition, Addison-Wesley Professional, 2018.<\/p>\n\n\n\n<p>Martin, Robert C. Clean Code: A Handbook of Agile Software Craftsmanship. 1st edition, Pearson, 2008.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One Thing I Want To Implement One thing from the articles that I would like to start doing more often is cutting down the amount of redundant code present in my codebases. This is something that I tend to already do at times, but after reading chapter 1 of Clean Code, I feel that I [&hellip;]<\/p>\n","protected":false},"author":12938,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.oregonstate.edu\/mattdemichele\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.oregonstate.edu\/mattdemichele\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.oregonstate.edu\/mattdemichele\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/mattdemichele\/wp-json\/wp\/v2\/users\/12938"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/mattdemichele\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":1,"href":"https:\/\/blogs.oregonstate.edu\/mattdemichele\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":27,"href":"https:\/\/blogs.oregonstate.edu\/mattdemichele\/wp-json\/wp\/v2\/posts\/26\/revisions\/27"}],"wp:attachment":[{"href":"https:\/\/blogs.oregonstate.edu\/mattdemichele\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/mattdemichele\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/mattdemichele\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}