You are previewing Design Patterns: Elements of Reusable Object-Oriented Software.
O'Reilly logo
Design Patterns: Elements of Reusable Object-Oriented Software

Book Description

Capturing a wealth of experience about the design of object-oriented software, four top-notch designers present a catalog of simple and succinct solutions to commonly occurring design problems. Previously undocumented, these 23 patterns allow designers to create more flexible, elegant, and ultimately reusable designs without having to rediscover the design solutions themselves.

The authors begin by describing what patterns are and how they can help you design object-oriented software. They then go on to systematically name, explain, evaluate, and catalog recurring designs in object-oriented systems. With Design Patterns as your guide, you will learn how these important patterns fit into the software development process, and how you can leverage them to solve your own design problems most efficiently.

Each pattern describes the circumstances in which it is applicable, when it can be applied in view of other design constraints, and the consequences and trade-offs of using the pattern within a larger design. All patterns are compiled from real systems and are based on real-world examples. Each pattern also includes code that demonstrates how it may be implemented in object-oriented programming languages like C++ or Smalltalk.



0201633612B07092001

Table of Contents

  1. Copyright
  2. Addison-Wesley Professional Computing Series
  3. Praise for Design Patterns: Elements of Reusable Object-Oriented Software
  4. Preface
  5. Foreword
  6. Guide to Readers
  7. 1. Introduction
    1. 1.1. What Is a Design Pattern?
    2. 1.2. Design Patterns in Smalltalk MVC
    3. 1.3. Describing Design Patterns
      1. Pattern Name and Classification
      2. Intent
      3. Also Known As
      4. Motivation
      5. Applicability
      6. Structure
      7. Participants
      8. Collaborations
      9. Consequences
      10. Implementation
      11. Sample Code
      12. Known Uses
      13. Related Patterns
    4. 1.4. The Catalog of Design Patterns
    5. 1.5. Organizing the Catalog
    6. 1.6. How Design Patterns Solve Design Problems
      1. Finding Appropriate Objects
      2. Determining Object Granularity
      3. Specifying Object Interfaces
      4. Specifying Object Implementations
        1. Class versus Interface Inheritance
        2. Programming to an Interface, not an Implementation
      5. Putting Reuse Mechanisms to Work
        1. Inheritance versus Composition
        2. Delegation
        3. Inheritance versus Parameterized Types
      6. Relating Run-Time and Compile-Time Structures
      7. Designing for Change
        1. Application Programs
        2. Toolkits
        3. Frameworks
    7. 1.7. How to Select a Design Pattern
    8. 1.8. How to Use a Design Pattern
  8. 2. A Case Study: Designing a Document Editor
    1. 2.1. Design Problems
    2. 2.2. Document Structure
      1. Recursive Composition
      2. Glyphs
      3. Composite Pattern
    3. 2.3. Formatting
      1. Encapsulating the Formatting Algorithm
      2. Compositor and Composition
      3. Strategy Pattern
    4. 2.4. Embellishing the User Interface
      1. Transparent Enclosure
      2. Monoglyph
      3. Decorator Pattern
    5. 2.5. Supporting Multiple Look-and-Feel Standards
      1. Abstracting Object Creation
      2. Factories and Product Classes
      3. Abstract Factory Pattern
    6. 2.6. Supporting Multiple Window Systems
      1. Can We Use an Abstract Factory?
      2. Encapsulating Implementation Dependencies
      3. Window and WindowImp
        1. WindowImp Subclasses
        2. Configuring Windows with WindowImps
      4. Bridge Pattern
    7. 2.7. User Operations
      1. Encapsulating a Request
      2. Command Class and Subclasses
      3. Undoability
      4. Command History
      5. Command Pattern
    8. 2.8. Spelling Checking and Hyphenation
      1. Accessing Scattered Information
      2. Encapsulating Access and Traversal
      3. Iterator Class and Subclasses
      4. Iterator Pattern
      5. Traversal versus Traversal Actions
      6. Encapsulating the Analysis
      7. Visitor Class and Subclasses
      8. Visitor Pattern
    9. 2.9. Summary
  9. Design Pattern Catalog
    1. 3. Creational Patterns
      1. Object Creational: Abstract Factory
        1. Intent
        2. Also Known As
        3. Motivation
        4. Applicability
        5. Structure
        6. Participants
        7. Collaborations
        8. Consequences
        9. Implementation
        10. Sample Code
        11. Known Uses
        12. Related Patterns
      2. Object Creational: Builder
        1. Intent
        2. Motivation
        3. Applicability
        4. Structure
        5. Participants
        6. Collaborations
        7. Consequences
        8. Implementation
        9. Sample Code
        10. Known Uses
        11. Related Patterns
      3. Class Creational: Factory Method
        1. Intent
        2. Also Known As
        3. Motivation
        4. Applicability
        5. Structure
        6. Participants
        7. Collaborations
        8. Consequences
        9. Implementation
        10. Sample Code
        11. Known Uses
        12. Related Patterns
      4. Object Creational: Prototype
        1. Intent
        2. Motivation
        3. Applicability
        4. Structure
        5. Participants
        6. Collaborations
        7. Consequences
        8. Implementation
        9. Sample Code
        10. Known Uses
        11. Related Patterns
      5. Object Creational: Singleton
        1. Intent
        2. Motivation
        3. Applicability
        4. Structure
        5. Participants
        6. Collaborations
        7. Consequences
        8. Implementation
        9. Sample Code
        10. Known Uses
        11. Related Patterns
        12. Discussion of Creational Patterns
    2. 4. Structural Patterns
      1. Class, Object Structural: Adapter
        1. Intent
        2. Also Known As
        3. Motivation
        4. Applicability
        5. Structure
        6. Participants
        7. Collaborations
        8. Consequences
        9. Implementation
        10. Sample Code
        11. Known Uses
        12. Related Patterns
      2. Object Structural: Bridge
        1. Intent
        2. Also Known As
        3. Motivation
        4. Applicability
        5. Structure
        6. Participants
        7. Collaborations
        8. Consequences
        9. Implementation
        10. Sample Code
        11. Known Uses
        12. Related Patterns
      3. Object Structural: Composite
        1. Intent
        2. Motivation
        3. Applicability
        4. Structure
        5. Participants
        6. Collaborations
        7. Consequences
        8. Implementation
        9. Sample Code
        10. Known Uses
        11. Related Patterns
      4. Object Structural: Decorator
        1. Intent
        2. Also Known As
        3. Motivation
        4. Applicability
        5. Structure
        6. Participants
        7. Collaborations
        8. Consequences
        9. Implementation
        10. Sample Code
        11. Known Uses
        12. Related Patterns
      5. Object Structural: Facade
        1. Intent
        2. Motivation
        3. Applicability
        4. Structure
        5. Participants
        6. Collaborations
        7. Consequences
        8. Implementation
        9. Sample Code
        10. Known Uses
        11. Related Patterns
      6. Object Structural: Flyweight
        1. Intent
        2. Motivation
        3. Applicability
        4. Structure
        5. Participants
        6. Collaborations
        7. Consequences
        8. Implementation
        9. Sample Code
        10. Known Uses
        11. Related Patterns
      7. Object Structural: Proxy
        1. Intent
        2. Also Known As
        3. Motivation
        4. Applicability
        5. Structure
        6. Participants
        7. Collaborations
        8. Consequences
        9. Implementation
        10. Sample Code
        11. Known Uses
        12. Related Patterns
        13. Discussion of Structural Patterns
          1. Adapter versus Bridge
          2. Composite versus Decorator versus Proxy
    3. 5. Behavioral Patterns
      1. Object Behavioral: Chain of Responsibility
        1. Intent
        2. Motivation
        3. Applicability
        4. Structure
        5. Participants
        6. Collaborations
        7. Consequences
        8. Implementation
        9. Sample Code
        10. Known Uses
        11. Related Patterns
      2. Object Behavioral: Command
        1. Intent
        2. Also Known As
        3. Motivation
        4. Applicability
        5. Structure
        6. Participants
        7. Collaborations
        8. Consequences
        9. Implementation
        10. Sample Code
        11. Known Uses
        12. Related Patterns
      3. Class Behavioral: Interpreter
        1. Intent
        2. Motivation
        3. Applicability
        4. Structure
        5. Participants
        6. Collaborations
        7. Consequences
        8. Implementation
        9. Sample Code
        10. Known Uses
        11. Related Patterns
      4. Object Behavioral: Iterator
        1. Intent
        2. Also Known As
        3. Motivation
        4. Applicability
        5. Structure
        6. Participants
        7. Collaborations
        8. Consequences
        9. Implementation
        10. Sample Code
        11. Known Uses
        12. Related Patterns
      5. Object Behavioral: Mediator
        1. Intent
        2. Motivation
        3. Applicability
        4. Structure
        5. Participants
        6. Collaborations
        7. Consequences
        8. Implementation
        9. Sample Code
        10. Known Uses
        11. Related Patterns
      6. Object Behavioral: Memento
        1. Intent
        2. Also Known As
        3. Motivation
        4. Applicability
        5. Structure
        6. Participants
        7. Collaborations
        8. Consequences
        9. Implementation
        10. Sample Code
        11. Known Uses
        12. Related Patterns
      7. Object Behavioral: Observer
        1. Intent
        2. Also Known As
        3. Motivation
        4. Applicability
        5. Structure
        6. Participants
        7. Collaborations
        8. Consequences
        9. Implementation
        10. Sample Code
        11. Known Uses
        12. Related Patterns
      8. Object Behavioral: State
        1. Intent
        2. Also Known As
        3. Motivation
        4. Applicability
        5. Structure
        6. Participants
        7. Collaborations
        8. Consequences
        9. Implementation
        10. Sample Code
        11. Known Uses
        12. Related Patterns
      9. Object Behavioral: Strategy
        1. Intent
        2. Also Known As
        3. Motivation
        4. Applicability
        5. Structure
        6. Participants
        7. Collaborations
        8. Consequences
        9. Implementation
        10. Sample Code
        11. Known Uses
        12. Related Patterns
      10. Class Behavioral: Template Method
        1. Intent
        2. Motivation
        3. Applicability
        4. Structure
        5. Participants
        6. Collaborations
        7. Consequences
        8. Implementation
        9. Sample Code
        10. Known Uses
        11. Related Patterns
      11. Object Behavioral: Visitor
        1. Intent
        2. Motivation
        3. Applicability
        4. Structure
        5. Participants
        6. Collaborations
        7. Consequences
        8. Implementation
        9. Sample Code
        10. Known Uses
        11. Related Patterns
        12. Discussion of Behavioral Patterns
          1. Encapsulating Variation
          2. Objects as Arguments
          3. Should Communication be Encapsulated or Distributed?
          4. Decoupling Senders and Receivers
          5. Summary
    4. 6. Conclusion
      1. 6.1. What to Expect from Design Patterns
        1. A Common Design Vocabulary
        2. A Documentation and Learning Aid
        3. An Adjunct to Existing Methods
        4. A Target for Refactoring
      2. 6.2. A Brief History
      3. 6.3. The Pattern Community
        1. Alexander’s Pattern Languages
        2. Patterns in Software
      4. 6.4. An Invitation
      5. 6.5. A Parting Thought
  10. A. Glossary
  11. B. Guide to Notation
    1. B.1. Class Diagram
    2. B.2. Object Diagram
    3. B.3. Interaction Diagram
  12. C. Foundation Classes
    1. C.1. List
      1. Construction, Destruction, Initialization, and Assignment
      2. Accessing
      3. Adding
      4. Removing
      5. Stack Interface
    2. C.2. Iterator
    3. C.3. ListIterator
    4. C.4. Point
    5. C.5. Rect
  13. Bibliography
  14. Inside Front Cover
    1. Creational Patterns
    2. Structural Patterns
    3. Behavioral Patterns
  15. Inside Back Cover