Karl Seguin

Sponsors

The Lounge

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Announcing the .NET Extension Library

285 days ago I blogged about my dislike for extension methods. Extension methods aren't very discoverable, and they can lead to poor communication (between members of a team, from project to project, and between a developer and the code he or she is trying to read).

I still think extension methods have serious shortcoming, but I've soften my view on them quite a bit. I don't know what changed, maybe it was my extended foray into Ruby or spending the last few weeks neck-deep in the ASP.NET MVC framework, but I decided to attempt to put out a standard extension library for .NET developers. One of my gripes with extension methods is that they can make projects rather inconsistent, a new developer might be surprised that string.Left suddenly doesn't work on a new project. Ideally, having a well-known extension library might help solve that problem.

The .NET Extension Library isn't just about extension methods though. It's about providing core functionality to projects. For example, I've blogged a few times about how hard it is to unit test code that caches - largely because there isn't an cache interface. This is a problem no more. The .NET Extension Library has an ICache interface, a CacheFactory (which really just returns HttpRuntime.Cache - for now), as well as enhancements to the cache API. Here's one of my favourite examples of what you can do:

User user = CacheFactory.GetInstance.Fetch(
"user.{0}".Sub(userId),
() => _dataStore.GetUser(userId),
3.DaysFromNow());

Fetch is a mix between Get and Insert. My second favourite addition are the extensions to IEnumerable, which bring all collections/arrays inline with the List when it comes to methods like Each, TrueForAll, Find, FindAll and more. You no longer need to use the static Array methods.

Input is always welcomed, as are suggestions and/or additions. As much as I'm up for adding useful extension methods, I rather focus on classes that show up in every project kinda thing, such as an abstraction for logging and such.

Anyways, check it out at codeplex: http://www.codeplex.com/nxl


Posted Mon, Jul 14 2008 8:01 PM by karl

[Advertisement]

Comments

lomaxx wrote re: Announcing the .NET Extension Library
on Mon, Jul 14 2008 9:38 PM

This is a pretty sweet idea, however I remember reading about something similar called Umbrella which is also over at codeplex. www.codeplex.com/umbrella

Maybe you could combine efforts?

Nathan wrote re: Announcing the .NET Extension Library
on Mon, Jul 14 2008 11:19 PM

I agree- the umbrella project has a lot of great tools - it would be nice to have the single utility library to end all utility libraries :)

Reflective Perspective - Chris Alcock » The Morning Brew #136 wrote Reflective Perspective - Chris Alcock » The Morning Brew #136
on Tue, Jul 15 2008 2:49 AM

Pingback from  Reflective Perspective - Chris Alcock  » The Morning Brew #136

Dew Drop - July 15, 2008 | Alvin Ashcraft's Morning Dew wrote Dew Drop - July 15, 2008 | Alvin Ashcraft's Morning Dew
on Tue, Jul 15 2008 8:59 AM

Pingback from  Dew Drop - July 15, 2008 | Alvin Ashcraft's Morning Dew

.NET Utility Libraries Galore « HSI Developer Blog wrote .NET Utility Libraries Galore « HSI Developer Blog
on Tue, Jul 15 2008 12:49 PM

Pingback from  .NET Utility Libraries Galore « HSI Developer Blog

DotNetKicks.com wrote .Net Extension Method Library
on Tue, Jul 15 2008 1:51 PM

You've been kicked (a good thing) - Trackback from DotNetKicks.com

karl wrote re: Announcing the .NET Extension Library
on Tue, Jul 15 2008 7:32 PM

Thanks for the feedback. My problem with Umbrella is just how big it is. I'll consider offering up my code for them to merge, but not right away, I want to see what comes of this.

Frank Quednau wrote re: Announcing the .NET Extension Library
on Wed, Jul 16 2008 11:13 AM

You should also have a look at www.extensionmethod.net

see if anything tickles your fancy.

Daniel wrote re: Announcing the .NET Extension Library
on Wed, Jul 16 2008 4:27 PM

I think the problem of having too many extension method libraries in a developer's multiple projects is going to become having too many extension method library choices. There are dozens of "places" for extension method libraries online. Because they are fairly atomic and most static .NET library calls can become extension methods easily, I don't know if having another place to put them is going to help add consistency for developers consuming them.

Sam wrote re: Announcing the .NET Extension Library
on Thu, Jul 17 2008 6:00 PM

I downloaded the source, but it would be good if there was a list of the methods something. Or maybe I missed it? Cool post

Roiy Zysman wrote A Cool Channel 9 Webcast covering numerous technology news
on Sun, Jul 20 2008 2:28 PM

This Week on C9: Netflix, Extension Methods, Debugging, oh my Oh, did I also mention that they showed

Weekly Link Post 51 « Rhonda Tipton’s WebLog wrote Weekly Link Post 51 « Rhonda Tipton’s WebLog
on Sun, Jul 20 2008 6:13 PM

Pingback from  Weekly Link Post 51 « Rhonda Tipton’s WebLog

Recent URLs tagged Abstraction - Urlrecorder wrote Recent URLs tagged Abstraction - Urlrecorder
on Tue, Dec 2 2008 11:31 AM

Pingback from  Recent URLs tagged Abstraction - Urlrecorder