The Lounge is rated PG. If you're about to post something you wouldn't want your
kid sister to read then don't post it. No flame wars, no abusive conduct, no programming
questions and please don't post ads.
For some reason I never thought of writing them for enums, though I use them for interfaces all the time. Can you give an example where an extension method for an enum would be useful? Can't think of any myself off hand.
Samhain (Halloween) is still fifteen days away, but you got my vote on this one, anyhow.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
Extensively sounds funny to me. Unless you are creating a framework of extension methods for built-in or third party types, using it intensively may indicate you're doing something wrong with your code.
They have a purpose, be sure you understand it before using it everywhere. It may create unorganized, hard to maintain code.
To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson
Our heads are round so our thoughts can change direction - Francis Picabia
Yes, quite a bit. I love the extension method concept. Now if they could just implement "extension properties". Yes, I know you can use extension methods to pseudo-implement properties, but a full-blown extension property implementation would be sweet...
The core products for the company I work for are mainly COM based libraries. I've written .Net libraries of extension methods that help hide the COM ugliness and provide a more .Net friendly interface.
I use extension methods somewhat. I'm slowly building a suite of useful methods. There is also the site extensionmethod.net too.
I keep the extension methods in a core library, but the methods are declared in the namespace of the class I'm targeting. That way, when I reference the core library all the extension methods are available without superfluous using statements.
Be careful, there is an ongoing debate on the internets about whether they're a good thing or bad thing. I would say, use sparingly, and note that an extension method is probably sign-posting a limitation in your design.
As well as other suggestions, I've used them to clean up a messy code base I've inherited. In this code base there were a number of inappropriate methods attached to a static globals class. Side-stepping the whole issue of a statics globals class, the methods attached to it were moved onto extension methods. Not a perfect solution, but migrating to extension methods helped me nudge the legacy code in the right direction.