Does anyone know of any 'Decorator' pattern implementations in the .NET Framework?

Published 30 March 5 2:11 PM | William
I've been reading through the Head First Design Pattern book by O'Rielly (Here's the link) and for the most part, I'm getting it.  I've read through the GOF book but haven't found that reading through patterns books is something I'm grasping really quickly.  The more I read on patterns, the more I realize that I can't seem to learn them in a linear fashion.  I make no progress for a while, sometimes even moving backward, then boom, I get it, then it repeats itself.

Anyway, I was working through the Decorator example (if you don't have the book, they reference the Java.IO library as an example of a real world implementation of a decorator patter) and while I have used the Java IO Libraries, I'm having trouble coming up with a concrete example of where I'd actually implement Decorator on my own.  Does anyone know of any places in the .NET Frameworkf where a decorator pattern was used and if so, would you be kind enough to point me in that direction?  Similiarly, if you have any examples of your own that you'd be willing to show me, I'd be much obliged!
Filed under:

Comments

# TrackBack said on March 30, 2005 12:49 PM:

# William said on March 30, 2005 3:59 PM:

The System.IO.Stream is a good example. Also, so is the XmlReader of the decorater pattern. I put up an implementation here: http://theagiledeveloper.com/archive/2005/03/30/DecoraterAndXInclude.aspx

# William said on March 30, 2005 4:02 PM:

Thanks Matt! I REALLY appreciate it!

# William said on March 30, 2005 4:28 PM:

A good one for your cuckoos is at: http://fox.wikis.com/wc.dll?Wiki~DecoratorPattern~SoftwareEng

yag

# William said on March 30, 2005 4:32 PM:

Yag - You rock brother! Thanks man!

# William said on March 30, 2005 4:52 PM:

Yeah, I was going to say the System.IO namespace uses it a lot. I use the Decorator (wrapper) and Adapter pattern a lot when I'm writing custom web controls for my application.

# William said on March 30, 2005 4:54 PM:

Thanks you guys! I appreciate it. I'm going to run through the IO libs tonight and try to get a better handle on them. Scott- if you have any examples or could show me one of your controls where you use it, I'd Really appreciate it ;-)

# William said on March 31, 2005 12:01 AM:

That's cool. I didn't know that it had a name until I read this entry but it comes in handy when you want to call a method in a sliced object and not call the base class method. So then you get your functionality plus the sliced objects functionality without having to know to much about the object that is being sliced other than it conforms to your decorator interface. It scales up well because you can add more concrete classes and so long as they conform you can use them with your classes derived from the decorated one without changing any code. It beats the h3ll out of having to sub-class each concrete class. That is for sure.

Search

This Blog

Tags

Community

Archives

News

My other sites

Cool Stuff

Book Stuff

Security

ORM

Data Access

Funny Stuff

Compact Framework Stuff

Web Casts

My KnowledgeBase Articles

My MVP Profile

Design Patterns

Performance

Debugging

Remoting

My Fellow Authors

My Books

LINQ

Misc

Speech

Syndication

Email Notifications