Design Patterns

Contents

  1. Introduction
    1. What is a Design Pattern? “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice.” In general, a pattrn has four essential elements
      1. The pattern name
      2. The problem describes when to apply the pattern
      3. The solution describes the elements that make up the design, their relationships, responsibilities, and collaborations.
      4. The consequences are the results and trade-offs of applying the pattern.
    2. Design Patterns in Smalltalk MVC. The Model/View/Controller (MVC) triad of classes is used to build user interfaces in Smalltalk-80…
    3. Describing Design Patterns. We describe design patterns using a consistent form. Each pattern is divided into sections according to the following template. The template lends a uniform structure to the information, making design patterns easier to learn, compare, and use.

      Design Pattern Template

      Pattern Name and Classification

      The pattern's name conveys the essence of the pattern succinctly. A good name is vital, because it will become part of your design vocabulary. The pattern's classification reflects the scheme we introduce in Section 1.5.

      (pattern) Intent

      A short statement that answers the following questions:

      • What does the design pattern do?
      • What is its rationale and intent?
      • What particular design issue or problem does it address?
      (pattern) Motivation

      A scenario that illustrates a design problem and how the class and object structures in the pattern solve the problem. The scenario will help you understand the more abstract description of the pattern that follows.

      (pattern) Structure

      A graphical representation of the classes in the pattern using a notation based on UML. We use interaction diagrams, also.

      (pattern) Participants

      The classes and/or object participating in the design pattern and their responsibilities.

      (pattern) Collaborations

      How the participants collaborate to carry out their responsibilities.

      (pattern) Consequences

      How does the pattern support its objectives? What are the trade-offs and results of using the pattern? What aspect of system structure does it let you vary independently?

      (pattern) Implementation

      What pitfalls, hints or techniques should you be aware of when implementing the pattern? Are there language-specific issues?

      (pattern) Sample Code

      Code fragments that illustrate houw you might implement the pattern in C++ or Smalltalk.

      (pattern) Known Uses

      Examples of the pattern found in real systems. We include at least two examples from different domains.

      Related Patterns

      What design patterns are closely related to this one? What are the important differences? With which other patterns should this one be used?

      · 2010/10/08 14:08 · Maurice Lanselle
    4. The Catalog of Design Patterns
    5. Orgnaizing the Catalog
    6. How Design Patterns Solve Design Problems
    7. How to Select a Design Pattern
    8. How to Use a Design Pattern
  2. A Case Study: Designing a Document Editor
    1. Design Problems
    2. Document Structure
    3. Formatting
    4. Embellishing the User Interface
    5. Supporting Multiple Look-and-Feel Standards
    6. User Operations
    7. Spelling Checking and Hyphenation
    8. Summary
  3. Creational Patterns
    1. Abstract Factory.
      > Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
    2. Builder
      > Separate the construction of a complex object from its representation so that the same construction process can create different representations.
    3. Factory Method
      > Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
    4. Prototype
      > Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
    5. Singleton
      > Ensure a class only has one instance, and provide a global point of access to it.
    6. Discussion of Creational Patterns
  4. Structural Patterns
    1. Adapter
      > Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.
    2. Bridge
      > Decouple an abstraction from its implementation so that the two can vary independently.
    3. Composite
      > Compose objects into tree structures to represent part-whole hierarchies. Composite lest clients treat individual objects and compositions of objects uniformly.
    4. Decorator
      > Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
    5. Facade
      > Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsytem easier to use.
    6. Flyweight
      > Use sharing to support large numbers of fine-grained objects efficiently.
    7. Proxy
      > Provide a surrogate or placeholder for another object to control access to it.
  5. Behavioral Patterns
    1. Chain of Responsibility
      > Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.
    2. Command
      > Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations.
    3. Interpreter
      > Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.
    4. Iterator
      > Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
    5. Mediator
      > Define an object that encapsulated how a set of object interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.
    6. Memento
      > Without violating encapsulation, capture and externalize an object's internal state so that the object can be restored to this state later.
    7. Observer
      > Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
    8. State
      > Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
    9. Strategy
      > Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
    10. Template Method
      > Define the skeleton of an algorithm in an operation, deferring some steps to the subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the slgorithm's structure.
    11. Visitor
      > Represent an operation to be performed on the elements of an object structure. Visitor lest you define a new operation without changing the classes of the elements on which it operates.
    12. Discussion of Behavioral Patterns
  6. Conclusion
    1. What to Expect from Design Patterns
    2. A Brief History
    3. The Pattern Community
    4. An Invitation
    5. A Parting Thought
  7. Glossary
  8. Guide to Notation
  9. Foundation Classes
  10. Bibliography

 
m2ilc/design_patterns.txt · Dernière modification: 2010/10/08 14:44 par suitable