10 Dec

Building Supportable Systems (Package Management)

Working in a large company where we do most of our own software development in-house we have a wide range of coding practices and various levels of supportability. For example, much of the older code doesn’t make use of any IOC and this is fair enough, it was written in the days of ASP.NET web forms, or windows forms, dependency injection wasn’t a common practice a few years ago, and unit testing wasn’t much of a consideration at the time either.

Fast-forward to 2014 (almost 2015) and these code-bases are starting to become harder to support, especially when compared to what we now think of as standard practices. Add to this the requirement to deliver reliable, supportable and testable software and we start to build quite a challenging environment.

I’ve put together a few short presentations to share the latest “what’s hot” in .NET and C# with my work colleagues and last week I gave a brown-bag on the topic of “Building Supportable Systems” covering a few of my favourite .NET tools.

This post is part 1 of a series of around 8 on various supportability topics such as Logging, Metrics, Testability and the like, but before we can get into those exciting topics – I first want to introduce one of the keystone elements to adding all of these great supportable benefits to .NET code-bases.

The code samples for this (and all the other projects) are available on GitHub https://github.com/ShawInnes/SupportableSoftware

Package Management

I’d be surprised if any .NET developer who’s actively developing hasn’t already heard of NuGet, but there are still a number of organisations who don’t permit the use of external package management processes. Today I was at DDD Brisbane and one of the other attendees said his company won’t allow them to consume NuGet Packages.

There’s plenty of good information on how to use NuGet and probably the best place to get started is through the official nuget.org website or by reading some of Scott Hanselman’s blogs from a while back. There are currently 29,000+ packages available for download from the nuget.org site and these provide all manner of great functions from assertion libraries to zipping.

My personal preference is to use the package manager console in visual studio, under the Tools -> Package Management menu.

PM> Install-Package {Package Id}
PM> Install-Package Humanizer

The Humanizer package by Mehdi Khalili has all sorts of great data-to-text conversion functions so you can do things like convert integers to human-readable text and a variety of other handy conversions. This is a perfect example of something where you could write your own, but why would you? Mehdi (and contributors) have put a lot of time and effort into making a great stable library already.

DateTime.UtcNow.AddHours(-30).Humanize() => "yesterday"
DateTime.UtcNow.AddHours(-2).Humanize() => "2 hours ago"