When given a programming project, I hone in on the provided requirements. I’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 “spaghetti code.”
So, I’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’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’s game development software through https://unity.com/solutions/game. 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’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.
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.
Below is the updated code block: