Design: How to model / where to store relational data between classes
- by Walker
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.