Common Modeling Techniques
Modeling Design Patterns
One thing for which you'll use patterns is to model a design pattern. When you model a mechanism such as this, you have to take into account its inside as well as its outside view.When viewed from the outside, a design pattern is rendered as a parameterized collaboration. As a collaboration, a pattern provides a set of abstractions whose structure and behavior work together to carry out some useful function. The collaboration's parameters name the elements that a user of this pattern must bind. This makes the design pattern a template that you use in a particular context by supplying elements that match the template parameters.When viewed from the inside, a design pattern is simply a collaboration and is rendered with its structural and behavioral parts. Typically, you'll model the inside of this collaboration with a set of class diagrams (for the structural aspect) and a set of interactions (for the behavioral aspect). The collaboration's parameters name certain of these structural elements, which, when the design pattern is bound in a particular context, are instantiated using abstractions from that context.To model a design pattern,
- Identify the common solution to the common problem and reify it as a mechanism.
- Model the mechanism as a collaboration, providing its structural as well as its behavioral aspects.
- Identify the elements of the design pattern that must be bound to elements in a specific context and render them as parameters to the collaboration.
Using collaborations to model a mechanism is discussed in Chapter 28 . |
Figure 29-4. Modeling a Design Pattern

Figure 29-5. Modeling the Structural Aspect of a Design Pattern

Figure 29-6. Modeling the Behavioral Aspect of a Design Pattern

Collaborations are discussed in Chapter 28; class diagrams are discussed in Chapter 8; interaction diagrams are discussed in Chapter 19 . |
Modeling Architectural Patterns
The other thing for which you'll use patterns is to model architectural patterns. When you model such a framework, you are, in effect, modeling the infrastructure of an entire architecture that you plan to reuse and adapt to some context.
Packages are discussed in Chapter 12 . |
Software architecture is discussed in Chapter 2 . |
- Harvest the framework from an existing, proven architecture.
- Model the framework as a stereotyped package, containing all the elements (and especially the design patterns) that are necessary and sufficient to describe the various views of that framework.
- Expose the plug-ins, interfaces, and parameters necessary to adapt the framework in the form of design patterns and collaborations. For the most part, this means making it clear to the user of the pattern which classes must be extended, which operations must be implemented, and which signals must be handled.
For example, Figure 29-7 shows a specification of the Blackboard architectural pattern (as discussed in Buschmann et al., Pattern-Oriented Software Architecture , New York, NY: Wiley, 1996). As its documentation states, this pattern "tackles problems that do not have a feasible deterministic solution for the transformation of raw data into high-level data structures." The heart of this architecture is the Blackboard design pattern, which dictates how KnowledgeSources, a Blackboard, and a Controller collaborate. This framework also includes the design pattern Reasoning engine, which specifies a general mechanism for how each KnowledgeSource is driven. Finally, as the figure shows, this framework exposes one use case, Apply new knowledge sources, which explains to a client how to adapt the framework itself.
Figure 29-7. Modeling an Architectural Pattern
