Design: How to model / where to store relational data between classes
Posted
by
Walker
on Game Development
See other posts from Game Development
or by Walker
Published on 2012-10-28T21:01:58Z
Indexed on
2012/10/28
23:23 UTC
Read the original article
Hit count: 260
I'm trying to figure out the best design here, and I can see multiple approaches, but none that seems "right."
There are three relevant classes here: Base, TradingPost, and Resource. Each Base has a TradingPost which can offer various Resources depending on the Base's tech level.
Where is the right place to store the minimum tech level a base must possess to offer any given resource? A database seems like overkill. Putting it in each subclass of Resource seems wrong--that's not an intrinsic property of the Resource. Do I have a mediating class, and if so, how does it work? It's important that I not be duplicating code; that I have one place where I set the required tech level for a given item. Essentially, where does this data belong?
P.S. Feel free to change the title; I struggled to come up with one that fits.
© Game Development or respective owner