mercredi 28 avril 2021

Decorator or Chain of responsibility

My application has a scheduled (weekly) task to populate different attributes of an object. This application will be multi tenant which means, for each tenant, the application might have to populate different/subset attributes. To meet this requirement, I want to choose the right design pattern for my scheduled job. Two design patterns are under active consideration.

  1. Decorator
  2. Chain of responsibility

The main difference that I could find between these patterns is that, in the former the object gets pass through each class in the pipeline whereas in the latter only one class in the pipeline will act on the object.

For decorator, I would create separate class for each attribute whereas for chain of responsibility, I would create separate class for each tenant. Is my understanding correct?

enter image description here

ps :: If my understanding is correct, I would prefer decorator.

Aucun commentaire:

Enregistrer un commentaire