mercredi 30 août 2017

Recommended design patterns to apply

I need to solve a problem which at the first seems simple but make me confused quickly.

Suppose I have a User which holds Box objects. A Box is an abstract concept that is concretely implemented by some concrete classes, e.g. MoneyBox, PointBox, ValueBox, ItemBox, etc.

Moreover, a box object can be composed of multiple dependent Box objects which can be of the same type described above.

This means that a user can hold, for example, a MoneyBox and a PointBox. The MoneyBox can also have a dependent DiscountBox.

A box supports a defined number of behaviors like Activate, Use, Disable, etc.

The algorythm is activated from a request that should be applied to a User. The requests then shall be forwarded to every Box of that user. If a Box has dependents boxes, those shall be notified about the requests as well.

Forwarding a request to a box can be done in parallel for the boxes directly holded by the user but shall be done sequentially, based on an order field, to dependent boxes.

I have read many sources on the internet including patterns like Mediator, Chain of responsibility and Command but I can't get through on putting them all together.

Any help and/or suggestions?

Aucun commentaire:

Enregistrer un commentaire