Modeling Patterns, Part 2: Modeling Pattern Definitions
In part 1, we discussed an approach to modeling patterns that focuses on:
- Modeling as it makes sense and adds value while focusing on content and intent.
- Recognizing that details about pattern definitions and pattern applications provide a useful mechanism for communicating important information about pattern usage in a model.
In this part, we’ll focus on what it means to capture pattern definitions in a model.
Nowadays the use of modeling is most common in the context of pattern definitions. Examples are typically found in pattern specifications. Even if UML is commonly used you could use any other visual representation that would best suit the audience of the pattern definition. Remember that in the context of pattern definition, the intent of visual modeling is to better communicate the pattern so you need to use a visual representation that would be easily understood by your audience. The common representation is a kind of class diagram showing the pattern structure, also called the static aspect. Below is the class diagram representation of the structure of the Subsystem Façade pattern we use as an example in the book.
Figure 1 – Simplified view of the structure of the Subsystem Façade pattern
Another important representation is the behavioral aspect showing a dynamic view of the pattern. In the behavioral aspect, we show how the different parts of the pattern interact together to carry the behavior of the pattern. It is often a combination of the static and dynamic aspects that really illustrates how to apply the pattern. Figure 2 shows the behavioral aspect of creating a new business entity object using the Subsystem Façade pattern.
Figure 2 – Behavioral aspect of the Subsystem Façade pattern
Using informal modeling works well when you want to use a pattern specification as a blueprint to help people manually apply the pattern. However, if the intent is to have pattern implementations consume your model, either to automatically apply the pattern or to even detect occurrences of the pattern, then more rigor and formalism is needed so that your pattern modeling becomes machine-readable.