Chapter 14
Hollywood
14.1 Constraints
- Larger problem is decomposed into entities using some form of abstraction (objects, modules or similar).
- The entities are never called on directly for actions.
- The entities provide interfaces for other entities to be able to register callbacks.
- At certain points of the computation, the entities call on the other entities that have registered for callbacks.
14.2 A Program in this Style
1 #!/usr/bin/env python
2 import sys, re, operator, string
3
4 #
5 # The "I'll call you back" Word Frequency Framework
6 #
7 class WordFrequencyFramework:
8 _load_event_handlers = []
9 _dowork_event_handlers = []
10 _end_event_handlers ...