Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Application Layer

Matthew Renze
SOFTWARE CONSULTANT

@matthewrenze www.matthewrenze.com
Overview Application Layer
Dependency Inversion Principle
Pros and Cons
Demo
What Are Layers?

Levels of abstraction
Single-responsibility
Isolate roles and skills
Multiple implementations
Varying rates of change
Classic Three-layer Architecture

Users

User Interface

Business Logic

Data Access

Database

Dependency
Modern Four-layer Architecture

Users

Presentation

Cross-Cutting Concerns
Application

Domain

Persistence Infrastructure

Database OS

Dependency
Application Layer

Users
Implements use cases
Presentation

Cross-Cutting Concerns
High-level application logic
Application
Knows about the domain
Domain
No knowledge of other layers
Persistence Infrastructure
Contains interfaces
Database OS

Dependency
Layer Dependencies

Users

Dependency inversion Presentation

Cross-Cutting Concerns
Inversion of control Application

Independent deployability Domain

Flexible and maintainable Persistence Infrastructure

Database OS

Flow of control Dependency


Users

Presentation

SalesController

Cross-cutting concerns
Application
ICreateSaleCommand

IDateService

DateService
CreateSaleCommand

IDatabaseService IInventoryService

Domain

Sale

Persistence Infrastructure
DatabaseService InventoryService
Composition
Implements
Database OS
Why Use an Application Layer

Users

Pros Presentation

Cross-Cutting Concerns
Focus on use cases Application

Easy to understand Domain

Follows DIP Persistence Infrastructure

Database OS
Why Use an Application Layer

Pros Cons
Focus on use cases Additional layer cost
Easy to understand Requires extra thought
Follows DIP IoC is counter-intuitive
Set Up
Show Application Project
Show SalesController Class
Show ICreateSaleCommand Interface
Show Create Sale Model
Show CreateSaleCommand Class (Part 1)
Show CreateSaleCommand Class (Part 2)
Show IDatabaseService Interface
Show DatabaseService Class
Other Dependencies
Wrap Up
Summary Application Layer
Dependency Inversion Principle
Pros and Cons
Demo

You might also like