Coming back to code that is “aged” to any extent (HamQuest is about a year old as a code-base), it is easy to spot the flaws and quick decisions that painted the code into a corner.
Normally I think “This code sucks! I totally need to re-write it!”
But then I asked myself a very simple question: “You have written games a hundred times. You have rewritten those games another hundred. Since when has that ever actually helped you finish any of them?”
So I’ve been slowly going over the code. In many way, software development is more like making bread. We add stuff, we remove stuff, we mix stuff around.
What started out as a single executable has turned into an executable and two dlls. Originally I had just split out a single dll for the game itself, but once I had done that, I could see that there were a number of classes that were generic (something of a pun as most of the classes are generics) enough that they didn’t have anything to do with the game specifically. There is now a dll called PDGBoardGames, which includes things like a Board class and a Maze class, both of which generic enough that they can be reused whenever I need a board or maze provided I remain in .Net land.
As I keep pulling stuff out of code and into XML files, more and more of the existing classes become unnecessary. Item management has had the most work done, and there is not a single mention within the ItemTable class about any specific item. Everything is either in the XML file, or derivable from the data in the xml file.
So, my usual thoughts about a codebase like HamQuest is “If I had done it right in the first place, it wouldn’t be like this.” But I don’t think that way this time. As far as codebases go, HamQuest isn’t all that bad or convoluted, which I attribute to my having worked on code for a long time, so a number of good habits have formed along the way.
However, I have spent the last few weeks working over the code and making it do exactly the same thing it did before, just a little more flexibly. Thankfully, I haven’t had any performance hits.