Cover image for C# 3.0 Design Patterns

Book description

If you want to speed up the development of your .NET applications, you're ready for C# design patterns -- elegant, accepted and proven ways to tackle common programming problems. This practical guide offers you a clear introduction to the classic object-oriented design patterns, and explains how to use the latest features of C# 3.0 to code them. C# Design Patterns draws on new C# 3.0 language and .NET 3.5 framework features to implement the 23 foundational patterns known to working developers. You get plenty of case studies that reveal how each pattern is used in practice, and an insightful comparison of patterns and where they would be best used or combined. This well-organized and illustrated book includes:

  • An explanation of design patterns and why they're used, with tables and guidelines to help you choose one pattern over another

  • Illustrated coverage of each classic Creational, Structural, and Behavioral design pattern, including its representation in UML and the roles of its various players

  • C# 3.0 features introduced by example and summarized in sidebars for easy reference

  • Examples of each pattern at work in a real .NET 3.5 program available for download from O'Reilly and the author's companion web site

  • Quizzes and exercises to test your understanding of the material.

With C# 3.0 Design Patterns, you learn to make code correct, extensible and efficient to save time up front and eliminate problems later. If your business relies on efficient application development and quality code, you need C# Design Patterns.

Table of Contents

  1. C# 3.0 Design Patterns
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Foreword
    4. Preface
      1. Why I Wrote This Book
      2. Who This Book Is For
      3. What You Need to Know
      4. How This Book Is Organized
      5. What You Need to Use This Book
      6. Finding What You Need
      7. Conventions Used in This Book
      8. Using Code Examples
      9. Comments and Questions
      10. Safari® Books Online
      11. Acknowledgments
    5. 1. C# Meets Design Patterns
      1. About Patterns
      2. About UML
      3. About C# 3.0
      4. About the Examples
    6. 2. Structural Patterns: Decorator, Proxy, and Bridge
      1. Decorator Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example: Photo Decorator
        6. Use
        7. Exercises
      2. Proxy Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example: SpaceBook
        6. Use
        7. Exercises
      3. Bridge Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
      4. Example: OpenBook
        1. Use
        2. Exercise
      5. Pattern Comparison
    7. 3. Structural Patterns: Composite and Flyweight
      1. Composite Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
      2. Example: Photo Library
        1. Use
        2. Exercises
      3. Flyweight Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example: Photo Group
        6. Use
      4. Exercises
      5. Pattern Comparison
    8. 4. Structural Patterns: Adapter and Façade
      1. Adapter Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Two-Way Adapters
        6. Example: The Seabird
        7. Pluggable Adapters
        8. Example: CoolBook
        9. Use
        10. Exercises
      2. Façade Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Façade Alternatives
        6. Example: Novice Photo Library
        7. Use
        8. Exercises
      3. Pattern Comparison
    9. 5. Creational Patterns: Prototype, Factory Method, and Singleton
      1. Prototype Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example: Photo Archive
        6. Use
        7. Exercises
      2. Factory Method Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation and Example: Avocado Sourcing
        5. Use
        6. Exercises
      3. Singleton Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example: Singleton Façade
        6. Use
        7. Exercises
      4. Pattern Comparison
    10. 6. Creational Patterns: Abstract Factory and Builder
      1. Abstract Factory Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation and Example: Gucci and Poochy
        5. Use
        6. Exercises
      2. Builder Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example
        6. Use
        7. Exercises
      3. Pattern Comparison
    11. 7. Behavioral Patterns: Strategy, State, and Template Method
      1. Strategy Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example: Sorting Animator
        6. Use
        7. Exercises
      2. State Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example: RPC Game
        6. Use
        7. Exercises
      3. Template Method Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example
        6. Use
        7. Exercises
      4. Pattern Comparison
        1. Pattern Comparison
    12. 8. Behavioral Patterns: Chain of Responsibility and Command
      1. Chain of Responsibility Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example: Trusty Bank
        6. Use
        7. Exercises
      2. Command Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
          1. Multireceiver commands
        5. Example: Menu Handler
        6. Use
        7. Exercises
      3. Pattern Comparison
    13. 9. Behavioral Patterns: Iterator, Mediator, and Observer
      1. Iterator Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example: Family Tree
        6. Use
        7. Exercises
      2. Mediator Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example: Chat Room
        6. Use
        7. Exercises
      3. Observer Pattern
        1. Role
        2. Illustration
        3. Design
          1. Push and pull models
        4. Implementation
        5. Example: Blogs
        6. Use
        7. Exercises
      4. Pattern Discussion and Comparison
          1. Language Support for the Iterator Pattern
          2. Mediator and Observer Pattern Comparison
    14. 10. Behavioral Patterns: Visitor, Interpreter, and Memento
      1. Visitor Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example: Course Statistics
        6. Use
        7. Exercises
      2. Interpreter Pattern
        1. Illustration
          1. Grammars
        2. Design
          1. Parsing
        3. Implementation
        4. Example: Mirrors
          1. Efficiency
        5. Use
        6. Exercises
      3. Memento Pattern
        1. Role
        2. Illustration
        3. Design
        4. Implementation
        5. Example: TicTacToe
        6. Use
        7. Exercise
      4. Pattern Comparison
    15. 11. The Future of Design Patterns
      1. Summary of Patterns
        1. Exercises
      2. A Future for Design Patterns
      3. Concluding Remarks
    16. A. Appendix
      1. Pluggable Adapter Pattern Example Code—CoolBook
      2. Prototype Pattern Example Code—Photo Archive
      3. Iterator Pattern Example Code—Family Tree
      4. Observer Pattern Example Code—Blogs
      5. Visitor Pattern Theory Code—Reflection
      6. Interpreter Pattern Example Code—Course Rules
      7. Interpreter Pattern Example Code—Mirrors
    17. Bibliography
    18. About the Author
    19. Colophon
    20. SPECIAL OFFER: Upgrade this ebook with O’Reilly