Behavioral patterns
Behavioral patterns are intended to simplify the interactions between classes by structuring the processes of their interaction.
This section provides three examples of popular behavioral patterns that you may want to consider when writing Python code:
- Observer
- Visitor
- Template
Observer
The observer pattern is used to notify a list of objects about a state change of the observed component.
Observer allows adding features in an application in a pluggable way by de-coupling the new functionality from the existing code base. An event framework is a typical implementation of the observer pattern and is described in the figure that follows. Every time an event occurs, all observers for this event are notified with the subject that has ...
Get Expert Python Programming - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.