| help | account  


Design Patterns in C#
View Larger Image
Steven John Metsker
Addison-Wesley, Hardcover, Published April 2004, 456 pages, ISBN 0321126971
List Price: $59.99
Our Price: $46.50
You Save: $13.49 (22% Off)


FREE Shipping on Orders over $40!*
Availability: Out-Of-Stock
Read an excerpt:
Chapter 3: Adapter

     

Excerpt provided courtesy of Addison-Wesley Professional. Copyright © Addison-Wesley. Written permission from the publisher is required for any use of this material.

Customer Reviews: 5     Average Customer Rating:

Write a Review and tell the world about this title!

People who purchase this book frequently purchase:

Books on similar topics, in best-seller order:Books from the same publisher, in best-seller order:

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.

 

Table of Contents

Preface.


1. Introduction.

Why Patterns? Why Design Patterns? Why C#? UML. Challenges. The Organization of this Book. Welcome to Oozinoz! Summary.

I. INTERFACE PATTERNS.

2. Introducing Interfaces.

Interfaces and Abstract Classes. Interfaces and Delegates. Interfaces and Properties. Interface Details. Summary. Beyond Ordinary Interfaces.

3. Adapter.

Adapting to an Interface. Class and Object Adapters. Adapting Data in .NET. Summary.

4. Facade.

An Ordinary Facade. Refactoring to Facade. Facades, Utilities, and Demos. Summary.

5. Composite.

An Ordinary Composite. Recursive Behavior in Composites. Composites, Trees, and Cycles. Composites with Cycles. Consequences of Cycles. Summary.

6. Bridge.

An Ordinary Abstraction. From Abstraction to Bridge. Drivers as Bridges. Database Drivers. Summary.

II. RESPONSIBILITY PATTERNS.

7. Introducing Responsibility.

Ordinary Responsibility. Controlling Responsibility with Accessibility. Summary. Beyond Ordinary Responsibility.

8. Singleton.

Singleton Mechanics. Singletons and Threads. Recognizing Singleton. Summary.

9. Observer.

C# Support for Observer. Delegate Mechanics. A Classic Example—Observer in GUIs. Model/View/Controller. Layering. Summary.

10. Mediator.

A Classic Example—GUI Mediators. Relational Integrity Mediators. Summary.

11. Proxy.

A Simple Proxy. A Data Proxy. Remote Proxies. Summary.

12. Chain of Responsibility.

An Ordinary Chain of Responsibility. Refactoring to Chain of Responsibility. Anchoring a Chain. Chain of Responsibility without Composite. Summary.

13. Flyweight.

Immutability. Extracting the Immutable Part of a Flyweight. Sharing Flyweights. Summary.

III. CONSTRUCTION PATTERNS.

14. Introducing Construction.

A Few Construction Challenges. Summary. Beyond Ordinary Construction.

15. Builder.

An Ordinary Builder. Building under Constraints. A Forgiving Builder. Summary.

16. Factory Method.

A Classic Example—Enumerators. Recognizing Factory Method. Taking Control of Which Class to Instantiate. Factory Method in Parallel Hierarchies. Summary.

17. Abstract Factory.

A Classic Example—GUI Kits. Abstract Factories and Factory Method. Namespaces and Abstract Factories. Summary.

18. Prototype.

Prototypes as Factories. Prototyping with Clones. Summary.

19. Memento.

A Classic Example—Using Memento for Undo. Memento Durability. Persisting Mementos across Sessions. Summary.

IV. OPERATION PATTERNS.

20. INTRODUCING OPERATIONS.

Operations and Methods. Signatures. Delegates. Exceptions. Algorithms and Polymorphism. Summary. Beyond Ordinary Operations.

21. Template Method.

A Classic Example—Sorting. Completing an Algorithm. Template Method Hooks. Refactoring to Template Method. Summary.

22. State.

Modeling States. Refactoring to State. Making States Constant. Summary.

23. Strategy.

Modeling Strategies. Refactoring to Strategy. Comparing Strategy and State. Comparing Strategy and Template Method. Summary.

24. Command.

A Classic Example—Menu Commands. Using Command to Supply a Service. Command Hooks. Command in Relation to Other Patterns. Summary.

25. Interpreter.

An Interpreter Example. Interpreters, Languages, and Parsers. Summary.

V. EXTENSION PATTERNS.

26. Introducing Extensions.

Principles of OO Design. The Liskov Substitution Principle. The Law of Demeter. Removing Code Smells. Beyond Ordinary Extensions. Summary.

27. Decorator.

A Classic Example—Streams. Function Wrappers. Decorator in GUIs. Decorator in Relation to Other Patterns. Summary.

28. Iterator.

Ordinary Iteration. Thread-Safe Iteration. Iterating over a Composite. Summary.

29. Visitor.

Visitor Mechanics. An Ordinary Visitor. Visitor Cycles. Visitor Controversy. Summary.

Appendix A: Directions.

Get the Most Out of This Book. Understand the Classics. Weave Patterns into Your Code. Keep Learning.

Appendix B: Solutions.

Appendix C: Oozinoz Source.

Acquiring and Using the Source. Building the Oozinoz Code. Helping the Oozinoz Code Find Files. Testing the Code with NUnit. Finding Files Yourself. Summary.

Appendix D: UML at a Glance.

Classes. Class Relationships. Interfaces. Delegates and Events. Objects. States.

Glossary.

Bibliography.

Index.


About the Author

STEVEN JOHN METSKER has written extensively on design patterns, object-oriented programming, and software methodologies. Steve is a software consultant with CapTech Ventures, and a frequent speaker at OOPSLA conferences. His work has appeared in journals including Java Report, JOOP, Distributed Object Computing, and Object Magazine. Steve's Addison Wesley books include Design Patterns Java Workbook and Building Parsers in Java.


Customer Reviews

Customer Reviews: 5     Average Customer Rating:

Apr 15, 2006     Sri from Stony Brook
MUST HAVE BOOK.
Steve has done a great job in this book. The patterns are explained in great detail but to the point! As he mentions, if we solve the challenges, we can learn a lot about design patterns. He shows how the C# language details can be made of use in the design patterns. This book can be strongly recommended to any professional who wants to develop good C# systems.

Jan 23, 2006     A review from Boston, MA
Not a good introduction to Design Patterns...
If that is what you are looking for then check out Head First Design Patterns or Design Patterns: Elements of Reusable Object-Oriented Software. If you're looking for a C# guide on implementing some of the patterns defined in those books than this book is for you.

Mar 13, 2005     A review from Missouri
Do not buy this book - what a disappointment.
Come on. Let's be honest. Do not buy this book. Purchase "Head First Design Patterns" instead (published by O'Reilly - written by Eric Freeman, Elisabeth Freeman, Bert Bates and Kathy Sierra - and no, I am not one of them, nor do I work for O'Reilly). HFDP is an EXCELLENT, EXCELLENT book. Steven Metzger uses a fictitious company named "OozInOz" that makes fireworks. On page 59 he goes into detail about how an aerial shell has a core, inner shell casing, outer shell, star, lifting charge and fuse. WHO CARES! We all want to learn about writing design patterns - not about how a rocket consumes itself as it flies through the air. Steven Metzger's examples are vague and uninteresting. After a few paragraphs of confusing rocket prose, he gives you 10 lines of code. On page 65 he provides an explanation of a concept: "The ordinary way to implement an abstraction is to create a class hierarchy with an abstract class at the top that defines the abstract operations; each subclass in the hierarchy provides a different implementation of the set of abstract operations. However, this approach becomes insufficient when you need to subclass the hierararchy for some other reason." Huh? Then he provides some confusing examples of StarPressControllers and FuserControllers and MachineManagers related to building rockets, then provides incomplete UML diagrams and no code (you have to go to the appendix for that). Throughout the book you find yourself scratching your head regarding how toy rockets work (and wondering why we should care), rather than learning code and design patterns. The 4-page UML primer in Appendix D is woefully inadequate. Really - purchase "Head First Design Patterns" instead. Sure, it's based on Java, but surely we can all translate Java into C# - since they are so similar.

Nov 19, 2004     A review from NY
gr8 book for patterns hungry guys
This is a gr8 book if you want to get into design patterns. most of the books talk about patterns but dont give indepth code examples. But this one covers pattern's indept and the actual code implementing it

Sep 19, 2004     
Approachable version of the classic Design Patterns
Great book for anybody interested in software patterns. It is nice to have books like this directed at the C# audience.



Forgot your password?
FAQs
Shipping Options
Returns
Your Orders
Your Account