Dependency Injection And Ioc Containers

3,035 views

Published on

These slides are from my presentation at the January 2010 Chicago Architects Group meeting on Dependency Injection and Inversion of Control Containers

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,035
On SlideShare
0
From Embeds
0
Number of Embeds
24
Actions
Shares
0
Downloads
80
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Dependency Injection And Ioc Containers

  1. 1. Dependency Injection And IOC Containers<br />Tim Murphy<br />Technical Specialist - PSC Group, LLC<br />
  2. 2. The Pursuit of the Loosely Coupled System<br />
  3. 3. Traditional Object Structure<br />Database Access Service<br />Entity<br /><ul><li>Database Access Service
  4. 4. Service Proxy
  5. 5. Logging Service
  6. 6. Etc..</li></ul>Service Proxy<br />Logging Service<br />Tightly coupled services!<br />
  7. 7. <ul><li> Doesn’t promote reusability
  8. 8. Creates brittle systems
  9. 9. Difficult to “mock” makes testing difficult</li></li></ul><li>With Dependency Injection<br />
  10. 10. The End(or is it)<br />
  11. 11. Better….<br />… but still a lot of work<br />There are so many dependencies in this system, how do I manage them all?<br />
  12. 12. Dependency InjectionWith a Factory Pattern<br />Entity<br />“I need to be created, including have all my services crated and given to me.”<br />Object Factory <br />“ I know how to build all of this stuff.”<br />Create a<br />Concrete instance<br />Create an<br />Entity for me<br />Instance for<br />application<br />Application<br />“I need an Entity, but I don’t know how to create it.”<br />
  13. 13. I want to spend my day writing functional business code, NOT a bunch of plumbing code…<br />
  14. 14. Dependency Injection Frameworks to the Rescue!<br />Structure Map<br />Ninject<br />Windsor <br />Microsoft Unity<br />
  15. 15. With a Dependency Injection/ IOC Framework<br />Entity<br /><ul><li>Database Access Service
  16. 16. Service Proxy
  17. 17. Logging Service
  18. 18. Etc..</li></ul>Application<br />“I need a concrete instance of an Entity…”<br />Provider<br />“You tell me what type of object you want, I give you the object you need:”<br />Container<br />“You ask me for objects, I create them based on my registrations”<br />
  19. 19. DEMO TIME!<br />
  20. 20. Related Topics<br />Microsoft Provider Model<br />Microsoft Extensibility Framework (MEF)<br />
  21. 21. Some helpful links…<br />Martin Fowler <br />martinfowler.com/articles/injection.html<br />MSDN Article on Dependency Injection pattern<br />http://tinyurl.com/bm8wm5<br />Dependancey Injection tutorial<br />http://tinyurl.com/5fysrq<br />
  22. 22. Some helpful links…<br />DI/IOC Frameworks:<br />Ninject.org<br />StructureMap.Sourceforge.net<br />www.castleproject.org/container/index.html<br />Unity (tinyurl.com/cm9pe3)<br />
  23. 23. http://geekswithblogs.net/tmurphytmurphy@psclistens.comTwitter: twmurph<br />

×