Home > Microsoft .Net Development Tips > .NET Developer > Improve dependency injection with ObjectBuilder
Win Development Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

.NET DEVELOPER

Improve dependency injection with ObjectBuilder


Brian Eastwood, Associate Editor
04.05.2006
Rating: --- (out of 5)


Office Development Channel
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Reusing components and objects in programming has obvious advantages, such as a tighter architecture. One downside, though, is the myriad of dependencies that results.

One answer is dependency injection, or DI, which is the task of helping child objects find each other. The process is akin to "putting objects in a bag and shaking it up and getting stuff out," said Brad Wilson, lead developer for Microsoft's patterns & practices team, at the group's recent summit at Microsoft's Boston-area offices.

The hardest way to implement DI, naturally, is hard coding. The Service Locator -- a component model inside Visual Studio and the DI system used in CAB -- is better, but it requires a dependency on the ILocator and storing constants is difficult.

Enter the Dependency Injection Container. This eliminates the need for an object to find its own dependencies through the use of containers, which create objects and fulfill dependencies for them.

This functionality is part of ObjectBuilder, a new Microsoft technology that Wilson described as "a framework for building dependency injection frameworks.
More from Patterns & Practices Summit East

Neward on communication design patterns

Toolkits, CAB and workflows

Mash-ups, Web 2.0 and developer empowerment

"As soon as your applications become non-trivial, it's a real problem creating objects. We decided to create a framework for all of you to build your containers," Wilson said.

The builder itself is comprised of strategies and policies, a locator and a container; this means the processes of finding items and storing items are independent.

ObjectBuilder works through strategies and policies that set what Wilson called a "chain of responsibility" for dependency characteristics such as singletons, nested containers, method invocation and instrumentation.

"The important thing about ObjectBuilder is that it's extensible," Wilson said. "If you don't like ours, you can write your own. It's perfectly acceptable."

ObjectBuilder is currently in use in Microsoft's CAB and in its Enterprise Library. Wilson said the patterns & practices group will soon post a sample of an XML-driven container on the ObjectBuilder page on GotDotNet.

More information is also available in this September 2005 MSDN article, Design Patterns: Dependency Injection.

Rate this Tip
To rate tips, you must be a member of SearchWinDevelopment.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
.NET Developer
How to speed up Visual Studio 2008's slow WPF designer
How to list fonts in WPF using markup extensions and data templates
How to convince management to buy Microsoft Visual Studio 2008
Microsoft webcast series previews new Visual Studio 2010 features
New features in Windows 7 bring new UI considerations for developers
User Account Control (UAC): How to develop code for standard users
Introduction to Vista's user account control (UAC) for developers
Visual Studio 2008 code metrics tools will help keep code clean
Downloadable MSDN library released for VS 2008 SP 1
Widgetbox provides good example of how to use Facebook Developer Toolkit

.NET Architecture Best Practices
Introduction to ASP.NET's Model View Controller (MVC) Design Pattern
Free book from Microsoft brings patterns and practices to .NET
Java application frameworks come to .NET
The faces of .NET/Java interoperability
.NET Development coming to a Cloud near you
Distributed caching goes mainstream
A look at concurrency constructs and primitives in .NET
Designing Windows Communication Foundation service contracts
Scaling WCF applications can challenge development teams
Microsoft touts rich Internet app development at Mix08
.NET Architecture Best Practices Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
.NET  (SearchWinDevelopment.com)
C#  (SearchWinDevelopment.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Database Programming Solutions - .NET XML, Visual Studio LINQ, ORM .NET
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts