Design Patterns in C# / Edition 1

Paperback (Print)
Buy New
Buy New from BN.com
$52.96
Used and New from Other Sellers
Used and New from Other Sellers
from $35.96
Usually ships in 1-2 business days
(Save 44%)
Other sellers (Paperback)
  • All (8) from $35.96   
  • New (5) from $51.26   
  • Used (3) from $35.96   

Overview

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

Read More Show Less

Editorial Reviews

From Barnes & Noble
The Barnes & Noble Review
Are you a C# programmer who wants to move up, earn more, become slightly more indispensable? Master software design. For years, that’s meant learning patterns -- beginning with the 23 patterns in the classic “Gang of Four” book. Now, you can learn these patterns directly in C#, using C# and .NET examples -- not warmed-over C++ or Java code.

Stephen Metsker takes a thoroughly hands-on approach. Every new pattern is accompanied with challenges that put it to work. For example: explaining the trade-offs of certain design choices, rewriting existing code, completing partly written code, or finishing incomplete UML class diagrams. (Rusty on UML? Metsker offers a handy refresher.)

Slightly varying from the GoF, Metsker has organized his patterns into five categories: interface, responsibility, construction, operation, and extension. But those who’ve come across GoF will find all the familiar faces: façade, builder, prototype, singleton, adapter, bridge, proxy, abstract factory, state, visitor, and so forth.

Metsker carefully explains why each pattern is necessary, why it does something important that goes beyond the features built into C#. Wherever C# features require adjustment to the original Design Patterns approach, Metsker clearly shows how and why. (For example, GoF focused heavily on abstract classes but didn’t discuss interfaces, which were absent in their preferred languages, C++ and Smalltalk.)

Patterns represent the distilled wisdom of the entire global software engineering community. By bringing that wisdom to C#, Metsker’s done a great service for millions of serious .NET developers. Bill Camarda

Bill Camarda is a consultant, writer, and web/multimedia content developer. His 15 books include Special Edition Using Word 2003 and Upgrading & Fixing Networks for Dummies, Second Edition.

Read More Show Less

Product Details

  • ISBN-13: 9780321718938
  • Publisher: Addison-Wesley
  • Publication date: 11/18/2011
  • Edition number: 1
  • Pages: 480
  • Product dimensions: 7.10 (w) x 9.20 (h) x 1.10 (d)

Meet 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.
Read More Show Less

Read an Excerpt

Preface

It seems a long time ago (two years!) that I received the initial encouragement for this book from Paul Becker, an editor at the time with Addison-Wesley. I remain grateful to Paul for his help, and to his successor, John Neidhart, who took over as editor when Paul left. I am also grateful for the encouragement of John Vlissides, who is the Patterns Series editor and who has been a supporter of mine for all three of my books.

John Vlissides is also, of course, one of the four authors of Design Patterns. John and his co-authors—Erich Gamma, Ralph Johnson, and Richard Helm—produced the work that not only established a list of important patterns that every developer should know, but also set a standard for quality and clarity that I have aspired to attain in my own writing.

In addition to relying heavily on Design Patterns, I have benefited from the use of many other books; see Bibliography on 439. In particular, I have depended on The Unified Modeling Language User Guide Booch for its clear explanations of UML. For concise and accurate help on C# topics, I have consulted C# Essentials Albahari almost daily. I have also repeatedly drawn on the insights of C# and the .NET Platform Troelsen, and for realistic fireworks examples, I have consistently consulted The Chemistry of Fireworks Russell.

As the present book began to take shape, several excellent reviewers helped to guide its progress. I would like to thank Bill Wake for his early reviews. Bill never ceases to amaze me in his ability to catch the subtlest errors while simultaneously providing advice on overall direction, content, and style. I would also liketo thank Steve Berczuk and Neil Harrison. In particular, they hit on the same key point that the book needed more introductory material for each pattern. Their comments drove me to rework the entire book. It is much stronger now because of their advice.

With the help of editors and reviewers, I was able to write this book; but, the text of a book is just the beginning. I would like to thank Nick Radhuber and the entire production staff for their hard work and dedication. Their work renders text into what is to this day its most usable form—a book!


Steve Metsker (
Steve.Metsker@acm.org)

Read More Show Less

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.

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 4 Customer Reviews
  • Anonymous

    Posted July 24, 2007

    Good Reference

    I thoroughly enjoyed this book. I am reading this book as an experienced C# developer and having read other patterns and other design books previously. The book is not for the beginning developer unless they are wanting to become a more accomplished developer/designer. A beginning developer will have to work some to understand the details of the book. This book is not an advanced one either it exists as a bridge between the two. It¿s my intent to keep this book on my desktop especially during the design phase of new implementations. The book is designed well to be a desktop reference. The segregation of the Challenges and answers makes it a cumbersome read but a good reference.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted August 1, 2004

    Only for beginners

    This book is an intro to patterns. I bought it to serve as a reference for C# examples to the Gang of four patterns book. If you don't know patterns but know c# then buy it to learn, but for anyone that knows patterns and why to use them don't waste your time.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted May 31, 2004

    Bootstrap your fluency in C#

    C# is still a relatively new language. Certainly younger than Java or C++, which are the 2 most common OO languages. So chances are, some people coming to this book are still clumsy in C#. But I think it is also reasonable to say that if you are contemplating ANY book on design patterns, that you are fluent in at least one language. Strictly, a purist might say that design patterns do not need to refer to a specific language. They are a level above code. But pragmatically, to understand them, it helps to instantiate examples in a language. All this means that the book is good for an experienced developer who is still new to C#. You understand why design patterns are important. You can use the book to bootstrap your fluency in C# by studying the examples and tackling the supplied problems. If you are indeed an experienced developer in another language, you might find the narrative more appealing than that in a Dummies-type book. The level of discussion that Metsker supplies is more advanced and challenging. More interesting. Hey! He also gives answers to the problems.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted May 4, 2004

    Excellent C# and Design Patterns Guide

    This book will serve you well whether you know Patterns and are trying to learn C# or know C# and are trying to understand Patterns better. It is not a replacement for the Design Patterns Book or a good C+ reference, but it is an excellent companion for both.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 4 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)