You are on page 1of 15

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
SOLID Principles
• Single Responsibility
• Open/Closed
• Liskov Substitution
• Interface Segregation
• Dependency Inversion
Dependencies
Lower application layers
External services
Other components

User Interface

Depends on

Business Logic Layer

Which Depends On

Data Access Layer

Which Depends On

Database
Example Code
Dependencies Inversion (Principle)

Inversion of Control (Pattern)

Dependency
Service Locator Event Delegate
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 View Model
Before and after
Mapper in Action

You might also like