Patterns and Pattern Languages
A software design pattern defines a proven approach to solving a problem. The solution described in the pattern is typically a set of components that are interacting in a particular configuration. The pattern explains why this approach works, its associated trade-offs, and resulting benefits and liabilities. It also links to other patterns that may:
- Provide an alternative approach
- Provide a complementary capability
- Describe an approach to implementing a component that is named in the pattern’s solution
This linking together of related patterns creates what we call a pattern language.
Every pattern in this pattern language has a name that summarizes the solution it represents in a succinct manner. For example, there is a pattern calledINFORMATIONCOLLECTION that describes a collection of related information. Notice that the pattern name is written using the small capitals formatting. This formatting convention is used wherever the pattern is first referenced in a section. The name of a pattern can act as shorthand for the solution during design discussions.
Choosing the terminology for the pattern names has been a challenge because the pattern language covers multiple architectural disciplines. Where possible, we have used industry standard names for the concepts and components exposed in the pattern language. However, we have found it necessary to introduce new terminology whenever there is conflicting nomenclature, or no obvious name exists.
Every pattern has an icon that can be used as a visual reminder of the pattern, particularly when whiteboarding and documenting solutions. The information collection icon is shown inFigure 1.4.
Figure 1.4. Icon for the information collection pattern.
The patterns are built on a common component model. This means that a pattern can be used as a component in the solution described by another pattern. When this occurs, the icon of the pattern is used in the solution diagram of the consuming pattern. For example,Figure 1.5shows the solution for the staging area introduced in the previous section. It is built from a variety of pattern icons.
Figure 1.5.The solution diagram for a staging area showing the use of the information collection icon.
The meaning of the icons in the diagram, and the details of the patterns behind them, will become familiar to you as you work with the pattern language. The purpose here is to illustrate how the icon of one pattern, the information collection in this case, can be used in the solutions of other patterns.
Each of the patterns of information management can be used independently. However, the real value of a pattern language is the ability to compare and contrast different approaches to resolving a situation.
The patterns of information management that are relevant to a particular situation are collected together in a pattern group. Each pattern group has a lead pattern that describes the core principles and capabilities of the group. The pattern group is named after the lead pattern. The other patterns in the pattern group enhance one or more characteristics of the lead pattern to support a more specialized situation.
You may have noticed that inFigure 1.5, the information collection icon appears slightly modified in the solution diagram with five lines coming out of the left side (as shown inFigure 1.6). The modification to the information collection icon denotes that the staging area uses specialized information collections described by theTRANSIENTSCOPE pattern.
Figure 1.6. Icon for the transient scope pattern.
The modified icon visually represents that there is a relationship between the information collection and transient usage patterns. They are, in fact, from the same pattern group along with other patterns calledLOCALSCOPE andCOMPLETESCOPE.
To make it easy to compare and contrast the patterns in a group, each group of patterns begins with a table of pattern summaries, called patlets. A patlet shows a pattern’s icon, name, short problem statement, and summary of the solution. The aim of the patlets is to help you quickly discover and navigate to the pattern you need. Table 1.1 shows the patlet for theINFORMATIONCOLLECTION pattern, which is the lead pattern in its group.
Table 1.1. Sample Pattern Summary for Information Collection
Icon |
Pattern Name |
Problem |
Solution |
INFORMATIONCOLLECTION |
Information must be organized so it can be located, accessed, protected, and maintained at a level that is consistent with its value to the organization. |
Group related information together into a logical collection and implement information services to access and maintain this information. |
Table 1.2 shows the related scope patterns from the same group. Notice that the icons are all variations of the information collection icon.
Table 1.2. Patlet Table for the Scope Patterns in the Information Collection Group
Icon |
Pattern Name |
Problem |
Solution |
COMPLETESCOPE |
An information process needs to perform an activity once for each instance of a particular subject area (such as a customer, product, order, invoice, shipment, etc.) that occurs within the information supply chain. |
The information process needs to use an information collection that stores a single information entry for each instance of the subject area that occurs within the information supply chain. Such an information collection is said to have a complete scope. |
|
LOCALSCOPE |
信息流程的实现hosted within an information node assume they are in complete control of changes to the information they use. |
Provide information collections within the information node for the sole use of its information processes. These information collections will then only have information entries that are created by the locally hosted information processes. These types of information collections are said to have a local scope. |
|
TRANSIENTSCOPE |
An information node needs to provide temporary storage for information entries that are being continuously added and removed by the information processes. |
Create an information collection to temporarily store the information entries in the information node. From time to time, the information entries stored in this information collection will change, and so we say this collection has transient scope. |
The detailed pattern descriptions follow the patlet tables. Many different styles and heading structures have been successfully used to describe software patterns. We have chosen to use one of the formats recommended by The Open Group Architecture Framework (TOGAF®)1with the following subsections:
- Context—The situation where it is appropriate to consider using the pattern
- Problem—A description of the problem that this pattern solves
- Example—An example of the problem
- Forces—The factors that make this problem hard to solve
- Solution—A description of solution components and how they are assembled together
- Consequences—The benefits and liabilities of using the solution
- Example Resolved—How the example described is resolved using the pattern
- Known Uses—References to well-known technologies and approaches that support the pattern
- Related Patterns—Links to other relevant patterns in the pattern language
这些部分提供一种汇集variety of information into a well-formed structure that summarizes the essence of the pattern. Together, they enable you to make reasoned choices of approach for the solution you are building.