Category Archive: OOD

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/

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/

Sep 10 2012

Observer Pattern in .NET

Observer Pattern? Sounds complicated? Reality is that if you are a .NET developer you already know it and it is very simple. The observer pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. But but but I can do this with events! Oh …

Continue reading »

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