dimanche 29 mai 2016

Role of Invoker class in Command pattern

let's assume that we have command pattern implemented in this way

I am a bit confused about the role of Invoker here. From my point of view:

  1. If we do need history (or any kind of action before command execution), then there is a sense in making this class. But then it breaks Single responsibility principle, yeah? Now it's not only a delegate, it also stores history there.
  2. If we don't need history, I don't see a goal of creating this invoker, that simply performs delegating. Is the only reason for it is just a assumption, that we would need some kind of logic before/after command execution in the future?

Or am I missing something?

Aucun commentaire:

Enregistrer un commentaire