0
Completed

Publisher - Subscriber pattern.

pedodorfo 6 years ago updated 6 years ago 2

They taught us this pattern/principle in University but I don't see it here. Why? What am I missing?

Answer

Answer
Completed

That's a nickname for the Observer pattern.

Answer
Completed

That's a nickname for the Observer pattern.

Hey wait no. Isn't Publisher - Subscriber (PS) like Observer pattern but PS has this middle man? The middle man accepts every event Publisher publishes and decides which Subscriber wants to see which event from the Publisher?

Example for observer:

TV News - Subject

Your family - bunch of Observers.

TV News sends out information about new technologies and about new cooking recipes and every member of your family acknowledges that there are new technologies and new cooking recipes but does nothing with that info.


Example for PS:

TV News - Publisher

Your family - bunch of Subscribers.

Butler - the middle man.

Each member of the family subscribes to the butler (tells the butler that one of them likes technology news and other

members like cooking news and some of them both and some of them none) and then when the TV announces new technology butler informs only those people who wanted the technology news.


I mean it is similar but not the same. So I'm not sure if it is just a nickname. More of a subclass of Observer but there is no info about it.