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.
ADVANCED
APPLICATION
ARCHITECTURE
I - Layers
Matthias Noback
@matthiasnoback
matthiasnoback/

layers-ports-and-adapters-
workshop
Clone from GitHub
docker-compose pull
bin/composer.sh install
docker-...
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
view
model
data
LAYERS
Horizontal division (as opposed to...)
USE CASES
Vertical division
LAYERS
Rendered as circles
CLEAN ARCHITECTURE
Or "union" architecture
COHESION
A basic set of layers
infrastructure
application
domain
COUPLING
The dependency rule
Layers should only depend on deeper layers
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
Decis...
LAYER CONVENTIONS
Application layer
➤ Find an object
➤ Change something
➤ Notify something
➤ Get some information
Use case...
LAYER CONVENTIONS
Infrastructure layer
Communication with:
➤ HTTP client
➤ Database
➤ Filesystem
➤ Email server
➤ Message ...
MATTHIASNOBACK/LAYERS-
PORTS-AND-ADAPTERS-
WORKSHOP
Assignments are on GitHub in assignments/
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
VALIDATION
At different levels
Structural validation of messages
User-friendly input validation
Domain invariant protection
assignment/04.md
Input validation
APPLICATION SERVICES
Transactional consistency
assignment/05.md
Output adapter
assignment/06.md
A hidden dependency on the persistence mechanism
ADVANTAGES OF USING LAYERS, 

PORTS & ADAPTERS
Offers insight into the application
Isolates the low-level details
Allows f...
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
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 te...
assignment/10.md
Notifications
https://training.matthiasnoback.nl/
https://joind.in/talk/b1763
Feedback?
Upcoming SlideShare
Loading in …5
×

of

Advanced application architecture Slide 1 Advanced application architecture Slide 2 Advanced application architecture Slide 3 Advanced application architecture Slide 4 Advanced application architecture Slide 5 Advanced application architecture Slide 6 Advanced application architecture Slide 7 Advanced application architecture Slide 8 Advanced application architecture Slide 9 Advanced application architecture Slide 10 Advanced application architecture Slide 11 Advanced application architecture Slide 12 Advanced application architecture Slide 13 Advanced application architecture Slide 14 Advanced application architecture Slide 15 Advanced application architecture Slide 16 Advanced application architecture Slide 17 Advanced application architecture Slide 18 Advanced application architecture Slide 19 Advanced application architecture Slide 20 Advanced application architecture Slide 21 Advanced application architecture Slide 22 Advanced application architecture Slide 23 Advanced application architecture Slide 24 Advanced application architecture Slide 25 Advanced application architecture Slide 26 Advanced application architecture Slide 27 Advanced application architecture Slide 28 Advanced application architecture Slide 29 Advanced application architecture Slide 30 Advanced application architecture Slide 31 Advanced application architecture Slide 32 Advanced application architecture Slide 33 Advanced application architecture Slide 34 Advanced application architecture Slide 35 Advanced application architecture Slide 36 Advanced application architecture Slide 37 Advanced application architecture Slide 38 Advanced application architecture Slide 39 Advanced application architecture Slide 40 Advanced application architecture Slide 41 Advanced application architecture Slide 42 Advanced application architecture Slide 43 Advanced application architecture Slide 44 Advanced application architecture Slide 45 Advanced application architecture Slide 46 Advanced application architecture Slide 47 Advanced application architecture Slide 48 Advanced application architecture Slide 49 Advanced application architecture Slide 50 Advanced application architecture Slide 51 Advanced application architecture Slide 52 Advanced application architecture Slide 53 Advanced application architecture Slide 54 Advanced application architecture Slide 55 Advanced application architecture Slide 56 Advanced application architecture Slide 57 Advanced application architecture Slide 58 Advanced application architecture Slide 59 Advanced application architecture Slide 60
Upcoming SlideShare
Defensive Coding Crash Course - ZendCon 2017
Next
Download to read offline and view in fullscreen.

7 Likes

Share

Download to read offline

Advanced application architecture

Download to read offline

In this workshop we'll take a slice of a pretty standard PHP project and gradually work our way towards an application that has a better architecture. "Better" meaning that:

It will be easy to find out what the uses cases of the application are ("screaming architecture")
It will be easy to find a place for every piece of the application ("layers")
It will be easy to find out how users and other systems can interact with it ("ports & adapters")
It will be easy to provide tests and automated acceptance criteria for it ("the testing pyramid")
I'm sure you would like your project to have these properties! I'll show you all the little steps that will help you transform your application to this new level.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Advanced application architecture

  1. 1. ADVANCED APPLICATION ARCHITECTURE I - Layers Matthias Noback @matthiasnoback
  2. 2. matthiasnoback/
 layers-ports-and-adapters- workshop Clone from GitHub docker-compose pull bin/composer.sh install docker-compose up -d
  3. 3. ARCHITECTURE Decisions about coupling and cohesion
  4. 4. COUPLING How are things linked to each other?
  5. 5. COHESION Which things belong together?
  6. 6. LAYERED ARCHITECTURE An answer to both questions
  7. 7. LAYERS Help you protect what's in a deeper layer
  8. 8. LAYERS Allow you to define dependency rules
  9. 9. LAYERS Define the right place to put things
  10. 10. TRADITIONAL LAYERING view model data
  11. 11. LAYERS Horizontal division (as opposed to...)
  12. 12. USE CASES Vertical division
  13. 13. LAYERS Rendered as circles
  14. 14. CLEAN ARCHITECTURE Or "union" architecture
  15. 15. COHESION A basic set of layers infrastructure application domain
  16. 16. COUPLING The dependency rule Layers should only depend on deeper layers
  17. 17. COUPLING Dependency inversion principle Classes should always depend on things that are more abstract
  18. 18. COUPLING Dependency inversion principle low-levelconcrete class specific abstract interface generic high-level
  19. 19. COUPLING Dependency inversion principle use
  20. 20. COUPLING Dependency inversion principle use implement
  21. 21. COUPLING Is about dependencies in code Use Dependency Injection
  22. 22. LAYER CONVENTIONS Domain layer Domain model: ➤ Entities ➤ Value objects ➤ Domain services ➤ Factories Business logic Decisions Data State Behavior
  23. 23. LAYER CONVENTIONS Application layer ➤ Find an object ➤ Change something ➤ Notify something ➤ Get some information Use cases Orchestration
  24. 24. LAYER CONVENTIONS Infrastructure layer Communication with: ➤ HTTP client ➤ Database ➤ Filesystem ➤ Email server ➤ Message broker Connecting the application to the world outside
  25. 25. MATTHIASNOBACK/LAYERS- PORTS-AND-ADAPTERS- WORKSHOP Assignments are on GitHub in assignments/
  26. 26. assignment/01.md Layers
  27. 27. ADVANCED APPLICATION ARCHITECTURE II - Ports & adapters
  28. 28. MESSAGING ... is the big idea
  29. 29. PORTS (COHESION) Web, CLI, test client, messages, database queries User interface Persistence
  30. 30. PORTS... AND ADAPTERS Translation HTTP SQL
  31. 31. HEXAGONAL ARCHITECTURE Same thing! User interface Persistence
  32. 32. PORTS... AND ADAPTERS (De)serialization, translation, structural validation HTTP SQL
  33. 33. assignment/02.md Ports
  34. 34. PORT ADAPTERS ...in the Infrastructure layer
  35. 35. APPLICATION SERVICES ... in the Application layer
  36. 36. DOMAIN MODEL in the Domain layer
  37. 37. APPLICATION SERVICES Delivery-mechanism agnostic
  38. 38. assignment/03.md Input adapters
  39. 39. VALIDATION At different levels Structural validation of messages User-friendly input validation Domain invariant protection
  40. 40. assignment/04.md Input validation
  41. 41. APPLICATION SERVICES Transactional consistency
  42. 42. assignment/05.md Output adapter
  43. 43. assignment/06.md A hidden dependency on the persistence mechanism
  44. 44. ADVANTAGES OF USING LAYERS, 
 PORTS & ADAPTERS Offers insight into the application Isolates the low-level details Allows for alternative implementations Helps with testing
  45. 45. ADVANCED APPLICATION ARCHITECTURE III - Testing
  46. 46. UNIT TESTS Testing your units of code One class at a time No IO No setup required Mocking only dependencies "you own"
  47. 47. INTEGRATION TESTS Testing your adapters Maybe multiple classes Including IO Some setup required Mocking no dependencies
  48. 48. ACCEPTANCE TESTS Testing your application services Multiple classes Use cases Infrastructure stand-ins
  49. 49. SYSTEM TESTS Testing your application end-to-end The real deal
  50. 50. TESTING PYRAMID Make it well-balanced Unit Integration System Acceptance
  51. 51. assignment/07.md Different types of tests
  52. 52. ACCEPTANCE TESTS Use infrastructure stand-ins Acceptance test test the application layer
  53. 53. Persistence FileBased InMemory Port Adapters
  54. 54. MeetupRepository FileBasedMeetupRepository InMemoryMeetupRepository Domain Infrastructure implements implements
  55. 55. assignment/08.md A test double for the Persistence port
  56. 56. assignment/09.md An acceptance test for the application layer
  57. 57. 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
  58. 58. assignment/10.md Notifications
  59. 59. https://training.matthiasnoback.nl/
  60. 60. https://joind.in/talk/b1763 Feedback?
  • RebeccaMontoya1

    Dec. 1, 2021
  • powerirs

    Dec. 15, 2019
  • Decano1

    May. 3, 2018
  • Gudimetla

    Feb. 23, 2018
  • AlessandroFrangioni1

    Nov. 26, 2017
  • andoniz

    Nov. 1, 2017
  • nikolaizujev

    Oct. 26, 2017

In this workshop we'll take a slice of a pretty standard PHP project and gradually work our way towards an application that has a better architecture. "Better" meaning that: It will be easy to find out what the uses cases of the application are ("screaming architecture") It will be easy to find a place for every piece of the application ("layers") It will be easy to find out how users and other systems can interact with it ("ports & adapters") It will be easy to provide tests and automated acceptance criteria for it ("the testing pyramid") I'm sure you would like your project to have these properties! I'll show you all the little steps that will help you transform your application to this new level.

Views

Total views

2,011

On Slideshare

0

From embeds

0

Number of embeds

117

Actions

Downloads

88

Shares

0

Comments

0

Likes

7

×