Dependency Injection, Generics, Enterprise Library 2.0, Composite UI Application Block, and the ObjectBuilder Framework
If you plan on using the Composite UI Application Block or the Enterprise Library 2.0, you need to understand dependency injection and Generics.
Both dependency injection and Generics are well worth investigating. Understanding both topics can help you improve you own designs. After getting a better understand of both topics with the resources below, I suggest investigating the Composite UI Application Block and the Enterprise Library 2.0. They have proven to be the best resource I have found for getting a thorough understand of applying dependency injection and Generics in production level code.
Links to both the Composite UI Application Block and the Enterprise Library 2.0. can be found here:
Information on Generics can be found here:
A great summary on dependency injection can be found here: http://www.martinfowler.com/articles/injection.html
The ObjectBuilder- A little more info...
The ObjectBuilder framework is used to create and inject instances of objects of the appropriate type into the application at runtime.
The following summary comes from the Composite UI Application Block help file:
ObjectBuilder uses a pipeline of strategies that allows multiple operations to take place as objects are instantiated and prepared for use. This allows you to control the order that the processes take place. It also supports controlled disposal of object instances by executing the appropriate pipeline processes in the reverse order.
ObjectBuilder strategies manage the processes performed on objects during construction and disposal. The ObjectBuilder pipeline is organized into stages, and each stage of the pipeline contains multiple strategies. You can implement your own strategies as a .NET class with a specific interface.
Design of ObjectBuilder
The construction and disposal of object instances is a common process in most applications, and particularly in business applications such as those built using the Composite UI Application Block and the Enterprise Library. For this reason, these blocks take advantage of an underlying sub-system called ObjectBuilder that performs all of the repetitive and necessary tasks for creating object instances, while still providing a high level of flexibility.
ObjectBuilder encapsulates features that simplify the creation of object instances. It can:
- Ensure the creation of specific concrete class instances, even when requests are for abstract types.
- Ensure the return of existing object instances when this is appropriate, or always generate new instances.
- Create the appropriate objects based on configuration data.
Intelligently select the appropriate constructor when a class exposes more than one constructor.
- Automatically apply values to public properties that contain attributes, and execute methods on the object, in response to pre-defined policies.
- Respond to attributes declared on the properties and methods, which influence the creation and naming of the new object.
- Communicate automatically with objects that support the IBuilderAware interface to indicate, for example, that object creation is complete.
- Provide a tear down facility that can remove settings from existing objects by reversing the chain of operations.
ObjectBuilder is a low-level utility that, in most cases, you will not interact with directly in your applications. The classes in the application blocks use it to generate object instances in response to your code creating the classes declared within the application blocks.
However, you can use the features of ObjectBuilder directly in your applications and your own frameworks if you wish. You can also influence the behavior of ObjectBuilder by creating your own strategies or modifying the existing strategies.
Copyright © 2005 by Microsoft Corporation. All rights reserved.