.NET Utility Libraries Galore
July 15, 2008Yesterday Karl Seguin announced a new .NET Extension Library. One of the really interesting pieces of the library is a streamlined approach to a simple dictionary
cache, which is similar to the one described in another interesting looking utility library called ShadeTree. Recently, Ayende Rahein reviewed another .NET utility library called Umbrella, which looks like a pretty wide and deep set of utilities. As I am about to create a new solution to consolidate the utility functionality we use across our various projects, it got me thinking it might be time to pick an established (or growing) library from the community and try to contribute any missing pieces we need for our own projects.
I figured that the three utility libraries mentioned above probably weren’t the only ones – it’s something anyone that works on more than one project is likely to at least think about creating, and something that is easy to contribute to open source, because utility libraries like these are generic by their nature. Here is what I found on Codeplex (none of these are dead – they all have relatively recent check-ins, and decent download traffic):
http://www.codeplex.com/Utilities
http://www.codeplex.com/publicdomain
http://www.codeplex.com/nice <- primarily graphics and math
http://www.codeplex.com/DotnetCommons
http://www.codeplex.com/dotNetTipsUtility
http://www.codeplex.com/toolbox
http://www.codeplex.com/nucleo
And the two already mentioned:
http://www.codeplex.com/umbrella
http://www.codeplex.com/nxl
And the Shade Tree project:
http://storyteller.tigris.org/source/browse/storyteller/trunk/src/ShadeTree.Core/?rev=177#dirlist
[Update/Correction] Apparently Rhino Commons is far more than a collection of utilities. To be honest, I haven’t looked too closely at it yet, and had a misconception about what it was. Time to repair my ignorance, I suppose.
http://ayende.com/wiki/Rhino+Commons.ashx
If you’re interested in learning a bit about Rhino Commons, and you don’t mind learning about it in the context of ASP.NET MVC, or alternatively you just want to visit a site called “frickinsweet.com”, check out this series of posts by Ryan Lanciaux: (I’m linking to part one – there are currently 5 parts)
http://frickinsweet.com/ryanlanciaux.com/post/RhinoCommons2c-NHibernate-and-ASPNET-MVC.aspx
Here’s a “utility” library with some light similarity (but much smaller scope) to Rhino Commons (in that it contains Repository and Unit Of Work implementations for NHibernate), and there is some WCF bag-o-trick stuff here as well:
http://davybrion.com/blog/stuff/
And for good measure, here is a round up of the extension method collections I’ve seen lately:
http://weblogs.asp.net/okloeten/archive/2008/06/19/6296904.aspx
http://weblogs.asp.net/okloeten/archive/2008/08/01/6463327.aspx
http://www.iridescence.no/Posts/A-Set-of-Useful-Extension-Methods-for-DateTime.aspx
http://james.newtonking.com/archive/2008/03/27/formatwith-string-format-extension-method.aspx
http://www.hanselman.com/blog/ASmarterOrPureEvilToStringWithExtensionMethods.aspx
http://elegantcode.com/2007/12/05/firing-events-with-extension-methods/
Here is a new library of extension methods for .NET 3.5, and a blog post describing the project
Update: Vijay Santhanam mentioned a website in the comments, http://www.extensionmethod.net/, that is pretty much exactly what I had in mind when I wrote the below paragraphs. It would be cool if it could be used beyond extension methods, for other sorts of utility classes & tools (maybe it can), but still, very cool website.
Wow…That’s a Lot
I’m not likely to have time to evaluate them all in order to choose one, but it got me thinking about utility libraries in general and if it makes sense to “choose one” at all. Utility Libraries (that is, all purpose, non-specialized ones, like the giant Swiss army knife above) are kind of personal. They aren’t like other libraries, where you have something you need done, and they do it well. They are all the million odd places you put a dab of oil onto the framework you’re using because it sticks or creaks, and one thing is certain, no matter how complete your utility library, you’ll need that one more helper class here and extension method there, and at a moments notice, and you’ll need somewhere to put them. Maybe a utility library is less like a giant Swiss army knife and more like a fisherman’s hat or a tackle box, everyone has one, they contain a lot of the same things, but every team has their own, highly personal selection that makes sense to their particular style and scope of work. ![]()
Another problem with finding “the” utilit
y library to use is that, while I’m sure there is heavy overlap among the various options, while perusing each I’m certain to find a few utilities done very well in one library, and others done very well in another, and yet I don’t want to reference half a dozen utility dll’s in my project. For instance, the caching mechanism in the new .NET Extension Library looks awfully handy, but the Umbrella project contains a number of great things I think I would use on a daily basis as well. As I look through the others, I’m quite certain I’ll continue to have that experience.
That makes me more likely to cut and paste code out of the various offerings into my own utility library more likely than with any other kind of open source project I can think of, in the same way perhaps as a fisherman prepares his tackle box.
Well, I don’t have a good solution to this, but I wonder if the utility library concept doesn’t really work as an open source project you choose and use as your main utility provider, unless perhaps everyone can agree on one, and the barrier to getting contributions accepted is very low. Another approach might be a Wiki approach (Karl Seguin’s own Code Wiki comes to mind, or a version of it anyway) where anyone can contribute source code and tests for their utilities very easily, and people can comment on or discuss them, download them or cut and paste them. The whole thing could probably be available as a solution, but it would also be easy to pull out pieces via copy and paste or maybe single file download that match your type of projects and your style of working, and it would be A-OK to have lots of utilities even for edge cases and niche’s, because the thing wouldn’t need to be monolithic. And it would be searchable, tag-able, browse-able, etc.
Anyway, that isn’t likely to happen any time soon, even if it’s feasible, which it might not be. In the mean time, I imagine it is cut and paste for me
[Update: http://www.extensionmethod.net/ looks like it might be the kind of thing I'm talking about]












