Design Patterns : Mediator Pattern

There are two reasons I thought I should be blogging about the Mediator Pattern. Firstly, I wanted to continue with the series of different design patterns and principles, filling out the missing pieces. Secondly, I would like to write a blog entry on configuring the Mediator and CQRS on a Web Api sometime soon. But … Continue reading Design Patterns : Mediator Pattern

Gof : Observer Pattern

This has been a long overdue. I had started with this series of byte sized tutorials on various patterns but never went ahead and completed the series. So here am continuing from where I left with the Observer Pattern. While working with applications, there would times you could have an object which would like to notify other … Continue reading Gof : Observer Pattern

GOF: Composite Pattern

Composite Pattern, in a way, literally takes of from where Decorator Pattern ends. One might be inclined to think of it as a specialized case of Decorator Pattern which composes one or more instances of similiar objects and manipulate them uniformly. This allows the client to work on a single entity or composition of entity … Continue reading GOF: Composite Pattern

Design Pattern : Memento Pattern

Memento Design Pattern allows to capture internal state of an object in an external object and restore it to the desired checkpoint when required, all the while being in compliance with encapsulation. The Memento Design Pattern comprises of 3 actor classes. Originator : The class which needs to have the ability to store its internal … Continue reading Design Pattern : Memento Pattern

Design Patterns : Bridge Pattern

The essence of Bridge Pattern lies in the fact that it not just decouples the abstraction from implementation, but in doing so, allows both to evolve independently. Let's consider the examples of smartphones. The underlying OS (for sake of example, let's assume its Android) improving every year. The Android has seen atleast 7 versions in … Continue reading Design Patterns : Bridge Pattern

Design Patterns : Prototype Pattern

Falling under Creational Patterns, Prototype Pattern aims in creating a clone of your object and is used in scenarios when creating a object is considered costly (may be the creation involves a long Database or Web Service Operation). The formal definition of the pattern is as follows.   Specify the kind of objects to create … Continue reading Design Patterns : Prototype Pattern

Design Patterns : Decorator Pattern

While Inheritance/Sub Classing seems to be most natural way of extending functionality, it might not be always the best option. Especially when you want to avoid subclassing as it might result in too many classes. Consider the following scenario. Your nearest Dominos has many varieties of Pizzas. On top of it, you could decorate each … Continue reading Design Patterns : Decorator Pattern

Design Patterns : State Pattern

State Pattern is share a lot of similarities with Strategy Pattern, but has its own fundamental differences as well. The State pattern allows to change the behavior of a method, depending on the state of an object, in other words it encapsulates the behavior dependent on the state (the What). This is different from the … Continue reading Design Patterns : State Pattern

Design Patterns : Null Object Pattern

Null Pattern is probably one of the most underestimated and often most ignored among the design Patterns., though it turns out to be one of the easiest to implement. The intend of the pattern is to ensure we won't end up with NullReference Exceptions, while avoiding the long list of repeated preconditions that checks of … Continue reading Design Patterns : Null Object Pattern

Design Patterns : Adapter Pattern

There is already a large amount of literature on the Internet which discusses Adapter Pattern. However, the purpose of article is to showcase the implementations of the Adapter Pattern, rather than discussing the application of the pattern. In this post, adapter class is implemented using 1. Inheritance 2. Dependency Injection 3. Generics Consider your old … Continue reading Design Patterns : Adapter Pattern