Take the 2-minute tour ×

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: Warehouse, TradingDesk, and Item. Each Warehouse has a TradingDesk which can offer various Items depending on the Warehouse's sophistication.

Where is the right place to store the minimum warehouse-sophistication level necessary to offer a certain Item? A database seems like overkill. Putting it in the Item seems wrong--that's not an intrinsic property of the Item. 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 sophistication 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.

share|improve this question
add comment

1 Answer

With just the information from your question, it's really hard to tell. I think you need to express your rules in some clear form first. As soon as you have the rules and their parameters, it will be easier to see what belongs where. Say, do you match WH sophistication to some (overlooked?) property of the item - or something else? How would you decide without any computer? Formalize first, then design.

share|improve this answer
The relation is defined in the real world; there's no real computation that needs to occur (though that's an interesting, related question). We basically sat down and determined what sophistication level was needed for each item, and constructed a table that lists relations like so: Item A--SophisticationLevel 3. For the purposes of the program, it can be considered arbitrary and merely subject to documentation. –  Walker Oct 28 '12 at 19:54
Well ,I think I start to understand what you are looking for. Bad news, it's a multicriterion decision. Simply put, it depends on how much data you have and what you are going to do with it. The good news is that there are some good tutorials. Not the easiest one but definitely worth looking at is this classical one; read about Domain Logic Patterns and Data Source Architectural Patterns first: martinfowler.com/eaaCatalog –  full.stack.ex Oct 28 '12 at 20:05
add comment

Your Answer


