Category Archive: Design Patterns

Feb 02 2014

Design Patterns Series – Learn Design Patterns quickly

What is a design pattern? From Wikipedia: In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. I think that learning design patterns and the underline Object Oriented Design principles is really important. However, it is really difficult and time consuming. It requires …

Continue reading »

Permanent link to this article: https://www.productivecsharp.com/2014/02/design-patterns-series-learn-design-patterns-quickly/

Feb 10 2013

The Iterator Pattern in .NET

The Iterator Pattern provides a way to access the elements of an aggregate object (collection) sequentially without exposing its underling representation. The ultimate goal of the pattern is to decouple the client from the implementation of the collection that always remains well encapsulated. This is definitely my favourite pattern in particular for how it is supported by …

Continue reading »

Permanent link to this article: https://www.productivecsharp.com/2013/02/the-iterator-pattern-html/

Jan 27 2013

The Template Method Pattern in .NET

The Template Method Pattern defines the skeleton of an algorithm in a method, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm’s structure. This pattern is typically used to implement frameworks as an important technique for code reuse. It allows to encapsulate pieces of algorithms …

Continue reading »

Permanent link to this article: https://www.productivecsharp.com/2013/01/the-template-method-pattern-in-net/

Nov 18 2012

The Facade Pattern in .NET

The Facade Pattern provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher level interface that makes the subsystem easier to use. The Facade Pattern is the simplest of the patterns and it is something that many developers probably used a lot in the past without even knowing that …

Continue reading »

Permanent link to this article: https://www.productivecsharp.com/2012/11/the-facade-pattern-in-net/

Nov 18 2012

The Adapter Pattern in .NET

The Adapter Pattern converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces. The pattern is also called “Wrapper” because it is usually implemented using the technique of wrapping objects (object composition). There are different situation when the pattern can be …

Continue reading »

Permanent link to this article: https://www.productivecsharp.com/2012/11/the-adapter-pattern-in-net/

Nov 03 2012

The Command Pattern in .NET

The Command Pattern encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations. The formal definition of the pattern is quite general and it shows how the pattern is versatile and can be used in many scenarios but the real important thing however is the …

Continue reading »

Permanent link to this article: https://www.productivecsharp.com/2012/11/the-command-pattern-in-net/

Sep 22 2012

The Singleton Pattern in .NET – If you can avoid it

The Singleton Pattern ensures a class has only one instance, and provides a global point of access to it. NOTE: This pattern is now considered by many (included the creators) an anti pattern and it is presented only for completeness! Read why. A Singleton is a class that manages a single instance of itself and prevent …

Continue reading »

Permanent link to this article: https://www.productivecsharp.com/2012/09/the-singleton-pattern-in-net-if-you-can-avoid-it/

Sep 20 2012

Abstract Factory Pattern in .NET

The Abstract Factory Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes. In a previous post, I have shown that in the Factory Method Pattern the object creation is done through inheritance. Instead, the Abstract Factory use object composition. Object creation is implemented in methods exposed in …

Continue reading »

Permanent link to this article: https://www.productivecsharp.com/2012/09/abstract-factory-pattern-in-net/

Sep 16 2012

Factory Method Pattern in .NET

There is a little bit of confusion around this pattern because Factory Method can be implemented in many different ways but I want to stick with the original definition of the pattern. The Factory Method Pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a …

Continue reading »

Permanent link to this article: https://www.productivecsharp.com/2012/09/factory-method-pattern-in-net/

Sep 13 2012

Decorator Pattern – Streams in .NET

The Decorator Pattern allows to attach additional responsibilities to an object dynamically. It is an alternative to subclassing for extending behaviour. Instead of creating a silly example of usage I decided to rely on one of the best example of implementation that is already available in the .NET Framework: the Streams. The following class diagram is …

Continue reading »

Permanent link to this article: https://www.productivecsharp.com/2012/09/decorator-pattern-streams-in-net/

Older posts «