Appendix I
The Gang of Four Companion
This appendix demonstrates how informal specifications of some of the design patterns in the seminal Gang of Four catalogue [Gamma et al 1995] can be specified formally using Codecharts. Each section contains a brief description of the pattern, followed by a UML class diagram of the pattern's structure and a Codechart.
ABSTRACT FACTORY
See §11.4.
ADAPTER
Intent Convert a class's interface to one that a client expects.Participants
- Target: Defines the interface that Client uses.
- Client: Collaborates with objects conforming to the Target interface.
- Adaptee: Defines an existing interface that needs adapting.
- Adapter: Adapts the interface of Adaptee to the Target interface.
Collaborations Clients call operations on an Adapter instance. In turn, the adapter calls Adaptee operations that carry out the request. The collaboration can take in either one of two forms: In the Adapter (class) variation, the Adapter class inherits from the Adaptee class, and in the Adapter (object) variation, the Adapter class holds a member (field) instance of the Adaptee class.
Get Codecharts: Roadmaps and blueprints for object-oriented programs now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.