Saturday September 24th

Friday September 23rd

Thursday September 22nd

.NET Design Patterns The decorator pattern. Adding behavior at runtime

Welcome to the first of many articles on design patterns on This article explains The decorator pattern. Adding new behavior to your existing objects at run time.


Why have you closed the comment feature in your blog?

Decorators (well, classes in general, but especially decorators) should not have init methods (SetArticle) but take the decorated instance in the constructor.

Thanks for reading. If you look at my blog you will notice that I have both a setter method as well as an overloaded constructor.

As a matter of fact, the example code uses the overloaded constructor for the Tweetable class.

From my blog..
public Tweetable(){ }

/// <summary>
/// A emthod to provide the article to be extended.
/// </summary>
/// <param name="article">The article in which to add new behavior</param>
public Tweetable(Article article)
_article = article;

I included both just to show that you have options.

As far as the comments are concerned, I found that the spam is too much trouble.

Thanks again for reading. I'll remove the setter method from the example since it's not being used. This will avoid confusion.

Thanks again.


great. you just got kicked. You can read more about init methods here:

Commenting on Stories is limited for now and will open up to those recommended by the community. Learn how
Loading DotNetKicks...
brought to you by the Kicks Network