Hexagonal Architecture 2 -...
Transcript of Hexagonal Architecture 2 -...
![Page 1: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/1.jpg)
Hexagonal ArchitecturePorts & Adapters
![Page 2: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/2.jpg)
Waarom architectuur?
![Page 3: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/3.jpg)
Vanwege onderhoudbaarheid
![Page 4: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/4.jpg)
“Allow an application to equally be driven by users, programs, automated test or batch scripts, and to be developed and tested in isolation from its eventual
run-time devices and databases.”- Alistair Cockburn
Hexagonal architecture
![Page 5: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/5.jpg)
“Allow an application to equally be driven by users, programs, automated test or batch scripts”
• Business logica loskoppelen van de input context
• Bijv. CLI, Web, API
Hexagonal architecture
![Page 6: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/6.jpg)
“and to be developed and tested in isolation from its eventual run-time devices and databases.”
• “Run-time devices” loskoppelen van de applicatie
• Bijv. database-, storage- en notificatie mechanismes
Hexagonal architecture
![Page 7: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/7.jpg)
Infrastructure
Application
• Domain
• Application
• Infrastructure Domain
Persistence
Doctrine, DBAL, API
UI
CLI, Web, API
Notifications
E-mail, SMS, Push
Storage
Filesystem, AmazonS3
Lagen in Hexagonal architecture
![Page 8: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/8.jpg)
Infrastructure
Application
• Lagen mogen alleen met onderliggende lagen communiceren
• Infrastructure > Application & Domain
• Application > Domain
• Domain
“Dependency” regel
Domain
UI
CLI, Web, API
Persistence
Doctrine, DBAL, API
![Page 9: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/9.jpg)
1. High-level modules mogen niet afhankelijk zijn van low-level modules, beiden zouden afhankelijk moeten zijn van abstracties
2. Abstracties mogen niet afhankelijk zijn van details, details moeten afhankelijk zijn van abstracties
Dependency inversion principle
![Page 10: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/10.jpg)
Dependency inversion principle
UploadImage class
upload()
FilesystemStorage class
storeToDisk()
UploadImage class
upload()
FileStorageinterface
store()
FilesystemStorageclass
store()
AmazonS3Storageclass
store()
![Page 11: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/11.jpg)
Infrastructure
Application
• Infrastructure > CLI > ChangeStatus
• Application > ChangeStatusValidator &ChangeStatusHandler
• Domain > Status
• Domain > StatusRepositoryInterface
• Infrastructure > Persistence > FilesystemStatusRepository
Applicatie flow
Domain
UI
CLI
Persistence
Filesystem
![Page 12: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/12.jpg)
Demo
![Page 13: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by](https://reader035.fdocuments.net/reader035/viewer/2022062506/5f8f1c33fcaa4a5a3265bd2b/html5/thumbnails/13.jpg)
linkedin.com/in/marcoveenendaal