Chapter 14

Hollywood

image

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 ...

Get Exercises in Programming Style 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.