{"id":33,"date":"2024-01-18T22:53:12","date_gmt":"2024-01-18T22:53:12","guid":{"rendered":"https:\/\/blogs.oregonstate.edu\/audrienielsen\/?p=33"},"modified":"2024-01-18T22:53:12","modified_gmt":"2024-01-18T22:53:12","slug":"writing-clean-code","status":"publish","type":"post","link":"https:\/\/blogs.oregonstate.edu\/audrienielsen\/2024\/01\/18\/writing-clean-code\/","title":{"rendered":"Writing Clean Code"},"content":{"rendered":"\n<p>As my team and I begin to dive deep into development, I have identified a few coding habits that I want to change to avoid code smells and write clean code. <\/p>\n\n\n\n<p>I like to think that I keep my code pretty clean. I use descriptive names, consistent indenting, sufficient white space and keep line counts to a minimum, all the things they drill into you in you first computer science class. But after reading an article written by software developer Claudia Sanjuan &#8220;<a href=\"https:\/\/www.unosquare.com\/blog\/10-tips-for-writing-cleaner-code-in-any-programming-language\/\">10 Tips for Writing Cleaner Code in Any Programming Language<\/a>&#8220;, one tip that I took away is to make sure that functions only serve one purpose, and keep them short. I think that when writing code, my first instinct is to solve my problem in one function. This leads to long complex functions, when the problem could have been solved in a manner of 1-2 simpler functions. Paying attention to when my functions should be split up into smaller, simpler functions is something I am going to work on going forward.<\/p>\n\n\n\n<p>One habit I am working on breaking is saving dead code. An article &#8220;<a href=\"https:\/\/pragmaticways.com\/31-code-smells-you-must-know\/#1_Comments\">31 Code Smells All Developers Must Watch Out For<\/a>&#8221; from software engineering blog Pragmatic Ways, lists dead code &#8211; code that is not being used in the programming or is commented out &#8211; as #4. I have a habit of commenting out code and saving it for later, worried that I might want to use it instead. But as the article mentions, that is the purpose of version control. In the future, I plan to make sure that I delete dead code I don&#8217;t need to clean up my codebase. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>As my team and I begin to dive deep into development, I have identified a few coding habits that I want to change to avoid code smells and write clean code. I like to think that I keep my code pretty clean. I use descriptive names, consistent indenting, sufficient white space and keep line counts [&hellip;]<\/p>\n","protected":false},"author":13686,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-33","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.oregonstate.edu\/audrienielsen\/wp-json\/wp\/v2\/posts\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.oregonstate.edu\/audrienielsen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.oregonstate.edu\/audrienielsen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/audrienielsen\/wp-json\/wp\/v2\/users\/13686"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/audrienielsen\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":1,"href":"https:\/\/blogs.oregonstate.edu\/audrienielsen\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":34,"href":"https:\/\/blogs.oregonstate.edu\/audrienielsen\/wp-json\/wp\/v2\/posts\/33\/revisions\/34"}],"wp:attachment":[{"href":"https:\/\/blogs.oregonstate.edu\/audrienielsen\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/audrienielsen\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/audrienielsen\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}