Your SlideShare is downloading. ×
Dependency Injection & IoC
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Dependency Injection & IoC

5,448
views

Published on

Published in: Technology

1 Comment
9 Likes
Statistics
Notes
No Downloads
Views
Total Views
5,448
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
1
Likes
9
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Dependency Injection & Inversion of Control Unity Application Block vs. Spring.NET Dennis Loktionov [email_address] February 2009
  • 2. Agenda
    • What is a Dependency?
    • Dependency Injection Pattern
    • Injection Types
    • Dependency Injection Pros & Cons
    • Spring.NET vs. MS Unity Application Block
    • References
    • Questions
  • 3. What is a Dependency?
    • Common Dependencies
      • Application Layers
        • -- Data Access Layer
        • -- Business Layer
        • -- Presentation Layer
      • External Services
        • -- Web Services
        • -- WCF Services
      • External Components
        • -- Frameworks & Libraries
        • -- 3 rd Party Components
  • 4. Application Layers Dependencies
  • 5. Why dependencies are evil?
    • Problems that dependencies create
      • Tight coupling of software components
      • Software becomes hard to maintain
      • Difficult to isolate when testing
  • 6. Dependency Injection Pattern
    • WHAT
    • Dependency Injection (DI) in computer programming refers to the process of supplying an external dependency to a software component or service.
    • WHY
      • Ability to specify component dependencies at run time
      • Simplified management of cross-cutting concerns
      • Increased testability of individual components
      • Need for pluggable architecture
  • 7. Dependency Injection Types
    • Types of Dependency Injection
      • Constructor Injection
      • Property (Setter) Injection
      • Method Call Injection
  • 8. Dependency Injection Types
    • Constructor Injection
  • 9. Dependency Injection Types
    • Property (Setter) Injection
  • 10. Dependency Injection Types
    • Method Call Injection
  • 11. Dependency Injection Pros & Cons
    • Pros
      • Loosely Coupled & Highly Cohesive
      • Increased Testability & Maintainability
      • Flexibility of run time configuration
      • Inversion of Control containers do the wiring for you
    • Cons
      • Increased code complexity
      • Can complicate debugging during the learning curve
      • Code flow becomes not trivial
  • 12. Inversion of Control
    • Dependency Inversion Principle (DIP)
      • The principle states that high level or low level modules should not depend upon each other, instead they should depend upon abstractions.
    • Specific implementation (object instances) are deferred to a higher level of abstraction control.
      • Parent Classes
      • Container
  • 13. Frameworks
    • Frameworks
      • Spring.NET
      • MS Unity Application Block
      • Castle Windsor
      • StructureMap
      • Ninject
      • PicoContainer.NET
      • … and many more
  • 14. Spring.NET
      • Spring.NET Architecture
  • 15. Spring.NET
      • Inversion of Control Container in Action
  • 16. Spring.NET: code samples
      • Movie Lister example
  • 17. MS Unity Application Block
      • Unity Application Block Architecture
  • 18. Unity: code samples
      • Movie Lister example
      • Quick start web example
  • 19. Dependency Injection Pitfalls
      • Circular References
        • Objects generated though constructor injection that reference each other in their constructor parameters
        • Objects generated though constructor injection that pass a reference of their type in constructor
        • Objects generated though method call injection that reference each other
        • Objects generated though property injection that reference each other
      • Partial Trust Environment Limitations
  • 20. References
    • Useful links:
    • http://martinfowler.com/articles/injection.html
    • http://www.springframework.net/
    • http://www.codeplex.com/unity
  • 21. THANKS
  • 22. Questions ? Dennis Loktionov [email_address] 604-628-5100 ext .356