SlideShare a Scribd company logo
ADVANCED
APPLICATION
ARCHITECTURE
I - Layers
Matthias Noback
@matthiasnoback
MATERIALS
ARE ON
TWITTER
https://twitter.com/
matthiasnoback
matthiasnoback/

layers-ports-and-adapters-
workshop
Clone from GitHub
docker-compose pull
bin/composer.sh install
docker-compose up -d
DEMO TIME
Navigate to localhost (or localhost:8080)
ARCHITECTURE
Decisions about coupling and cohesion
COUPLING
How are things linked to each other?
COHESION
Which things belong together?
LAYERED ARCHITECTURE
An answer to both questions
LAYERS
Help you protect what's in a deeper layer
LAYERS
Allow you to define dependency rules
LAYERS
Define the right place to put things
TRADITIONAL LAYERING
MVC
view
controller
model
TRADITIONAL LAYERING
Works well with JS
view
model
data
LAYERS
Horizontal division (as opposed to...)
USE CASES
Vertical division
COHESION
A basic set of layers
infrastructure
application
domain
COUPLING
The dependency rule
Layers should only depend on deeper layers
COUPLING
The dependency rule
infrastructure
application
domain
COUPLING
Dependency inversion principle
Classes should always depend on things that are more abstract
COUPLING
Dependency inversion principle
low-levelconcrete class specific
abstract interface generic high-level
COUPLING
Dependency inversion principle
use
COUPLING
Dependency inversion principle
use implement
COUPLING
Is about dependencies in code
Use Dependency Injection
LAYER CONVENTIONS
Domain layer
Domain model:
➤ Entities
➤ Value objects
➤ Domain services
➤ Factories
Business logic
Decisions
Data
State
Behavior
LAYER CONVENTIONS
Application layer
➤ Find an object
➤ Change something
➤ Notify something
➤ Get some information
Use cases
Orchestration
LAYER CONVENTIONS
Infrastructure layer
Communication with:
➤ HTTP client
➤ Database
➤ Filesystem
➤ Email server
➤ Message broker
Connecting the
application to
the world
outside
MATTHIASNOBACK/LAYERS-
PORTS-AND-ADAPTERS-
WORKSHOP
Assignments are on GitHub in assignments/
php -S 0.0.0.0:8080 -t public/
assignment/01.md
Layers
ADVANCED
APPLICATION
ARCHITECTURE
II - Ports & adapters
MESSAGING
... is the big idea
PORTS (COHESION)
Web, CLI, test client, messages, database queries
User interface
Persistence
PORTS... AND ADAPTERS
Translation
HTTP
SQL
HEXAGONAL ARCHITECTURE
Same thing!
User interface
Persistence
PORTS... AND ADAPTERS
(De)serialization, translation, structural validation
HTTP
SQL
assignment/02.md
Ports
PORT ADAPTERS
...in the Infrastructure layer
APPLICATION SERVICES
... in the Application layer
DOMAIN MODEL
in the Domain layer
APPLICATION SERVICES
Delivery-mechanism agnostic
assignment/03.md
Input adapters
APPLICATION SERVICES
Most often they are "command handlers"
Command object is a DTO
Represents a user's intention
Contains primitive-type values
APPLICATION SERVICES
Translate, and orchestrate
From primitive-type values to rich domain objects
Manipulates an entity
Persists it
May dispatch events
VALIDATION
At different levels
Structural validation of messages
User-friendly input validation
Domain invariant protection
STRUCTURAL VALIDATION
Infrastructure layer
Form keys
JSON schema
USER-FRIENDLY INPUT
VALIDATION
Infrastructure layer
Usability concern
Prevent problems later on
Localized, translated
Friendly
DOMAIN INVARIANT PROTECTION
Application & Domain layer
Domain objects: always valid
Valid state
Valid state transitions
assignment/04.md
Input validation
APPLICATION SERVICES
Transactional consistency
assignment/05.md
Output adapter
INCOMPLETE ENTITY
A Meetup without an ID...
DATABASE-GENERATED ID
Faux-auto increment (check out the code)
ALTERNATIVE: UUID
Universally Unique Identifier
7d7fd0b2-0cb5-42ac-b697-3f7bfce24df9
assignment/06.md
A hidden dependency on the persistence mechanism
ALTERNATIVE: SEQUENCE
MeetupId encapsulates the type of ID used
ADVANTAGES OF USING LAYERS, 

PORTS & ADAPTERS
Offers insight into the application
Provides a useful convention for the team
Isolates the low-level details
Allows for alternative implementations
Helps with testing
ADVANCED
APPLICATION
ARCHITECTURE
III - Testing
UNIT TESTS
Testing your units of code
One class at a time
No IO
No setup required
Mocking only dependencies "you own"
INTEGRATION TESTS
Testing your adapters
Maybe multiple classes
Including IO
Some setup required
Mocking no dependencies
ACCEPTANCE TESTS
Testing your application services
Multiple classes
Use cases
Infrastructure stand-ins
SYSTEM TESTS
Testing your application end-to-end
The real deal
TESTING PYRAMID
Make it well-balanced
Unit
Integration
System
Acceptance
Development
Regression
TESTING PYRAMID
Make it well-balanced
Supports development
Prevents regressionSlow, brittle
Fast, stable
Proof of effectiveness
Proof of Correctness
assignment/07.md
Different types of tests
ACCEPTANCE TESTS
Use infrastructure stand-ins
Acceptance test
test the
application
layer
Persistence
FileBased InMemory
Port
Adapters
MeetupRepository
FileBasedMeetupRepository InMemoryMeetupRepository
Domain
Infrastructure
implements implements
assignment/08.md
A test double for the Persistence port
assignment/09.md
An acceptance test for the application layer
A WELL-BALANCED TEST SUITE
Adapters can be easily replaced
Test suite is fast
Feedback is quick
Small amount of fragile tests
Enables continuous delivery
https://training.matthiasnoback.nl/
Feedback?
@matthiasnoback
training.matthiasnoback.nl
assignment/10.md
Notifications

More Related Content

What's hot (20)

PPTX
31 days Refactoring
Ahasanul Kalam Akib
 
PDF
Tactical DDD (just better OOP?) - PHPBenelux 2017
Matthias Noback
 
PDF
Reactive programming - Observable
Dragos Ionita
 
PDF
How to create fast and much more efficient database
shivang tyagi
 
PPTX
Domain Driven Design in Rails
Hans Yu
 
PDF
React + Mobile
antriss
 
PPTX
Asp.net c# MVC-5 Training-Day-1 of Day-9
AHM Pervej Kabir
 
PPTX
Functional reactive programming
Ahmed Kamel Taha
 
PPT
Building Reactive webapp with React/Flux
Keuller Magalhães
 
PDF
Intro to ember.js
Leo Hernandez
 
PDF
Introduce flux & react in practice
Hsuan Fu Lien
 
PPTX
Utilize Flex And Java Servlet To Implement File Upload
Guo Albert
 
PDF
Reflection
Marcus Denker
 
PPT
Architectural peripherals of react by Vadym Zhiltsov
Lohika_Odessa_TechTalks
 
PPTX
Ajax
amitmishra43258
 
PDF
Angular - Chapter 9 - Authentication and Authorization
WebStackAcademy
 
PPT
zigbee
mahamad juber
 
PPT
Flux architecture
Badr Zaman [Front End , J2EE ]
 
PPTX
Flux and React.js
sara stanford
 
PPTX
C# advanced topics and future - C#5
Peter Gfader
 
31 days Refactoring
Ahasanul Kalam Akib
 
Tactical DDD (just better OOP?) - PHPBenelux 2017
Matthias Noback
 
Reactive programming - Observable
Dragos Ionita
 
How to create fast and much more efficient database
shivang tyagi
 
Domain Driven Design in Rails
Hans Yu
 
React + Mobile
antriss
 
Asp.net c# MVC-5 Training-Day-1 of Day-9
AHM Pervej Kabir
 
Functional reactive programming
Ahmed Kamel Taha
 
Building Reactive webapp with React/Flux
Keuller Magalhães
 
Intro to ember.js
Leo Hernandez
 
Introduce flux & react in practice
Hsuan Fu Lien
 
Utilize Flex And Java Servlet To Implement File Upload
Guo Albert
 
Reflection
Marcus Denker
 
Architectural peripherals of react by Vadym Zhiltsov
Lohika_Odessa_TechTalks
 
Angular - Chapter 9 - Authentication and Authorization
WebStackAcademy
 
Flux and React.js
sara stanford
 
C# advanced topics and future - C#5
Peter Gfader
 

Similar to Advanced Application Architecture Symfony Live Berlin 2018 (20)

PPTX
Enabling multi tenancy(An Industrial Experience Report)
ICSM 2010
 
PPT
Interoperability and Windows Communication Foundation (WCF) Overview
Jorgen Thelin
 
PPT
Modern Database Development Oow2008 Lucas Jellema
Lucas Jellema
 
PPT
Linq To The Enterprise
Daniel Egan
 
PPTX
J2EE pattern 5
Naga Muruga
 
PPTX
Stephane Lapointe & Alexandre Brisebois: Développer des microservices avec Se...
MSDEVMTL
 
PPT
Oo Design And Patterns
Anil Bapat
 
PPTX
Docker, cornerstone of cloud hybridation ? [Cloud Expo Europe 2016]
Adrien Blind
 
PDF
L03 Software Design
Ólafur Andri Ragnarsson
 
PPT
Web Services: Encapsulation, Reusability, and Simplicity
hannonhill
 
PDF
Building High Scalability Apps With Terracotta
David Reines
 
PDF
Stucorner dot-net-training-syllabus
STUCORNER technology
 
DOCX
Framework 4
Rajesh Kumar Ranjan
 
PPTX
Hybrid - Seguridad en Contenedores v3.pptx
HansFarroCastillo1
 
PPTX
CTU June 2011 - Windows Azure App Fabric
Spiffy
 
PPTX
Day6
madamewoolf
 
PPTX
Decomposing the Monolith using modern-day .NET and a touch of microservices
Dennis Doomen
 
PPTX
Unleash software architecture leveraging on docker
Adrien Blind
 
PPT
Linq 1224887336792847 9
google
 
PPT
Distributed Programming using RMI
backdoor
 
Enabling multi tenancy(An Industrial Experience Report)
ICSM 2010
 
Interoperability and Windows Communication Foundation (WCF) Overview
Jorgen Thelin
 
Modern Database Development Oow2008 Lucas Jellema
Lucas Jellema
 
Linq To The Enterprise
Daniel Egan
 
J2EE pattern 5
Naga Muruga
 
Stephane Lapointe & Alexandre Brisebois: Développer des microservices avec Se...
MSDEVMTL
 
Oo Design And Patterns
Anil Bapat
 
Docker, cornerstone of cloud hybridation ? [Cloud Expo Europe 2016]
Adrien Blind
 
L03 Software Design
Ólafur Andri Ragnarsson
 
Web Services: Encapsulation, Reusability, and Simplicity
hannonhill
 
Building High Scalability Apps With Terracotta
David Reines
 
Stucorner dot-net-training-syllabus
STUCORNER technology
 
Framework 4
Rajesh Kumar Ranjan
 
Hybrid - Seguridad en Contenedores v3.pptx
HansFarroCastillo1
 
CTU June 2011 - Windows Azure App Fabric
Spiffy
 
Decomposing the Monolith using modern-day .NET and a touch of microservices
Dennis Doomen
 
Unleash software architecture leveraging on docker
Adrien Blind
 
Linq 1224887336792847 9
google
 
Distributed Programming using RMI
backdoor
 
Ad

More from Matthias Noback (20)

PDF
Rector fireside chat - PHPMiNDS meetup
Matthias Noback
 
PDF
Service abstractions - Part 1: Queries
Matthias Noback
 
PDF
Hexagonal Symfony - SymfonyCon Amsterdam 2019
Matthias Noback
 
PDF
Advanced web application architecture - PHP Barcelona
Matthias Noback
 
PDF
A testing strategy for hexagonal applications
Matthias Noback
 
PDF
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...
Matthias Noback
 
PDF
Layers, ports and adapters
Matthias Noback
 
PDF
Beyond design principles and patterns (muCon 2019 edition)
Matthias Noback
 
PDF
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Matthias Noback
 
PDF
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Matthias Noback
 
PDF
Beyond Design Principles and Patterns
Matthias Noback
 
PDF
Designing for Autonomy
Matthias Noback
 
PDF
Docker workshop
Matthias Noback
 
PDF
Docker swarm workshop
Matthias Noback
 
PDF
Docker compose workshop
Matthias Noback
 
PDF
Building autonomous services
Matthias Noback
 
PDF
Designing for autonomy
Matthias Noback
 
PDF
Continously delivering containerized microservices
Matthias Noback
 
PDF
Apprendre le français
Matthias Noback
 
PDF
Living Documentation (presentation)
Matthias Noback
 
Rector fireside chat - PHPMiNDS meetup
Matthias Noback
 
Service abstractions - Part 1: Queries
Matthias Noback
 
Hexagonal Symfony - SymfonyCon Amsterdam 2019
Matthias Noback
 
Advanced web application architecture - PHP Barcelona
Matthias Noback
 
A testing strategy for hexagonal applications
Matthias Noback
 
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...
Matthias Noback
 
Layers, ports and adapters
Matthias Noback
 
Beyond design principles and patterns (muCon 2019 edition)
Matthias Noback
 
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Matthias Noback
 
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Matthias Noback
 
Beyond Design Principles and Patterns
Matthias Noback
 
Designing for Autonomy
Matthias Noback
 
Docker workshop
Matthias Noback
 
Docker swarm workshop
Matthias Noback
 
Docker compose workshop
Matthias Noback
 
Building autonomous services
Matthias Noback
 
Designing for autonomy
Matthias Noback
 
Continously delivering containerized microservices
Matthias Noback
 
Apprendre le français
Matthias Noback
 
Living Documentation (presentation)
Matthias Noback
 
Ad

Recently uploaded (20)

PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Human Resources Information System (HRIS)
Amity University, Patna
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 

Advanced Application Architecture Symfony Live Berlin 2018