0
Completed

Publisher - Subscriber pattern.

pedodorfo 4 months ago • updated 4 months 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.

GOOD, I'M SATISFIED

I thought so but then why would they call it like that? I mean I have never heard anyone say Publisher - Subscriber pattern.

Satisfaction mark by pedodorfo 4 months ago
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.