A Curious Mind
#tastic

September 2006 Entries

Null Object Pattern

"Provide an object as a surrogate for the lack of an object of a given type. The Null Object provides intelligent do nothing behavior, hiding the details from its collaborators."public class Person { private string _name; public Person(string name) { this.Name = name; } public string Name { get { return this._name; } set { this._name = value; } } // Null Object Pattern Implementation private static Person _nullInstance = new Person(""); public static Person NullInstance { get { return _nullInstance;...

The Decorator Pattern

Intent: Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.* This post is another love story about software patterns. I love programming to interfaces. Today I am going to talk about one of my favorite benefits of doing this, leveraging the Decorator pattern. What follows is a simple class getting refactored/developed to use the Decorator pattern. Take for example this simple class:public class Repository...