Dennis Mulder - Convert.ToString(My.Core.Dump)

ObjectBuilder on Codeplex

Just attended a fun session at the P&P Summit from Brad Wilson about Dependency Injection with ObjectBuilder. It turns out ObjectBuilder can now be found on Codeplex. Brad is now in the Codeplex team. He promised to finally work on the documentation of ObjectBuilder and as it turns out I think he will end up getting some help now that it is on codeplex.

Some notes from his presentation:

ObjectBuilder in the wild

Is a framework to build a dependency injection container

  • CAB & Mobile Software Factory
    • Workitem
  • Enterprise Library
    • Configuration System

Object Building Strategies

Build can create an object on your behalf. Locator object can resolve questions (get me a logger) and can resolve this to an existing Logger object (Lifetime). Strategies & Policies are used to determine how to create the objects. Strategies are a chain of responsibility that can return existing object (Singleton), Type mapping (specific logger, like Eventlog), Reflection, Creation (actually creating the object), Property Setter/Method calls (actually calling the object). Strategies don't make decisions (except the reflection). The policies make the decisions (should this be a singleton) and then the strategy does that. The Reflection strategy looks at which constructor to use (for example).

Four stages

  • Pre Creation (Singleton -> Type Mapping -> Reflection, decide what properties to set, which constructors to call)
  • Creation
  • Initialization (Property setter / Method calls)
  • Post initialization (Builder aware strategy, IBuilderAware, tell the object that things are done)

Make it your own

  • What kind of injection?
  • How do describe them?
  • What does the container look like?
  • What are the strategies I need?

Objectbuilder is powerful and flexible, not easy.

URLs

Codeplex ObjectBuilder site: http://shrinkster.com/j0w

Brad's Blog: http://www.agileprogrammer.com/DotNetGuy