1 / 16

Dealing with dependencies

Dealing with dependencies. jon fuller. IoC , DI, DIP, OMG, WTF?. Acronym overload! Whats it all mean? IoC – Inversion of Control DI – Dependency Injection DIP – Dependency Inversion Principle Often used interchangeably, but we’ll see they aren’t really all the same thing. IoC.

Télécharger la présentation

Dealing with dependencies

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dealing with dependencies jon fuller

  2. IoC, DI, DIP, OMG, WTF? Acronym overload! Whats it all mean? • IoC – Inversion of Control • DI – Dependency Injection • DIP – Dependency Inversion Principle Often used interchangeably, but we’ll see they aren’t really all the same thing.

  3. IoC • Declarative – Separation of what to do and how to do it • Hollywood Principle • Examples: • Winforms/WPF • Ruby On Rails • Dependency Injection

  4. DI[P] • Uncle Bob Says High-level modules should not depend on low-level modules. Both should depend on abstractions. • Dependencies are supplied by the caller of a module • The D in SOLID (saved the best for last? nah.)Single Responsibility PrincipleOpen Closed PrincipleLiskov Substitution PrincipleInterface Segregation PrincipleDependency Inversion Principle source

  5. But Why? • It’s Awesome! • All the cool kids are doing it! (read: Fowler, Uncle Bob, Me (did you know Cool is my middle name?), etc.) • Simplicity • Testability* • Configurability source * Loaded Term… Watch out!

  6. Example – Non-DI Tightly coupled!

  7. Example – DI Injected Dependency Injection site

  8. Yeah, but… You: Someone has to create that dependency right? Me: Yep You: Ah, so we just push it up one level. Wait, where’s the benefit in that? Me: Enter Container. source

  9. Example – DI w/Container Configure Container Get instance from container

  10. Example – DI w/Container (Autowire) Register the finder Configure finder Autowire, Automagic

  11. Conventions/Features • Constructor Injection • Property Injection • Lifecycle Management • AOP/Interception

  12. Common Implementations • .NET • Windsor • StructureMap • Unity • Ninject • AutoFac • Spring.NET • Java • Spring • Nano/Pico Container • Tapestry/Hivemind • Ruby • Copland

  13. Configuration Management • Fluent (StructureMap) • DSL (Binsor) • XML(Windsor)

  14. Testability • Loosely Coupled/Highly Cohesive • TDD • Mocking

  15. Resources • Fowler • http://martinfowler.com/articles/injection.html • http://martinfowler.com/bliki/InversionOfControl.html • Uncle Bob • www.objectmentor.com/resources/articles/dip.pdf • StructureMap – http://structuremap.sourceforge.net/ • Windsor – http://www.castleproject.org • Unity – http://www.codeplex.com/unity • Common Service Locator – http://www.codeplex.com/CommonServiceLocator

  16. Questions?/Comments/Feedback source

More Related