.NET Framework Extension Methods


Going over the Design Patterns coined by the Gang of Four (GoF), and working with the Decorator pattern quite a bit recently, I did a comparison of this pattern and the .NET Framework extension methods. So, does an extension method extend a class such as the Decorator pattern advocates? On first looks possibly, but an extension method doesn’t wrap the class being extended, it is a compiler “trick”. I think that extension methods are more akin to the Visitor pattern.

Advertisements