samedi 26 mai 2018

Which Design Pattern use

Let's say I have a class products where I have a stock and can pay in 2 ways: Paypal or cash. I can only sell 2 products cash. This might change in the future so I don't want to have to change the whole code with ifs and else so I thought of using the Strategy Pattern.

I'm just learning about design patterns. I'm most interesten in an UML design first before going to code.

So, is this a good pattern for my case? I might add more validations to the Cash class or to the Paypal class.

Aucun commentaire:

Enregistrer un commentaire