Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
ADVANCED
APPLICATION
ARCHITECTURE
I - Layers
Matthias Noback
@matthiasnoback
matthiasnoback/layers-
ports-and-adapters-
workshop
Clone from GitHub
Follow the instructions in README.md
ARCHITECTURE
Decisions about coupling and cohesion
COUPLING
How are things linked to each other?
COHESION
Which things belong together?
COHESION
Which things belong together?
www.youtube.com/watch?v=N_7DPyxzUzc
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
domain
application
infrastructure
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 ...
assignment/01.md
Layers
ADVANCED
APPLICATION
ARCHITECTURE
II - Ports & adapters
MESSAGING
... is the big idea
PORTS (COHESION)
Web, CLI, test client, messages, database queries
Web
Database
PORTS... AND ADAPTERS
Translation
HTTP
SQL
HEXAGONAL ARCHITECTURE
Same thing!
Web
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 

PORTS & ADAPTERS
Offers insight into the application
Isolates the low-level details
Allows for alternative...
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 tests
Integration tests
System
tests
assignment/07.md
Different types of tests
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...
Prochain SlideShare
Chargement dans…5
×

Advanced Application Architecture (workshop slides)

473 vues

Publié le

Workshop slides (https://training.matthiasnoback.nl/)

Publié dans : Logiciels
  • Soyez le premier à commenter

Advanced Application Architecture (workshop slides)

  1. 1. ADVANCED APPLICATION ARCHITECTURE I - Layers Matthias Noback @matthiasnoback
  2. 2. matthiasnoback/layers- ports-and-adapters- workshop Clone from GitHub Follow the instructions in README.md
  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. COHESION Which things belong together? www.youtube.com/watch?v=N_7DPyxzUzc
  7. 7. LAYERED ARCHITECTURE An answer to both questions
  8. 8. LAYERS Help you protect what's in a deeper layer
  9. 9. LAYERS Allow you to define dependency rules
  10. 10. LAYERS Define the right place to put things
  11. 11. TRADITIONAL LAYERING view model data
  12. 12. LAYERS Horizontal division (as opposed to...)
  13. 13. USE CASES Vertical division
  14. 14. LAYERS Rendered as circles
  15. 15. CLEAN ARCHITECTURE Or "union" architecture
  16. 16. COHESION A basic set of layers domain application infrastructure
  17. 17. COUPLING The dependency rule Layers should only depend on deeper layers
  18. 18. COUPLING Dependency inversion principle Classes should always depend on things that are more abstract
  19. 19. COUPLING Dependency inversion principle low-levelconcrete class specific abstract interface generic high-level
  20. 20. COUPLING Dependency inversion principle use
  21. 21. COUPLING Dependency inversion principle use implement
  22. 22. COUPLING Is about dependencies in code Use Dependency Injection
  23. 23. LAYER CONVENTIONS Domain layer Domain model: ➤ Entities ➤ Value objects ➤ Domain services ➤ Factories Business logic Decisions Data State Behavior
  24. 24. LAYER CONVENTIONS Application layer ➤ Find an object ➤ Change something ➤ Notify something ➤ Get some information Use cases Orchestration
  25. 25. LAYER CONVENTIONS Infrastructure layer Communication with: ➤ HTTP client ➤ Database ➤ Filesystem ➤ Email server ➤ Message broker Connecting the application to the world outside
  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 Web Database
  30. 30. PORTS... AND ADAPTERS Translation HTTP SQL
  31. 31. HEXAGONAL ARCHITECTURE Same thing! Web 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 
 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 tests Integration tests System tests
  51. 51. assignment/07.md Different types of tests
  52. 52. assignment/08.md A test double for the Persistence port
  53. 53. assignment/09.md An acceptance test for the application layer
  54. 54. 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

×