Unity Application Block

June 7, 2008

Unity Application Block

A new release of enterprise library was published few weeks ago.Patterns & Practices
In the new release the ObjectBuilder subsystem was replaced with
the new Unity application block. In this post I’ll describe what is the
Unity application block and when to use it.

What Is The Unity Application Block?
The Unity application block is described as a lightweight,
extensible dependency injection container. Unity enables
constructors, properties or method calls injections.
The main reason to use Unity is to design and build loosely coupled
applications. By doing so the application will be more flexible and
maintainable. Dependency injection is a technique for building a
loosely coupled applications. It decouples the dependencies between
objects and abstract their connections. For example a scenario of a 
person class that use a validation object which validate it’s properties
and a data access object which holds the person’s database operations. 
The dependency injection techniques help to the person class to 
instantiate and populate those objects and also help to decouple those
objects from the person class.

Advantages Of Using Unity

  • Simplifies object creation.
  • Abstraction of requirements – dependencies are specified
    in runtime or by configurations.
  • Increased flexibility by deferring component configuration to the
    container.
  • Service location capability – clients can store or cache the
    dependencies container.

When To Use Unity?

  • You have dependencies between objects.
  • The dependencies are complex and you need a way to abstract
    them.
  • You want to be able to change your dependencies at runtime.
  • You want to be able to persist your dependencies in web
    applications.
  • You want to use constructors, properties or method calls injections.

Summary
In this post I explained what is the Unity application block,
why to use it and when to use it. In the next posts in this subject I’ll explain
how to use Unity in more details.

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>