Dependency Inversion Principle

1,632 views
1,435 views

Published on

Covering DI, the D of SOLID. IOC tools, TDD and a bit of best practice

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,632
On SlideShare
0
From Embeds
0
Number of Embeds
561
Actions
Shares
0
Downloads
16
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Dependency Inversion Principle

  1. 1. http://lifetuned.com http://pikpak.me Dependency Inversion@tommysqueak http://tomphilip.me
  2. 2. About• Dependency Injection• Service Location• TDD & Mocking - How they play together nicely• Auto-mocking• IOC - Tools, Features, Usage, Pros/Cons, Best Practice
  3. 3. Definition• High-level modules should not depend on low-level modules. Both should depend on abstractions.• Abstractions should not depend upon details. Details should depend upon abstractions.
  4. 4. Design PatternsDependency Injection Service Locator
  5. 5. StoryAs a CustomerI want to change my passwordIn order to keep my account secureScenarioGiven I’m an account holderWhen I change my passwordThen It should ensure it is a strong passwordAnd it should change my passwordAnd it should notify me it has been changed
  6. 6. Demo
  7. 7. Benefits• Loose coupling• Re-use• Testability
  8. 8. Inversion of Control
  9. 9. ProvideDependency Injection Service Locator
  10. 10. Usage• Registration• Entry Point
  11. 11. Demo
  12. 12. Frameworks•AutoFac• NInject• Castle Windsor• StructureMap• Unity
  13. 13. How They Look
  14. 14. A Little Best Practice• Internal code should not reference the container directly• Verify registration with tests• Constructor Injection over Setter Injection over Service Location
  15. 15. Picture Credits• http://www.flickr.com/ • http://www.flickr.com/ photos/smil/4196304056/ - photos/gcwest/ Patterns 281385801/ - containers• http://lostechies.com/ derickbailey/2009/02/11/ solid-development- principles-in-motivational- pictures/ - SOLID pictures• http://www.flickr.com/ photos/kevindean/ 4031083510/ - trolley

×