Design Patterns in C#

Book description

Steven John Metsker explains how to use C# as an object-oriented language, using design patterns to create clean code while taking advantage of the extensive Microsoft(R) .NET Framework Class Libraries.

For all 23 classic "Gang of Four" design patterns, Metsker offers detailed code examples utilizing C# and the .NET Framework--as well as programming exercises crafted to help you rapidly build expertise. His exercises and explanations make extensive use of the Unified Modeling Language, helping you build your skills in this standard notation.

Design patterns covered include:

  • Interfaces: Adapter, Facade, Composite, and Bridge

  • Responsibility: Singleton, Observer, Mediator, Proxy, Chain of Responsibility, and Flyweight

  • Construction: Builder, Factory Method, Abstract Factory, Prototype, and Memento

  • Extensions: Decorator, Iterator, and Visitor

  • If you've already used design patterns in other languages, Design Patterns in C# will deepen your understanding, build your confidence, and help you apply them to any C# project. If you're a Microsoft programmer who's new to design patterns, this book will be an ideal practical introduction.

    www.awprofessional.com/patterns/

    ADDISON-WESLEY PROFESSIONAL

    Pearson Education

    ISBN: 0-321-12697-1

    Table of contents

    1. Copyright
      1. Dedication
    2. The Software Patterns Series
    3. Preface
    4. 1. Introduction
      1. Why Patterns?
      2. Why Design Patterns?
      3. Why C#?
      4. UML
      5. Challenges
      6. The Organization of this Book
      7. Welcome to Oozinoz!
      8. Summary
    5. 1. Interface Patterns
      1. 2. Introducing Interfaces
        1. Interfaces and Abstract Classes
        2. Interfaces and Delegates
        3. Interfaces and Properties
        4. Interface Details
        5. Summary
        6. Beyond Ordinary Interfaces
      2. 3. Adapter
        1. Adapting to an Interface
        2. Class and Object Adapters
        3. Adapting Data in .NET
        4. Summary
      3. 4. Facade
        1. An Ordinary Facade
        2. Refactoring to FACADE
        3. Facades, Utilities, and Demos
        4. Summary
      4. 5. Composite
        1. An Ordinary Composite
        2. Recursive Behavior in Composites
        3. Composites, Trees, and Cycles
        4. Composites with Cycles
        5. Consequences of Cycles
        6. Summary
      5. 6. Bridge
        1. An Ordinary Abstraction
        2. From Abstraction to Bridge
        3. Drivers as Bridges
        4. Database Drivers
        5. Summary
    6. 2. Responsibility Patterns
      1. 7. Introducing Responsibility
        1. Ordinary Responsibility
        2. Controlling Responsibility with Accessibility
        3. Summary
        4. Beyond Ordinary Responsibility
      2. 8. Singleton
        1. Singleton Mechanics
        2. Singletons and Threads
        3. Recognizing SINGLETON
        4. Summary
      3. 9. Observer
        1. C# Support for Observer
        2. Delegate Mechanics
        3. A Classic Example—OBSERVER in GUIs
        4. Model/View/Controller
        5. Layering
        6. Summary
      4. 10. Mediator
        1. A Classic Example—GUI Mediators
        2. Relational Integrity Mediators
        3. Summary
      5. 11. Proxy
        1. A Simple Proxy
        2. A Data Proxy
        3. Remote Proxies
        4. Summary
      6. 12. Chain of Responsibility
        1. An Ordinary CHAIN OF RESPONSIBILITY
        2. Refactoring to CHAIN OF RESPONSIBILITY
        3. Anchoring a Chain
        4. CHAIN OF RESPONSIBILITY without Composite
        5. Summary
      7. 13. Flyweight
        1. Immutability
        2. Extracting the Immutable Part of a Flyweight
        3. Sharing Flyweights
        4. Summary
    7. 3. Construction Patterns
      1. 14. Introducing Construction
        1. A Few Construction Challenges
        2. Summary
        3. Beyond Ordinary Construction
      2. 15. Builder
        1. An Ordinary Builder
        2. Building under Constraints
        3. A Forgiving Builder
        4. Summary
      3. 16. Factory Method
        1. A Classic Example—Enumerators
        2. Recognizing FACTORY METHOD
        3. Taking Control of Which Class to Instantiate
        4. FACTORY METHOD in Parallel Hierarchies
        5. Summary
      4. 17. Abstract Factory
        1. A Classic Example—GUI Kits
        2. Abstract Factories and Factory Method
        3. Namespaces and Abstract Factories
        4. Summary
      5. 18. Prototype
        1. Prototypes as Factories
        2. Prototyping with Clones
        3. Summary
      6. 19. Memento
        1. A Classic Example—Using Memento for Undo
        2. Memento Durability
        3. Persisting Mementos across Sessions
        4. Summary
    8. 4. Operation Patterns
      1. 20. Introducing Operations
        1. Operations and Methods
        2. Signatures
        3. Delegates
        4. Exceptions
        5. Algorithms and Polymorphism
        6. Summary
        7. Beyond Ordinary Operations
      2. 21. Template Method
        1. A Classic Example—Sorting
        2. Completing an Algorithm
        3. TEMPLATE METHOD Hooks
        4. Refactoring to TEMPLATE METHOD
        5. Summary
      3. 22. State
        1. Modeling States
        2. Refactoring to STATE
        3. Making States Constant
        4. Summary
      4. 23. Strategy
        1. Modeling Strategies
        2. Refactoring to STRATEGY
        3. Comparing STRATEGY and STATE
        4. Comparing STRATEGY and TEMPLATE METHOD
        5. Summary
      5. 24. Command
        1. A Classic Example—Menu Commands
        2. Using COMMAND to Supply a Service
        3. COMMAND Hooks
        4. COMMAND in Relation to Other Patterns
        5. Summary
      6. 25. Interpreter
        1. An INTERPRETER Example
        2. Interpreters, Languages, and Parsers
        3. Summary
    9. 5. Extension Patterns
      1. 26. Introducing Extensions
        1. Principles of OO Design
        2. The Liskov Substitution Principle
        3. The Law of Demeter
        4. Removing Code Smells
        5. Beyond Ordinary Extensions
        6. Summary
      2. 27. Decorator
        1. A Classic Example—Streams
        2. Function Wrappers
        3. Decorator in GUIs
        4. Decorator in Relation to Other Patterns
        5. Summary
      3. 28. Iterator
        1. Ordinary Iteration
        2. Thread-Safe Iteration
        3. Iterating over a Composite
          1. Adding Depth to a Composite Enumerator
          2. Enumerating Leaves
        4. Summary
      4. 29. Visitor
        1. Visitor Mechanics
        2. An Ordinary VISITOR
        3. VISITOR Cycles
        4. VISITOR Controversy
        5. Summary
      5. A. Directions
        1. Get the Most Out of This Book
        2. Understand the Classics
        3. Weave Patterns into Your Code
        4. Keep Learning
      6. B. Solutions
        1. Introducing Interfaces
        2. Adapter
        3. Facade
        4. Composite
        5. Bridge
        6. Introducing Responsibility
        7. Singleton
        8. Observer
        9. Mediator
        10. Proxy
        11. Chain of Responsibility
        12. Flyweight
        13. Introducing Construction
        14. Builder
        15. Factory Method
        16. Abstract Factory
        17. Prototype
        18. Memento
        19. Introducing Operations
        20. Template Method
        21. State
        22. Strategy
        23. Command
        24. Interpreter
        25. Introducing Extensions
        26. Decorator
        27. Iterator
        28. Visitor
      7. C. Oozinoz Source
        1. Acquiring and Using the Source
        2. Building the Oozinoz Code
        3. Helping the Oozinoz Code Find Files
        4. Testing the Code with NUnit
        5. Finding Files Yourself
        6. Summary
      8. D. UML at a Glance
        1. Classes
        2. Class Relationships
        3. Interfaces
        4. Delegates and Events
        5. Objects
        6. States
      9. Glossary
      10. Bibliography

    Product information

    • Title: Design Patterns in C#
    • Author(s):
    • Release date: April 2004
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 9780321126979