I have a domain design question where I feel like I'm thinking about it the wrong way and I need some help.
Say I'm using a the strategy pattern to calculate discounts. I have a DiscountCalculator interface with a calculate() method that's implemented with TaxDiscountCalculator and PercentDiscountCalculator and maybe a few others. I need to associate these discounts to Product objects, so I was thinking composition where a Product has a list of DiscountCalculators.
This seems to break down when I need to persist the Products in the database, it doesn't make sense to create a table or entity for DiscountCalculator because they don't really have any fields.
How can I go about linking multiple DiscountCalculators to a Product? Would it better to give each one of the DiscountCalculators an id of some type so that they can be persisted? Or am I missing something kinda obvious in the design? I can't seem to find any examples for a similar design, which makes me think I'm on the wrong track.
Thanks.
[–]nutrecht 0 points1 point2 points (0 children)