At the p&p Summit in November here in Redmond I gave a talk called “EntLib Refactored”. This talk was started by my work done on the EntLib contrib project under the same name. What I wanted to do was make Enterprise Library smaller, simpler and easier to consume. My first attempt was to rewrite the blocks to not depend on Configuration. This was a great first stab, yet I found that what I really wanted was to reduce the size of things (which factoring out config did not do). What I wanted to do was get rid of the factories and use a Dependency Injection Container to wire up the objects. Brad Wilson and myself had been working on Object Builder 2 and Containers on top of them to test it out. What we needed for Enterprise Library was a DI Container.
After working on previous versions of Enterprise Library, we have learned that we needed Dependency Injection (DI) without knowing it and did it at the most basic level. We created factories: which is a form of simple DI. The problem this created is that each individual block was responsible for it’s own configuration and configuration was buried at the bottom of the stack. We need to change around the model a bit to make the responsibility of configuration built into the DI Container and remove all that extra code from each block.
Here is a picture of the old way: [BTW Enterprise Library Factory is buried at the bottom in the Core assembly that no one sees.]
Here is the new way:
This looks better. Configuration is about the container. WAHOOOOOO! This means that building a block, using a block adding your extensions and having the configuration all comes through the container. This will make it easier for you to use Enterprise Library with Unity or your current DI container and allow us to deliver more cool things to you, the customer. Look for more on this later.
That all sounds good, yet there is one lagging thing that needed to be addressed: the devil. Backwards compatibility is the work of the devil, and just like the devil, necessary. This is fueled by the fact that Enterprise Library has reached over a million downloads and not having a story would cause a lot of people to swing large baseball bats at us. So the old way will still work working with factories so you can upgrade and migrate slowly.
The funny story about Unity is the name. Grigori and I were trying to come up with a name for this DI block and mentioned it to Peter Provost when we settled on Unity (which is better than the Doohicky Application Block that was up on the board). Peter never thought we would get it pass legal… neener neener is what we said when we got it. He said “Enterprise Library 4: Now with more Peace love and Rock n’ Roll”.
Doesn’t Remind Me from the album “Out Of Exile” by Audioslave