Whatever the category of pattern, it is very useful to have a standard way of describing and documenting a pattern so that it can be easily referenced, compared with other patterns, and reused. Three important aspects of a pattern that need to be captured (Buschmann et al. 1996) are the context, problem, and solution.
The context is the situation that gives rise to a problem.
The problem refers to a recurring problem that arises in this context.
The solution is a proven resolution to the problem.
A template for describing a pattern usually also addresses its strengths, weaknesses, and related patterns. A typical template looks like this:
- Pattern name
- Aliases. Other names by which this pattern is known.
- Context. The situation that gives rise to this problem.
- Problem. Brief description of the problem.
- Summary of solution. Brief description of the solution.
- Strengths of solution
- Weaknesses of solution
- Applicability. When you can use the pattern.
- Related patterns
- Reference. Where you can find more information about the pattern.
- An example of documenting a pattern is given next for the Layered Pattern.
- Pattern name: Layers of Abstraction
- Aliases: Hierarchical Layers, Levels of Abstraction
- Context: Software architectural design
- Problem: A software architecture that encourages design for ease of extension and contraction is needed.
- Summary: of solution Components at lower layers provide services for components at higher layers. Components may use only services provided by components at lower layers.
- Strengths: of solution Promotes extension and contraction of software design.
- Weaknesses: of solution Could lead to inefficiency if too many layers need to be traversed
- Applicability: Operating systems, communication protocols, software product lines
- Related patterns: Kernel can be lowest layer of Layers of Abstraction architecture. Variations of this pattern include Flexible Layers of Abstraction.
- Reference: Hoffman and Weiss 2001; Parnas 1979.