jzepeda
jzepeda

Reputation: 1620

Are Qt's signals and slots a form of publish-subscribe?

I don't think I've seen this comparison anywhere, but would they be considered the same? If not, why not?

Upvotes: 15

Views: 3176

Answers (2)

tinito
tinito

Reputation: 381

They are very similar, but there is a little difference:

  • signals/slots implement the observer pattern, where the producer has a reference to its subscribers and is responsible of notifying them

  • the publish/subscribe paradigm inserts an additional mediator, i.e., the topic handler, which decouples producers and consumers (the producers does not know who will consume messages)

A main consequence is that in the p/s paradigm you can have multiple producers on the same topic.

This is (probably) the most cited article about p/s: The many faces of publish/subscribe

Upvotes: 28

shofee
shofee

Reputation: 2129

publish subscribe is same as the signals and slots... check this...

http://en.wikipedia.org/wiki/Observer_pattern

http://doc.qt.nokia.com/qtmobility/publish-subscribe.html

Upvotes: 1

Related Questions