Tuesday, May 18, 2010

Unity 2.0 Design pattern in simple words

As part of my search for perfection in technology, I come accross many different technologies. Some of them are worth delving into. One of them is Unity 2.0 design pattern. In this article I will try to explain the basic premise of Unity 2.0 design pattern, where it should be used, where it should not be used and simple steps to implement Unity 2.0 Design pattern.

Unity 2.0 design pattern in simple words:
  • Unity 2.0 is a type of design pattern that can be used to implement composite application library.
  • Unity 2.0 design pattern lets us to view different modules of our composite application to appear as signal entity.
  • It allows objects belonging to different modules to implement dependency on each other.
From the above mentioned points, the most important word here is dependency. So in more simpler words

"Unity 2.0 design pattern is used to implement dependency injection"

How to implement Unity 2.0 design pattern?

Step 1: Download Unity 2.0 library. This can be found here.

Step 2: Create composite application using Composite Application Guidance. You can find the details about this here.

Step 3: Override the boot strapping class in composite application to use Unity bootstrapper.

Step 4: Identify classes in your composite application that are dependent.

Step 5: Create a dependency injection (DI) container using the Unity 2.0 library.

Step 6: Implement dependency injection using one of the following techniques:
  1. Using build up to wire up objects not created by the container
  2. Using injection attributes
Happy coding!