Database mapping woes
Monday, August 4th, 2008For the past week I’ve been struggling with some Object-Relational Mapping issues. At the core it was an optimization issue, which may seem non-essential, but it caused the database layer to create records and run queries that weren’t really needed. So I dived in to some of the less pretty parts of my code and wrestled just as long as I had to, to get it to do what I want.
ORM isn’t always a perfect solution, and every implementation has its flaws. Your choice depends on the domain you’re trying to model. In the case of Particracy, there’s a very rich and complex model that depends less on sheer quantity of data, and more on the kind of logic I feel comfortable expressing with Objects and inheritance. In designing a database-backed application, you need to decide up front whether your master model is your database schema, or your domain class hierarchy, and I chose the latter. I could nag on for hours about this object-relational impedance mismatch, but I’m not going to do that here.
With these issues (hopefully) behind me, I can get back to the real work, which is finishing the features that will make it into the alpha, polishing up the user interface where required, providing the game with some basic content (such as the map, some nations, ethnicities and of course proposal variables) and lots of testing.