{"id":1,"date":"2022-04-14T17:20:20","date_gmt":"2022-04-14T17:20:20","guid":{"rendered":"https:\/\/blogs.oregonstate.edu\/littlecodethings\/?p=1"},"modified":"2022-04-14T19:16:53","modified_gmt":"2022-04-14T19:16:53","slug":"compartmentalize","status":"publish","type":"post","link":"https:\/\/blogs.oregonstate.edu\/littlecodethings\/2022\/04\/14\/compartmentalize\/","title":{"rendered":"always remember to compartmentalize your code"},"content":{"rendered":"\n<p>When given a programming project, I hone in on the provided requirements. I&#8217;m very guilty of writing code from start to finish and clean up my code at the end. This, most often than not, leads to my codebase being filled with a bunch of &#8220;spaghetti code.&#8221; <br><\/p>\n\n\n\n<p>So, I&#8217;m working on my Capstone project with 2 other group members. I was tasked with creating restrictions for a board game editor. To give some context, our project is to build and design a board game creator that allows the user to create, edit, save, and play their very own customized board. It&#8217;s a simple game concept where multiple local players start on the same tile and roll dice to traverse to the finish-tile. Back to the task I was assigned, I spent roughly 5-6 hours watching YouTube tutorials on making board games through Unity. You can learn more about Unity&#8217;s game development software through <a href=\"https:\/\/unity.com\/solutions\/game\">https:\/\/unity.com\/solutions\/game<\/a>. After grasping the basic concepts of how to link Visual Studio Code and Github to Unity, I began writing the code for preventing users from creating tiles diagonally and tiles adjacent to another. My first initial thought was to write the function&#8217;s if-else statements within itself. With my completed code, I presented it to my team during our Standup meeting. Even with comments, my team had a hard time understanding where and how I was implementing the checks to prevent certain tile creation. The team leader and I sat down with my code and gave me guidance on how I should create smaller, specifically named functions to call within the main. The whole process only took 15-20 minutes in part due to the fact that I had already mapped out the code logic. <\/p>\n\n\n\n<p>I take every mistake as a learning experience. Sometimes, it just takes multiple people providing the same experience to really drill in the importance of the topic. Compartmentalize. Compartmentalize. Compartmentalize. It may take a little longer to proof my code, but just taking that extra time to clean up my codebase is definitely an important step toward my code career.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Below is the updated code block:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"783\" src=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/5652\/files\/2022\/04\/image-1024x783.png\" alt=\"\" class=\"wp-image-13\" srcset=\"https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/5652\/files\/2022\/04\/image-1024x783.png 1024w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/5652\/files\/2022\/04\/image-300x229.png 300w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/5652\/files\/2022\/04\/image-768x587.png 768w, https:\/\/osu-wams-blogs-uploads.s3.amazonaws.com\/blogs.dir\/5652\/files\/2022\/04\/image.png 1207w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>When given a programming project, I hone in on the provided requirements. I&#8217;m very guilty of writing code from start to finish and clean up my code at the end. This, most often than not, leads to my codebase being filled with a bunch of &#8220;spaghetti code.&#8221; So, I&#8217;m working on my Capstone project with [&hellip;]<\/p>\n","protected":false},"author":12462,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.oregonstate.edu\/littlecodethings\/wp-json\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.oregonstate.edu\/littlecodethings\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.oregonstate.edu\/littlecodethings\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/littlecodethings\/wp-json\/wp\/v2\/users\/12462"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/littlecodethings\/wp-json\/wp\/v2\/comments?post=1"}],"version-history":[{"count":2,"href":"https:\/\/blogs.oregonstate.edu\/littlecodethings\/wp-json\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":14,"href":"https:\/\/blogs.oregonstate.edu\/littlecodethings\/wp-json\/wp\/v2\/posts\/1\/revisions\/14"}],"wp:attachment":[{"href":"https:\/\/blogs.oregonstate.edu\/littlecodethings\/wp-json\/wp\/v2\/media?parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/littlecodethings\/wp-json\/wp\/v2\/categories?post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.oregonstate.edu\/littlecodethings\/wp-json\/wp\/v2\/tags?post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}