I have a currently-existing stock management dashboard. The user selects a warehouse, and it displays the current stock in this warehouse. The stock management teams wants to display a date, calculated with various parameters.

The problem is that there are several warehouses, and since they work differently, they want to display the date based on different factors.
For instance, one might process regular items like cloths, the other processes large items like furniture, and a third processes fresh items (food). So they have very different ways of handling their stock.

How should I design my app so that the date handling is specific to each warehouse?

I see 2 possibilities:

  • using a rules engine, but I'm very not sure that it's appropriate (I only know that the concept exists)
  • using a factory design pattern, which will instantiate one warehouse class or another depending on the warehouse ID from the DB, and use this class to calculate the date.

Which one seems the more appropriate? Maybe I missed another possibility?

  • 1
    I like the Factory idea. Rules engines are probably not something you want to get mired in right now, and the factory will work just fine. Commented Mar 14, 2016 at 17:18
  • I think it's a workflow problem for each kind of item (even each furniture might get handled differently) Commented Mar 14, 2016 at 18:52

1 Answer 1


Abstract Factory on top of strategy pattern is the best fit for this use case. Where strategy pattern decides which warehouse to be instantiated.

Hope that helps at least in designing the class diagram.

  • Could you expand this answer with a brief explanation of why those patterns are the best fit?
    – Ixrec
    Commented Mar 22, 2016 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.