mercredi 2 septembre 2015

Suitable design pattern for matrix-like feature

Which design pattern or combination of patterns would be correct or most suitable for the following common scenario:

Let's say I have a method which places an order. I have different order types and different countries. The method's implementation differs based on order type and also country.

My idea is to use the strategy pattern where I could have objects like OrderType1Country1Strategy, OrderType1Country2Strategy, OrderType2Country1Strategy etc.

My problem with this is that any two class can have common code which I'm not sure how best to handle. Any ideas for that or alternative patterns? Could decorator be used somehow?

Aucun commentaire:

Enregistrer un commentaire