InfoQ

News

Microsoft Enterprise Library 4.0 will get a dose of Dependency Injection

Posted by Robert Bazinet on Dec 13, 2007 03:43 PM

Community
.NET
Topics
Enterprise Architecture
Tags
Patterns and Practices ,
Microsoft

The next version of the Microsoft Enterprise Library, v4, will support dependency injection out-of-the box.  Dependency Injection will be provided in containers both separately and part of the library.

It's important to note that the next release of the Enterprise Library was going to be v3.5 but was changed to be v4.0 due to the amount of core changes to the library.  Grigori Melnik, the Product Manager in the Microsoft Patterns & Practices group gives his reasons for the version change:

As to the Enterprise Library version change, yes, originally, we only planed to do minor enhancements and fixes. DIAB was a separate project in our product backlog. Based on the recent feedback from customers at the Patterns & Practices Summit, correspondence with Enterprise Library enthusiasts, comments from other teams at Patterns & Practices and CodePlex, plus people's constructive blog postings and suggestions it made sense to address the dependency injection story now – so we’ve included it in the coming release of Enterprise Library and that's not a minor change. Thus, v4.

What is Dependency Injection, as explained on Wikipedia:

Dependency injection (DI) is a programming technique, sometimes also (incorrectly) referred to as inversion of control or IoC, even though, technically speaking, dependency injection specifically refers to a limited-scope implementation of a particular form of IoC.

Dependency injection is where the implementation of one class is actually performed partially by another - the injected class (see the example below). Typically there are multiple variants (sub-classes) of the injected class. The main class abstracts out the common code required by all implementations and delegates to the injected class where specific behavior is required.

Inversion of Control is where a program gives up control of its own execution and simply responds to requests made of it (typically in the form of events). In the same way, a class using dependency injection gives up control over some of its implementation and lets the injected class do the work.

Dependency Injection is not a new technology, but has experienced popularity recently.  A good introduction can be found in an article written by Martin Fowler of ThoughtWorks. 

Microsoft views the importance of adding dependency injection to the Enterprise Library to take advantage of the benefits of modular design:

The benefits of modular design with cohesive components that have little or no coupling to the rest of the software system are commonly recognized today. Dependency injection is a mechanism that facilitates such aggressive decoupling and independence of components. Lightweight dependency injection containers help assemble components (potentially from different projects) into a cohesive application at runtime and promote code reuse.

Microsoft has a long history of incorporating modular design into their application blocks:

The values of modular design implemented with support of dependency injection have been long recognized and embraced by Microsoft patterns & practices. Originally, implemented for the Composite UI Application Block (CAB) and later for the Enterprise Library v2 (back in early 2006), the ObjectBuilder pipeline allows to customize how objects are created at runtime. The current Enterprise Library configuration system is based on a DI container created using ObjectBuilder.

Version 4.0 of the Enterprise Library will include much redesign and refactoring. 

With the upcoming version of EntLib (v4), we are planning to provide containers (flat and hierarchical) that will support dependency injection out of the box. These containers will be packaged individually and also with EntLib v4. Furthermore, to demonstrate the effective use of dependency injection on a real world project, we plan to refactor individual EntLib blocks and abstract away configuration code (configurators). We will build an EntLib facade that will have individual configurators injected in it as needed. A client app can go through this facade to request services while all wiring of objects necessary for those services to run will be handled by the DI container. This will not only make the design cleaner but will also make it easier to use and configure only those application blocks that you desire.

Some existing .NET application frameworks already support dependency injection and will be able work with the new application blocks including:

An organization using these containers will be able to leverage the new Enterprise Library into their existing infrastructure.  Anyone using an existing version of the Enterprise Library will be able to upgrade to the new version without breaking their code.

More information about the Microsoft Enterprise Library can be found at the Microsoft Patterns & Practices web site.  There has been no release date announced for version 4.0 of the library.

13 comments

Watch Thread Reply

Timeframe EntLib4 by Gabriel Lozano-Moran Posted Dec 13, 2007 4:50 PM
Re: Timeframe EntLib4 by Cameron Purdy Posted Dec 13, 2007 5:49 PM
Re: Timeframe EntLib4 by Shay Banon Posted Dec 13, 2007 6:09 PM
Re: Timeframe EntLib4 by Robert Bazinet Posted Dec 13, 2007 7:20 PM
Not the first DiP attempt by MS by Solomon Duskis Posted Dec 13, 2007 8:37 PM
Re: Not the first DiP attempt by MS by Grigori Melnik Posted Dec 14, 2007 6:31 PM
DI Container (Unity) API preview now available by Grigori Melnik Posted Jan 15, 2008 5:56 PM
Unity Extensibility Workshop by Grigori Melnik Posted Jan 29, 2008 7:14 PM
Re: Not the first DiP attempt by MS by Derek Greer Posted Feb 17, 2008 8:48 AM
Unity - February 2008 Community Technology Preview released by Grigori Melnik Posted Feb 12, 2008 6:46 PM
Unity 1.0 is released on MSDN by Grigori Melnik Posted Apr 5, 2008 10:41 AM
Enterprise Library 4.0 released on MSDN by Grigori Melnik Posted Jun 13, 2008 4:02 PM
Update: Enterprise Library 4.1 and Unity 1.2 released by Grigori Melnik Posted Nov 2, 2008 12:26 AM
  1. Back to top

    Timeframe EntLib4

    Dec 13, 2007 4:50 PM by Gabriel Lozano-Moran

    Timeframe for EntLib4 is February - March 2008: http://blogs.msdn.com/agile/archive/2007/12/03/making-dependency-injection-simpler-in-entlib-4.aspx

  2. Back to top

    Re: Timeframe EntLib4

    Dec 13, 2007 5:49 PM by Cameron Purdy

    Hmm .. only seven years later than the rest of the industry? ;-) Peace, Cameron Purdy Oracle Coherence: Data Grid for Java and .NET

  3. Back to top

    Re: Timeframe EntLib4

    Dec 13, 2007 6:09 PM by Shay Banon

    Hmm .. only seven years later than the rest of the industry? ;-) Peace, Cameron Purdy Oracle Coherence: Data Grid for Java and .NET
    Yea, in that respect. But then, as a Java user, I envy .NET language features....

  4. Back to top

    Re: Timeframe EntLib4

    Dec 13, 2007 7:20 PM by Robert Bazinet

    Thanks. I saw the timeframe too but didn't know if it was official or not.

  5. Back to top

    Not the first DiP attempt by MS

    Dec 13, 2007 8:37 PM by Solomon Duskis

    Microsoft has had a DiP Container for a while now - ObjectBuilder, but I haven't heard too many good things about it. The big news here is that Microsoft is reaching out to OSS experts and valuing their input. My colleague Jeremy Miller, the guy who's been the sole proprietor of StructureMap, blogged about it yesterday and seems to be impressed by MS's work on the project. Jeremy is on the Alt.Net group that's trying to change the Microsoft shops to accept alternate ways than the One Microsoft Way. The following sentence from his blog resonated with me:

    All of us StructureMap/Windsor/Spring.Net enthusiasts need to remember that there are unenlightened shops that simply won't use any OSS tools
    I've crossed paths with a few Microsoft developers who had the same "unenlightened" attitude about OSS. DIAB may be a back door for the other developers who actually like alternatives to use OSS on their projects. While I'm at it, I'm going to shamelessly link my blog entry on this subject ;).

  6. Back to top

    Re: Not the first DiP attempt by MS

    Dec 14, 2007 6:31 PM by Grigori Melnik

    As a matter of clarification, ObjectBuilder is not a DI Container per se, but a framework for building DI containers.

  7. Back to top

    DI Container (Unity) API preview now available

    Jan 15, 2008 5:56 PM by Grigori Melnik

    Some more info: http://blogs.msdn.com/agile/archive/2008/01/14/diab-is-now-unity.aspx

  8. Back to top

    Unity Extensibility Workshop

    Jan 29, 2008 7:14 PM by Grigori Melnik

    Microsoft patterns & practices will host Unity Extensibility Workshop to walk the participants through the design of Unity container and its extensibility model. You will become familiar with all aspects of the container infrastructure and container extensions: from using existing extensions to building your own. A special attention will be given to the integration of Unity with Enterprise Library 4.0 and the refactored application blocks. For more information and to register visit: http://blogs.msdn.com/agile/archive/2008/01/29/unity-extensibility-workshop.aspx

  9. http://www.codeplex.com/unity

  10. Back to top

    Re: Not the first DiP attempt by MS

    Feb 17, 2008 8:48 AM by Derek Greer

    As a matter of clarification, ObjectBuilder is not a DI Container per se, but a framework for building DI containers.
    If I may, I'd like to further clarify this description. While it is true that Object Builder is a framework, it isn't just a framework for building DI containers. Moreover, it isn't even limited to building IoC containers. Object Builder is an "Object Factory Pipeline Framework". It can be used to build a whole host of different types of object creation constructs. That said, I believe it was primarily developed to serve as an Inversion of Control framework, though they have always used the term "DI" in the description. I find a bit of irony in everyone's use of the term "Dependency Injection" to describe "Inversion of Control" containers. This term apparently came about because Martin Fowler felt the term "Inversion of Control" was too general to be descriptive of the containers he was seeing at the time. Apparently, the containers he was seeing were merely being used to invert the concerns of dependency acquisition as opposed to doing stuff like inverting the concerns of registration. Regardless of whether the term was misapplied or not at the time, the term was invented based upon the premise that terms to adequately describe what they are doing. Inversion of Control is a correct description, but perhaps not adequate. However, applying the term "Dependency Injection" to forms of inversion of control is not correct. When you start using these containers to do stuff like automatically register services, or automatically wire up events and event handlers using a broker, this goes beyond simply acquiring a dependency. I think having the term "Dependency Injection" is a good thing as it can allow us to further qualify what sort of Inversion of Control we are referring to. However, having this increased vocabulary is only helpful if we are going to actually use the terms correctly.

  11. Back to top

    Unity 1.0 is released on MSDN

    Apr 5, 2008 10:41 AM by Grigori Melnik

    Microsoft patterns & practices is pleased to announce the final release of Unity DI container: http://msdn2.microsoft.com/en-us/library/cc468366.aspx

  12. Back to top

    Enterprise Library 4.0 released on MSDN

    Jun 13, 2008 4:02 PM by Grigori Melnik

    This release of Enterprise Library includes the following:
    – Integration with the Unity Application Block
    – Windows Management Instrumentation (WMI) 2.0 support and improved instrumentation
    – Performance improvements (particularly, in the Logging Application Block)
    – Pluggable Cache Managers (outproc and distributed caches are now possible)
    – Visual Studio 2008 support
    – Bug fixes

    Note: existing public APIs (v3.1) are still supported.

    The Application Block Software Factory and the Strong Naming Guidance Package are not included in this release but are available as a separate download. Thus, there is no longer a dependency on Guidance Automation Extensions (GAX).
    To download visit:
    http://msdn.microsoft.com/entlib

    For the detailed list of all changes, see About This Release of Enterprise Library.

  13. Fixes + Unity now supports interception. http://blogs.msdn.com/agile/archive/2008/10/28/just-released-microsoft-enterprise-library-4-1-and-unity-1-2.aspx --Grigori

Educational Content

Bindings, Platforms, and Innovation

This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.

Orchestrating Long Running Activities with JBoss / JBPM

This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.

Neo4j - The Benefits of Graph Databases

This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.

Realistic about Risk: Software development with Real Options

This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.

Communication Flexibility Using Bindings

This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.

Writing DSLs in Groovy

After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.

Scaling Agile with C/ALM (Collaborative Application Lifecycle Management)

IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.

Concurrent Programming with Microsoft F#

Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.