Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Agenda
SOLID Principles
Dependency Inversion, IoC, Dependency Injection
Pros and cons of Dependency Injection
Apply DI fra...
SOLID Principles
• Single Responsibility
• Open/Closed
• Liskov Substitution
• Interface Segregation
• Dependency Inversion
Database
Data Access Layer
Which Depends On
Business Logic Layer
Which Depends On
User Interface
Depends on
Dependencies
L...
Example Code
Dependencies Inversion (Principle)
Inversion of Control (Pattern)
Service Locator Event Delegate
Dependency
Injection
Example Code
Why Dependency Injection
• Loose coupling code
• Testability
• Clear dependency
• Separate of concern
• Easy to change
Why NOT Dependency
Injection
• Hard to learn
• Hard to debug
• Object created before needed
• More layer => More complexity
Simple DI Container
IoC in Action
Unity
Ninject
Structure Map
What
An “object to object”
mapper
Why
Remove the boring
mapping code
When
Entity to DTO
Entity to Data Contact
Entity to V...
Before and after
Mapper in Action
IoC and Mapper in C#
IoC and Mapper in C#
Upcoming SlideShare
Loading in …5
×

IoC and Mapper in C#

76,831 views

Published on

A simple slide about DI, IoC, Mapper in C#.

Published in: Software
  • Be the first to comment

IoC and Mapper in C#

  1. 1. Agenda SOLID Principles Dependency Inversion, IoC, Dependency Injection Pros and cons of Dependency Injection Apply DI frameworks into MVC project AutoMapper – What, Why and How
  2. 2. SOLID Principles • Single Responsibility • Open/Closed • Liskov Substitution • Interface Segregation • Dependency Inversion
  3. 3. Database Data Access Layer Which Depends On Business Logic Layer Which Depends On User Interface Depends on Dependencies Lower application layers External services Other components
  4. 4. Example Code
  5. 5. Dependencies Inversion (Principle) Inversion of Control (Pattern) Service Locator Event Delegate Dependency Injection
  6. 6. Example Code
  7. 7. Why Dependency Injection • Loose coupling code • Testability • Clear dependency • Separate of concern • Easy to change
  8. 8. Why NOT Dependency Injection • Hard to learn • Hard to debug • Object created before needed • More layer => More complexity
  9. 9. Simple DI Container
  10. 10. IoC in Action Unity Ninject Structure Map
  11. 11. What An “object to object” mapper Why Remove the boring mapping code When Entity to DTO Entity to Data Contact Entity to View Model
  12. 12. Before and after
  13. 13. Mapper in Action

×