BT

Microsoft Enterprise Library 4.0 will get a dose of Dependency Injection

by Robert Bazinet on Dec 13, 2007 |

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.

Hello stranger!

You need to Register an InfoQ account or to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Timeframe EntLib4 by Gabriel Lozano-Moran

Timeframe for EntLib4 is February - March 2008:
blogs.msdn.com/agile/archive/2007/12/03/making-...

Re: Timeframe EntLib4 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

Re: Timeframe EntLib4 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....

Re: Timeframe EntLib4 by Robert Bazinet

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

Not the first DiP attempt by MS 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 ;).

Re: Not the first DiP attempt by MS by Grigori Melnik

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

DI Container (Unity) API preview now available by Grigori Melnik

Unity Extensibility Workshop 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:
blogs.msdn.com/agile/archive/2008/01/29/unity-e...

Unity - February 2008 Community Technology Preview released by Grigori Melnik

Re: Not the first DiP attempt by MS 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.

Unity 1.0 is released on MSDN by Grigori Melnik

Microsoft patterns & practices is pleased to announce the final release of Unity DI container:

msdn2.microsoft.com/en-us/library/cc468366.aspx

Enterprise Library 4.0 released on MSDN 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:

msdn.microsoft.com/entlib



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

Update: Enterprise Library 4.1 and Unity 1.2 released by Grigori Melnik

Fixes + Unity now supports interception.

blogs.msdn.com/agile/archive/2008/10/28/just-re...

--Grigori

Re: Timeframe EntLib4 by Wes Nur

i think for any body using Enterprise Library from Microsoft, they should consider the drawbacks as well. I would suggest a research before going ahead. A good read can be found here Drawbacks of regular Caching Application Block

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

14 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2013 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT