I am writing some hobby project for poker game. My application will store a lot of games in database. I created representation of object Game which uses a lot of other objects like: PlayerHand (basically 2 Card objects as properties, and some utility methods like isSuited(), isPaired(), etc), Actions (describes stakes raisings done by players), Board (describes flop, turn and river cards), etc.
Problem is that for database storage I can describe game in a more compact and efficient way. For instance I can just use integers for each unique hand. Such representation is compact and good for DB, but for other logic implementation I would like to have more fields describing a hand then just one integer. I don’t like idea having both representations in one class this just doesn’t look right.
Question: what approach can be used for my problem?
The best solution I’ve come up with is something like MVC pattern. Where Model is my compact database representation and view is my business-logic representations. But again, this doesn’t seem right to me, because looks too complex for such a simple task. Are there more elegant approaches or maybe more simple patterns?
MVC is for the entire application, to separate flow control, from presentation, from business logic. What you need is Data Mapper, so you can have domain objects that know nothing about the db. For most applications I usually use both MVC and Data Mapper.