The Patterns & Practices team at Microsoft have just released version 5 of their Enterprise Library which is definitely worth a look. I’ve been using parts of the Enterprise Library for quite a while now but must confess that I haven’t had cause to use all the application blocks. There was a time that I made extensive use of Data Access Application Block (DAAB), which was released even before the first version of Enterprise Library, but with the emergence of new .NET ORMs and alternative data access strategies I’ve drifted away from it. Unity was a welcome addition in Enterprise Library 4.0 and its good to see that this latest version of the Enterprise Library now internally uses and supports the Dependence Injection pattern
Overview of the Enterprise Library
Enterprise Library is made up of a collection of ‘Application Blocks’ which are effectively software libraries to support best practice and code reuse within common areas of application development. Version 5.0 does not add any new Application Blocks, but instead concentrates on improving what was there in v 4.1. The available application blocks are:
- Caching Application Block
- Cryptography Application Block
- Data Access Application Block
- Exception Handling Application Block
- Logging Application Block
- Policy Injection Application Block
- Security Application Block
- Unity Application Block
- Validation Application Block
Its also worth noting that all the blocks are designed to be extensible, not only by using provider model style extensibility, but full source code is available from CodePlex. Even if you decide not to use any of the application blocks there is a lot to be learned from the source code. After all this is intended to be best practice guidance.
What’s new in v 5.0?
As mentioned above there are no new Application Blocks in this release, but instead they have concentrated on improving what’s already there in terms of both the architecture and functionality of the existing Application Blocks. The key improvements are:
- Support for .NET 4.0 and Visual Studio 2010
- Improvements to the architecture including full support for Dependency Injection (DI)
- Independence from Unity should you want to use an alternative Inversion of Control (IoC) container e.g. Windsor
- Improvements for configuration (config wizard, Intellisense XSD Schema + more)
- DAAB supports asynchronous data access, unit testing (via DI), has LINQ support and supports data>object mapping
- Performance improvements
There are a few breaking changes between 4.1 and 5, but the one that will affect most people is the merge of ObjectBuilder2 into the Unity assembly.
Why use Enterprise Library?
Its worth pointing out that there are a number of good alternatives to these application blocks out there which are freely downloadable and have good community support. I’m not going to try to convince anyone that these are the only option or even the best option when it comes to selecting a framework, but it is certainly one that you should consider. Here are some plus points for selecting the Enterprise Library:
- It is a suite of blocks from a single provider, therefore it has a consistent style and is well integrated with other components in the suite. Developers may encounter a shallower learning curve when learning subsequent Application Blocks.
- It comes from Microsoft, so it will be much easier to get buy in from managers in some organisations. Its not always easy to convince the powers that be to use an open source, community based framework, especially if you are writing business critical software.
- Good samples, support and lifetime.
Its worth mentioning some of the alternatives to these application blocks. These include:
Caching Application Block
Although this block is widely used and works well I'm not sure how much of a future the Caching Application block will have, especially with the release of AppFabric. Its also worth looking at memcached.
Logging Application Block
The logging in Enterprise Library is pretty good, but you may also want to look at log4Net (which is a very popular port of log4j) or nLog.
Data Access Application Block
There is a myriad of options out there for data access so I'm not going to try and list the alternatives, but suffice to say there are plenty of them. Its worth considering the performance characteristics of the option that you choose, remembering that some data access strategies will generate dynamic (and sometimes poorly performing) SQL. DAAB works nicely with sprocs.
Unity Application Block
Unity is a lightweight Inversion of Control (IoC) container which is used throughout the Enterprise Library. Alternatives include Spring.NET's IoC Container or Windsor.