Top Banner
Hexagonal Architecture Ports & Adapters
13

Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by

Aug 04, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Hexagonal Architecture 2 - CanWeDoThiscanwedothis.com/wp-content/uploads/2017/10/Hexagonal-Architectu… · Hexagonal architecture “Allow an application to equally be driven by

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

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

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

“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

“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

“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

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

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

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

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

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

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

linkedin.com/in/marcoveenendaal