{"id":26,"date":"2025-01-17T07:21:23","date_gmt":"2025-01-17T07:21:23","guid":{"rendered":"https:\/\/blogs.oregonstate.edu\/soulobrettcs\/?p=26"},"modified":"2025-01-17T07:23:02","modified_gmt":"2025-01-17T07:23:02","slug":"clean-code-code-smells","status":"publish","type":"post","link":"https:\/\/blogs.oregonstate.edu\/soulobrettcs\/2025\/01\/17\/clean-code-code-smells\/","title":{"rendered":"Clean Code &amp; Code-Smells"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"297\" height=\"220\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/8088\/files\/2025\/01\/th.jpeg\" alt=\"\" class=\"wp-image-27\" style=\"width:610px;height:auto\" \/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"has-moss-green-background-color has-background\"><strong>What is one thing from the articles that you would like to start doing (more often), and why? <\/strong><\/p>\n<\/blockquote>\n\n\n\n<p class=\"has-moon-dust-blue-background-color has-background\">I found an interesting article, \u201cClean Code Principles: Best Practices for Writing High-Quality Software.\u201d, 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, &#8220;Meaningful names and variables&#8221;, or, &#8220;keep methods and functions small&#8221;, that states that &#8220;Small, focused functions and methods are easier to understand, test, and maintain.&#8221;<\/p>\n\n\n\n<p class=\"has-moon-dust-blue-background-color has-background\">Of course these are crucial for code development. Some other ones from the article that may not be as well known are ones like, &#8220;Follow the Open\/Closed Principle&#8221;. This one I was not fully aware of based off the name. The description goes into the fact that &#8220;(&#8230;OCP states that software entities should be open for extension but closed for modification. We\u2019ll explain how adhering to this principle enables code to be easily extended without modifying existing code. We\u2019ll discuss techniques such as interfaces, abstractions, and design patterns that facilitate OCP and promote clean code practices.)&#8221;.<\/p>\n\n\n\n<p class=\"has-neutral-grey-background-color has-background\">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 &#8220;Don&#8217;t Repeat Yourself or DRY&#8221; 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. <\/p>\n\n\n\n<p class=\"has-neutral-grey-background-color has-background\">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&#8217;t done much of it in other courses or projects. <\/p>\n\n\n\n<p class=\"has-moss-green-background-color has-background\"><strong>What is one thing you want to avoid doing and why?<\/strong><\/p>\n\n\n\n<p class=\"has-moon-dust-blue-background-color has-background\">As the second article, &#8220;Code Smells and Refactoring: A Tertiary Systematic Review of Challenges and Observations.&#8221;, states:<\/p>\n\n\n\n<p class=\"has-moon-dust-blue-background-color has-background\">&#8220;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.&#8221;.<\/p>\n\n\n\n<p class=\"has-moon-dust-blue-background-color has-background\">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. <\/p>\n\n\n\n<p class=\"has-neutral-grey-background-color has-background\">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. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"469\" height=\"220\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/8088\/files\/2025\/01\/th-1.jpeg\" alt=\"\" class=\"wp-image-29\" style=\"width:610px;height:auto\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/8088\/files\/2025\/01\/th-1.jpeg 469w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/8088\/files\/2025\/01\/th-1-300x141.jpeg 300w\" sizes=\"auto, (max-width: 469px) 100vw, 469px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Works Cited <\/h2>\n\n\n\n<p>Dyankov, Dimitar. \u201cClean Code Principles: Best Practices for Writing High-Quality Software.\u201d&nbsp;<em>The Coding Hub<\/em>, 24 May 2023, <a href=\"http:\/\/www.thecodinghub.com\/articles\/clean-code-principles-best-practices-for-writing-high-quality-software\" data-type=\"link\" data-id=\"www.thecodinghub.com\/articles\/clean-code-principles-best-practices-for-writing-high-quality-software\">www.thecodinghub.com\/articles\/clean-code-principles-best-practices-for-writing-high-quality-software<\/a>.<\/p>\n\n\n\n<p>Lacerda, Guilherme, et al. \u201cCode Smells and Refactoring: A Tertiary Systematic Review of Challenges and Observations.\u201d&nbsp;<em>Journal of Systems and Software<\/em>, vol. 167, Sept. 2020, p. 110610, <a href=\"https:\/\/doi.org\/10.1016\/j.jss.2020.110610\">https:\/\/doi.org\/10.1016\/j.jss.2020.110610<\/a>. <\/p>\n\n\n\n<p>\u200c<\/p>\n\n\n\n<p class=\"has-pine-stand-color has-text-color has-link-color wp-elements-f9ee921d9f280a832fbeb7c4e7784342\"><em>Blogs by Brett Sullivan<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is one thing from the articles that you would like to start doing (more often), and why? I found an interesting article, \u201cClean Code Principles: Best Practices for Writing High-Quality Software.\u201d, that lists some of the most important concepts to do our best to adhere to, in order to create and maintain clean code [&hellip;]<\/p>\n","protected":false},"author":14472,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[4],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-cs-461","tag-clean-code"],"_links":{"self":[{"href":"https:\/\/blogs.oregonstate.edu\/soulobrettcs\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.oregonstate.edu\/soulobrettcs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.oregonstate.edu\/soulobrettcs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/soulobrettcs\/wp-json\/wp\/v2\/users\/14472"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/soulobrettcs\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":6,"href":"https:\/\/blogs.oregonstate.edu\/soulobrettcs\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":34,"href":"https:\/\/blogs.oregonstate.edu\/soulobrettcs\/wp-json\/wp\/v2\/posts\/26\/revisions\/34"}],"wp:attachment":[{"href":"https:\/\/blogs.oregonstate.edu\/soulobrettcs\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/soulobrettcs\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/soulobrettcs\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}