1

I am learning the basics of software engineering independently. And there's something I did not understand about the observer design template.

enter image description here

I have this diagram, in this diagram I marked what each part says, whether it is an observer, subject, concreteObserver or adapter.

From this chart I did not understand if it is a model of push or pull. In my opinion it's a pull, but I'm not sure. I think it's Pull, because we inform our Observers that there was a change, and the Observers go and check what the change was and interrogate the subject's state.

I would be happy if you could help me.

1 Answers1

0

Clearly the ColourHandler is a Subject and the ColourSelectors are its Observers. Colour itself is a simple data structure. I have no idea why it would have a set_colour() method. An enum would be sufficient. Adapter is a separate design pattern, unrelated to Observer.

No implementation of the update() method is shown; however, we can see it takes no arguments. That is a strong indication of a pull model: the ColourSelectors must query the ColourHandler to determine the new Colour. Another indication is the circular dependency between Subject and Observer. In a push model, the Observer needn't be coupled to the Subject.

Also see the GoF description of push vs pull.

jaco0646
  • 15,303
  • 7
  • 59
  • 83