O'Reilly logo

Codecharts: Roadmaps and blueprints for object-oriented programs by J. Nicholson, Amnon H. Eden

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

image

Figure I-1. UML Class diagram of the structure of the Adapter (class) pattern (adapted from [Gamma et al. 1995] by conversion from the OMT notation)

image

Codechart 112. Adapter (class) pattern

Figure ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required