publish-subscribe pattern def unregister(selfcallback)self callbacks discard(callbackdef unregister_all(self)self callbacks set(def poll_for_change(self)if self changedself update_all def update_all(self)for callback in self callbackscallback(selfalthough the observer pattern allows us to decouple the objects that are observed from knowing anything about the objects observing themthe observer objects still need to know which objects they need to observe sowe still have more coupling than we saw in the previous where we were able to change the view code without needing to change the controller or model codeand the same goes for the model code even the controllerwhich sits between the models and the viewsis fairly decoupled from both when we changed the viewwe had no need to also update the controllerand vice versa the observer pattern we dealt with previously works well when number of potential observable classes that an observer needs to register with is limited as with many things in programmingwe are often faced with challenges that do not comply with the ideal caseand so we need to adapt what we are going in search of in this is way to decouple the observer from the observable even more we want neither the observer nor the observable to know anything about each other each class and its instances should be able to change without any changes being needed on the other side of the equation new observers and observables should not require alterations in the code of the other classes in the systemas this would cause our code to be less flexible in an attempt to reach this idealwe will be looking at ways to extend the one-to-many methodologies of the observer pattern to many-to-many relationship between observables and observerssuch that one class of objects does not need to know much about the other these blind observables will be called publishersand the disconnected observers will be named subscribers