Recipes to Reuse


We propose to use objects as closures for behavior parameterization. In contrast to reuse by inheritance, they realize reuse by composition. Closures allow black-box behavior parameterization with encapsulated components, promote function reuse, allow calculations on demand, represent first-class behavior, i.e., feature protocol-, undo-, and persistence mechanisms, and can represent ``business-transactions''. In this paper, we present closures as the object-oriented design pattern Recipe. In contrast to the Command pattern, Recipe establishes a useful collaboration with iterators. We show in particular how to use generic recipes with iterators in order to allow multi-dispatching operations on heterogeneous data structures.

13 pages.