Tags » Design Patterns

SOLID principles in .NET revisited part 3: the Open-Closed principle


In the previous post we looked at the letter ‘S’ in SOLID, i.e. the single responsibility principle. We identified the reasons for change in the OnDemandAgentService class and broke out 3 of them into separate classes. 1,169 more words


Restrict Object Instantiation via the Singleton Pattern in Sitecore

This post is a continuation of a series of posts I’m putting together around using design patterns in Sitecore, and will show a “proof of concept” around using the… 972 more words


.NET Design Patterns – A Fresh Look

Note: This post is also available in .NET Curry Magazine 16th Issue and Site.

.NET Design Patterns…. yes, there are several books and resources written on this topic. 3,990 more words

Design Patterns

Decorator pattern

Decorator design pattern allows to attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.


public void DecoratorTest()
    IComponent concreteComponent = new ConcreteComponent1();
    IComponent concreteDecorator1 = new ComponentDecorator1(concreteComponent);
    IComponent concreteDecorator2 = new ComponentDecorator2(concreteDecorator1);

    Assert.AreEqual(concreteDecorator1.Operation(), "ComponentDecorator1 + " + concreteComponent.Operation());
    Assert.AreEqual(concreteDecorator2.Operation(), "ComponentDecorator2 + " + ((ComponentDecorator2)concreteDecorator2).ExtendedOperation() + " + ComponentDecorator1 + " + concreteComponent.Operation());

184 more words

SOLID principles in .NET revisited part 2: Single Responsibility Principle


In the previous post we set the tone for the recycled series on SOLID. We also presented a piece of code to be improved. There are several issues with this code and we’ll try to improve it step by step as we go through the principles behind SOLID. 1,052 more words


Command design pattern

Command design pattern encapsulates request as an object thereby allowing parameterize other objects with different request, log and queue requests, and support undoable operations.

Test client:

391 more words

Being Lazy

I’ve always had the feeling that I’m a lazy person. I mean, not the laziest one out of all of my friends, but certainly not the hardest working either. 633 more words