0% found this document useful (0 votes)
131 views

Tutorial - Common Design Patterns in C# 4 PDF

Uploaded by

dippune
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
131 views

Tutorial - Common Design Patterns in C# 4 PDF

Uploaded by

dippune
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1/30/2015 Tutorial: Common Design Patterns in C# 4.

0 ­ Home

CodePlex Project Hosting for Open Source Software Register Sign In Search all projects

Tutorial: Common Design Patterns in C# 4.0


HOME SOURCE CODE DOWNLOADS DOCUMENTATION DISCUSSIONS ISSUES PEOPLE LICENSE

Page Info Change History ﴾all pages﴿ Follow ﴾191﴿ Subscribe

Search Wiki & Documentation


Tutorial: Common Design Patterns in C# 4.0
There is no recommended release for this project.
Design Patterns provide standardized and efficient solutions to software design and programming problems that
are re‐usable in your code. Software Architects and developers use them to build high quality robust
applications. ACTIVITY

However, you have to take care to select the right pattern for the right problem. If you need to modify the initial
PAGE VIEWS VISITS DOWNLOADS
pattern too much, this may indicate that it is not adapted to your needs and may in the worst case lead to
unmaintainable, complex and inefficient code. The opposite of what you intend when using Design Patterns !! 0 0 26

You may also create your own custom Design Patterns. Whenever you come up with a certain solution that is Days: 7 30 All Details
reusable in a vast majority of your projects, you may decide to abstract a design pattern out of it. Then you may
create your own library of patterns and share them within your whole company, thus creating standards and
ameliorating maintainability.

I am going to show you how to use the well known Gang of Four ﴾GoF﴿ Design Patterns in C# 4.0 code. Those
patterns will work well in any project that uses C# but especially in WPF, WCF, WinForms, ASP.NET projects.

The GoF Design Patterns are divided into 3 categories : Creational Patterns, Structural Patterns and Behavioral
Patterns. I am going to explain each GoF Design Pattern in detail and will show you examples of how to write
good C# 4.0 code that implement those patterns.

Creational Patterns

Abstract Factory Pattern: Create instances of classes belonging to different families


Builder Pattern: Separate representation and object construction
Factory Method Pattern: Create instances of derived classes
Prototype Pattern: Clone or copy initialized instances
Singleton Pattern: Class with only one single possible instance

Structural Patterns

Adapter Pattern: Match interfaces of classes with different interfaces


Bridge Pattern:: Separate implementation and object interfaces
Composite: Simple and composite objects tree
Decorator: Dynamically add responsibilities to objects
Facade: Class that represents subclasses and subsystems
Flyweight: Minimize memory usage by sharing as much data as possible with similar objects
Proxy: Object that represents another object

Behavioral Patterns

Chain of Responsibility: Pass requests between command and processing objects within a chain of
objects
Command: Encapsulate a method call as an object containing all necessary information
Interpreter: Include language elements and evaluate sentences in a given language
Iterator: Give sequential access to elements in a collection
Mediator: Encapsulates and simplifies communication between objects
Memento: Undo modifications and restore an object to its initial state
Observer: Notify dependent objects of state changes
State: Change object behavior depending on its state
Strategy: Encapsulate algorithms within a class and make them interchangeable
Template Method: Define an algorithm skeleton and delegate algorithm steps to subclasses so that they
may be overridden
Visitor: Add new operations to classes without modifying them

https://csharpdesignpatterns.codeplex.com/ 1/2
1/30/2015 Tutorial: Common Design Patterns in C# 4.0 ­ Home

There are also many other types of patterns such as: Parallel Patterns, SOA Patterns, Enterprise Architecture
Patterns, etc… So if you work in the respective area don’t hesitate to look up patterns that may help you to be
more efficient and build better applications.

Find further explications and a more detailed step‐by‐step guide on my Blog:


http://www.jasondeoliveira.com
Last edited Apr 24, 2014 at 10:01 AM by JasonOliveira, version 18

© 2006‐2015 Microsoft Get Help Privacy Statement Terms of Use Code of Conduct Advertise With Us Version 12.4.2014.20959

https://csharpdesignpatterns.codeplex.com/ 2/2

You might also like