mardi 4 janvier 2022

In which cases is the observer pattern superior to the PubSub pattern?

At the moment I'm learning about important OOP design patterns and are currently studying the differences between the Observer and the PubSub pattern and how to implement them in Python. For that reason, I'm asked to implement some easy notification service for a SmartHome with the help of the Observer Pattern. Thereby, the notification service should send notification messages when the house is empty and e.g. the light is still turned on.

Now in a subsequent task I'm asked to argue why the observer pattern is superior to the PubSub pattern in the above example. At the moment I am a little unsure how to answer this question, because I would have considered the PubSub pattern for the above example to be more suitable. However, despite all that I've come to an argument where the Observer pattern might be superior to the PubSub pattern.

  • PubSub pattern relies on a many-to-many communication.
  • Confidentiality and authenticity of messages is strongly coupled to the security of the broker that mediates all dataflows.
  • Publishers and subscribers can easily connect to a broker and exchange data via specific topics which is also true for an attacker (many-to-many communication).
  • Passive attackers outside the publish/subscribe network can eavesdrop the communication and try to discover content of events and subscriptions.

Due to the above "weaknesses", this would mean that an attacker could potentially monitor if any of the house owners is currently at home to commit burglary if the PubSub pattern is not implemented carefully. However, from my point of view the Subject in the Observer pattern could establish a one-to-one communication on calling the "update" method and establish a secure channel to maintain Confidentiality and Integrity of the sent state change notification.

At the moment, I'm not quite sure about the correctness of my argumentation and would like to ask if anyone could give me a hint to answer this question.

Thank you in advance for your help.

Best regards,

RatbaldMeyer

Aucun commentaire:

Enregistrer un commentaire