A ratchet wrench uses a suite of sockets. The large sockets
require a 3/8" square fitting, and the small sockets require a
1/4" fitting. The wrench itself only supplies the 3/8" fitting.
But – a 3/8" to 1/4" adapter readily bridges the mismatch. The Adapter pattern allows otherwise incompatible classes to work together by converting the interface of one class into an interface expected by the other class. [Michael Duell, "Non-software examples of software design patterns"] |
Pictures often have frames added, and it is the frame which is actually hung
on the wall. One or more mats are also optional. When complete,
the painting, the mat(s), and the frame form a single visual component.
The Decorator pattern demonstrates how to support many permutations of core and optional features in software – all the features are mapped to classes that each implement a common interface, and then the user can mix and match any set of features she desires. [Michael Duell, "Non-software examples of software design patterns"] |
The Mediator defines an object that controls how a set of objects interact. Loose coupling between colleague objects is achieved by having colleagues communicate with the Mediator, rather than with each other. The control tower at a controlled airport demonstrates this pattern very well. The pilots of the planes approaching or departing the terminal area communicate with the tower rather than explicitly communicating with one another. The constraints on who can take off or land are enforced by the tower. It is important to note that the tower does not control the whole flight. It exists only to enforce constraints in the terminal area. [Michael Duell, "Non-software examples of software design patterns", Object Magazine, Jul 97, p54] |
The Observer defines a one-to-many relationship so that when one object changes state, the others are notified and updated automatically. Some auctions demonstrate this pattern. Each bidder possesses a numbered paddle that is used to indicate a bid. The auctioneer starts the bidding, and "observes" when a paddle is raised to accept the bid. The acceptance of the bid changes the bid price which is broadcast to all of the bidders in the form of a new bid. [Michael Duell, "Non-software examples of software design patterns", Object Magazine, Jul 97, p54] |
The Proxy provides a surrogate or place holder to provide access to an object. A check or bank draft is a proxy for funds in an account. A check can be used in place of cash for making purchases and ultimately controls access to cash in the issuer's account. [Michael Duell, "Non-software examples of software design patterns", Object Magazine, Jul 97, p54] |
The Chain of Responsibility pattern avoids coupling the sender of a request to the receiver by giving more than one object a chance to handle the request. Mechanical coin sorting banks use the Chain of Responsibility. Rather than having a separate slot for each coin denomination coupled with a receptacle for the denomination, a single slot is used. When the coin is dropped, the coin is routed to the appropriate receptacle by the mechanical mechanisms within the bank. [Michael Duell, "Non-software examples of software design patterns", Object Magazine, Jul 97, p54] |