The list of open bugs and enhancements has been accumulating for some time now and I haven’t been able to keep up. I need to increase my productivity by reducing the number of bugs created and making it easier to implement new features. Refactoring is the key to accomplishing this. Specifically, I’m doing the following:
- Making greater use of Unity composition to handle actor/item/object interactions in a more maintainable way.
- Consolidating methods that do similar things. For example, I implemented a method for adding items to the map early in development, and a different one later on in a different class. They don’t do exactly the same thing, and this anti-pattern has been a major source of bugs, unsurprisingly. I need to more consistently follow the single-responsibility principle; the challenge has been that, as the game has evolved, the appropriate source of responsibility in some cases has changed.
- Reducing instances of functional coupling. For example, there are separate methods to create items and instantiate Unity GameObjects. These methods are often called together, and problems arise when I forget to call both. Except in a couple of edge cases, these two methods can be combined into one.
To that end, I spent most of the week on the first and second items listed above and made enormous progress. I’m always amazed at how much easier software development is when solid architecture and code design are in place; recreating existing objects into the new architectural framework has been a breeze compared to creating the objects in the previous framework.
Next week, I should be able to wrap up the refactoring and then revisit the bug list. Hopefully a lot of the bugs will have been indirectly addressed through the refactoring.