Hexagonal architecture for dummies (and spring developer) @youen-chene

@saagie_io

Why hexagonal architecture?

@youen-chene

@saagie_io

Hexagonal/DDD Speaker (Jérome)

DDD & Hexagonal will save the world. 40mn to 1h57 before showing some code. No framework. Manual Bean & IoC instanciation.

@youen-chene

@saagie_io

Java/Kotlin Developer (Pierre)

No framework? it’s not real world stuff. What’s the value versus a layer architecture? Looks complicated.

@youen-chene

@saagie_io

“Parce que quand on est grand on arrête de mettre des couches” Cédric Champeau LCC#154

@youen-chene

@saagie_io

@youen_chene CTO @saagie_io Activiste : @normandyjug @codeursenseine @devoxx4kidsfr @n_w_x

Data Fabric

Data Governance

GDPR

Container Management Spark

Datanodes

Python

Keras Spring Boot

CPU

GPU

App/Dataviz

HTML, JS, CSS

Browser Server Controller

Controller

Service

DAO

Service

DAO

Service

DAO

DAO

HTML, JS, CSS

Browser Server Controller

Controller

Service

DAO = Business Rule

Service

DAO

Service

DAO

DAO

HTML, JS, CSS

Browser Server Controller

Controller

Service

DAO = Business Rule

Service

DAO

Service

DAO

DAO

HTML, JS, CSS

Browser Server Controller

Controller

Service

DAO = Piece of Business Rule

Service

DAO

Service

DAO

DAO

HTML, JS, CSS

Browser Server Controller

Controller

Service

DAO = Piece of Business Rule

Service

DAO

Service

DAO

DAO

if ($job->getCategory() == "dataviz" || $job->getCapsuleCode() == CapsuleInstance::JUPITER_CODE) { $notebookConfig = $this->managerConfig->getCapsules()->getNotebook(); return $notebookConfig->getMesostag(); } else if ($job!=null && $job->getCapsuleCode() == CapsuleInstance::SQOOP_CODE) { return "hdfs-master"; } else { return "hdfs"; }

Tackling Complexity in the Heart of Software Eric Evans 2003

@youen-chene

@saagie_io

Sexy Allistair Schema

@youen-chene

@saagie_io

Sister’ Architecture

@youen-chene

@saagie_io

Simple Hexagonal Architecture with Spring Boot

@youen-chene

@saagie_io

Let’s start by the domain

Domain

@youen-chene

@saagie_io

Let’s start by the domain

Domain

Rule 1 : no framework or lib dependency!!!!!!! @youen-chene

@saagie_io

Let’s start by the domain

Domain

Rule 2 : external call the inside @youen-chene

@saagie_io

One simple Rule

Domain

No Infra Code in the domain @youen-chene

@saagie_io

Back the domain

Domain

@youen-chene

@saagie_io

@youen-chene

@saagie_io

@youen-chene

@saagie_io

Let’s start by the domain

@youen-chene

@saagie_io

Hexagonal I/O

@youen-chene

@saagie_io

Accessing the Domain : (1) Primary Port

Classes, Functions, Methods, Service External Infrastructure call the inside

Domain Domain

(Ex: API Controller, Batch)

@youen-chene

@saagie_io

Accessing the Domain : (1) Primary Port

Classes, Functions, Methods, Service External Infrastructure call the inside

Domain Domain

(Ex: API Controller, Batch)

@youen-chene

@saagie_io

Accessing the Infrastructure Code : (2) Secondary Port

Interface

Domain Domain

Interface Implementation

Accessing/Pushing Data

@youen-chene

DB, Kafka, Rabbit, External API

@saagie_io

Accessing the Infrastructure Code : (2) Secondary Port

Interface

Domain Domain

Interface Implementation

Accessing/Pushing Data

@youen-chene

DB, Kafka, Rabbit, External API

@saagie_io

Co

nt r Ad AP olle r I ap te r

go on M DB er t ap Ad

Bo Spr ot ing Ap p

Infrastructure Code : With Adapters

Ba

tc

h

Ex ter AP nal A I d ap ter

h tc r Ba pte a Ad

Domain Domain Domain

@youen-chene

@saagie_io

Ports

Primary Port Driving Port Input Port

@youen-chene

Secondary Port Domain Domain Domain

Driven Port Output Port

@saagie_io

C o AP Ad ntro I ap lle te r r

Dirty technical shit

go on M DB er t ap Ad

Bo Spr ot ing Ap p

Infrastructure Code : With Adapters

Domain Domain Domain

Ba

tc

h

Ex ter AP nal A I d ap ter

h tc r Ba pte a Ad

Clean rule

@youen-chene

@saagie_io

Infrastructure Code : @Repository Spring Secondary Adapter MongoDB Adapter go on M B er D t ap

Ad

Domain Domain

Port (Interface)

@youen-chene

@saagie_io

Infrastructure Code : @Repository Spring Secondary Adapter MongoDB Adapter

Repository Spring bean Implements Port Kmongo as DAO

Implements method with domain, DAO and DTOs. @youen-chene

@saagie_io

Infrastructure Code : Data Transfer Object (DTO)

Mongo dependency

Boring Mapping

Boring Mapping

@youen-chene

@saagie_io

Back to Spring Boot

Domain Object

Bean @Repository class FeatureRecordsMongoRepository

DTO

KMongo @youen-chene

@saagie_io

Infrastructure Code : Spring Application Primary Adapter

Co AP Ad ntro I ap lle te r r

Bo Spr ot ing Ap p

Spring Boot App

Domain Domain @youen-chene

@saagie_io

Back to Spring Boot @SpringBootApplication class FeaturebrawlApplication

Domain Object

Instanciate

Bean @Repository class FeatureRecordsMongoRepository

DTO

KMongo @youen-chene

@saagie_io

Infrastructure Code : Spring Application Primary Adapter

Spring Boot App

Co AP Ad ntro I ap lle te r r

Bo Spr ot ing Ap p

Spring API Controller Adapter

Domain Domain @youen-chene

@saagie_io

Infrastructure Code : Spring Application Primary Adapter Spring API Controller Adapter

RestController Spring bean Inject FeatureManagement Port

Use FeatureManagement Port

@youen-chene

@saagie_io

API Calls DTO

@SpringBootApplication class FeaturebrawlApplication

Instanciate

@RestController class FeatureSpringRestController

Bean

Domain Object

Instanciate

Bean @Repository class FeatureRecordsMongoRepository

DTO

KMongo @youen-chene

@saagie_io

API Calls DTO

@SpringBootApplication class FeaturebrawlApplication

Instanciate

@RestController class FeatureSpringRestController

Bean

Domain

Domain Object

Instanciate

Bean @Repository class FeatureRecordsMongoRepository

DTO

KMongo @youen-chene

@saagie_io

@youen-chene

@saagie_io

One simple Rule

Domain

No Infra Code in the domain @youen-chene

@saagie_io

Infrastructure Code : Hack all Together

@youen-chene

@saagie_io

Infrastructure Code : Hack all Together

Service Spring bean to expose the primary port as a spring bean bean

@youen-chene

@saagie_io

Infrastructure Code : Hack all Together

So it can be injected by spring here (Rest controller primary adapter)

Service Spring bean to expose the primary port as a spring bean bean

@youen-chene

@saagie_io

Infrastructure Code : Hack all Together

Inject Repository Secondary Adapter.

@youen-chene

@saagie_io

Infrastructure Code : Hack all Together

Inject Repository Secondary Adapter. So it can use the @repository spring bean (repository primary adapter)

@youen-chene

@saagie_io

API Calls DTO

@SpringBootApplication class FeaturebrawlApplication

Instanciate

@RestController class FeatureSpringRestController

Bean

Domain Object

Instanciate

Bean @Service class FeatureManagementSpringHandler Domain Domain Object

Instanciate

Bean @Repository class FeatureRecordsMongoRepository

DTO

KMongo @youen-chene

@saagie_io

It’s a little bit crappy, no?

@youen-chene

@saagie_io

Spring Boot on it’s nominal use case Hexagonal Architecture respected Domain still clean.

@youen-chene

@saagie_io

C o AP Ad ntro I ap lle te r r

Dirty technical shit

go on M DB er t ap Ad

Bo Spr ot ing Ap p

Infrastructure Code : With Adapters

Domain Domain Domain

Ba

tc

h

Ex ter AP nal A I d ap ter

h tc r Ba pte a Ad

Clean rule

@youen-chene

@saagie_io

https://github.com/youenchene/featurebrawl

@youen-chene

@saagie_io

Pros

Cons

Clean Domain/Business Rules

DTOs make it a little heavy

Fast unit test on the domain

Developer need to be trained

Better code scalability

No starter like jHipster

@youen-chene

@saagie_io

One simple Rule

Domain

No Infra Code in the domain @youen-chene

@saagie_io

C o AP Ad ntro I ap lle te r r

Dirty technical shit

go on M DB er t ap Ad

Bo Spr ot ing Ap p

Questions?

Domain Domain Domain

Ba

tc

h

Ex ter AP nal A I d ap ter

h tc r Ba pte a Ad

Clean rule

@youen-chene

@saagie_io

Hexagonal architecture for dummies-LyonJUG.pdf

world. 40mn to 1h57 before showing. some code. No framework. Manual ... Cédric Champeau LCC#154 ... Hexagonal architecture for dummies-LyonJUG.pdf.

3MB Sizes 1 Downloads 165 Views

Recommend Documents

Vision-based hexagonal image processing based hexagonal ... - IJRIT
addresses and data of hexagonal pixels. As shown in Fig. 2, the spiral architecture is inspired from anatomical consideration of the primate's vision system.

Vision-based hexagonal image processing based hexagonal image ...
computer vision and pattern Recognition, Las Vegas, June 2006. [8] R.M. Mersereau, “The processing of Hexagonally Sampled Two-. Dimensional Signals,” Proceedings of the IEEE. 67: pp. 930 949, 1979. [9] X. He and W. Jia, “hexagonal structure for

Self-consistent calculations for n-type hexagonal SiC ...
Apr 15, 2004 - as the U-shaped trench MOSFET. Such devices are easily fabricated ... into a number of subbands, and the interface electrons exist as a quasi .... verse direction, m3 , is also given in Table I. For all except the 0001 orientation ...

Self-consistent calculations for n-type hexagonal SiC ...
Apr 15, 2004 - Ai z1 /z2. z z1 /z2 . 17. For weak inversion, when Ninv. NAzd ,. (1)(z) could be used as a next approximation to the triangular well potential.

hexagonal number tp submit
IJRIT International Journal of Research in Information Technology, Volume 3, Issue 6, June ..... Remark 5 .1: Consider the trapezoidal number (a1 b a3 a4 c a6).

Guided modes in a locally perturbed hexagonal ...
structures (perturbed on the red line). Figure 1: Schematic representation of photonic crystals. In her PhD work ([1]), E. Vasilevskaya exhibits a simple configuration where such a localization phe- nomenon occurs: this configuration is made of a rec

Isabelle Zenone_GENERIC ARCHITECTURE FOR MULTIMISSION ...
a thermal control, ... ARCHITECTURE FOR MULTIMISSION POINTING GONDOLAS.pdf ... ARCHITECTURE FOR MULTIMISSION POINTING GONDOLAS.pdf.

Architecture patterns for safe design
We have been inspired by computer science studies where design patterns have been introduced to ease software development process by allowing the reuse ...

ELF for the ARM Architecture
Jul 5, 2005 - (navigate to the ARM Software development tools section, ABI for the ARM Architecture subsection). .... http://www.sco.com/developers/gabi/2003-12- ..... LX. DCD R_ARM_GLOB_DAT(X). PLT code loads the PLTGOT entry SB- relative (§A.1). D

Isabelle Zenone_GENERIC ARCHITECTURE FOR MULTIMISSION ...
Page 2 of 2. Isabelle Zenone_GENERIC ARCHITECTURE FOR MULTIMISSION POINTING GONDOLAS.pdf. Isabelle Zenone_GENERIC ARCHITECTURE FOR ...

ELF for the ARM Architecture
Jul 5, 2005 - PLEASE READ THEM ..... PLT refers to the read-only ...... memory. Linker veneers may be needed for a number of reasons, including, but not ...

ELF for the ARM Architecture
5 Jul 2005 - 23. 4.6.1.1. Addends and PC-bias compensation. 23. 4.6.1.2. Relocation types. 24. 4.6.1.3. Static Data relocations. 29. 4.6.1.4. Static ARM relocations. 29 ... Platform architecture compatibility data (ABI format). 42. 5.3 ..... relocati

13. AN ARCHITECTURE FOR REALIZING TRANSMISSION FOR ...
AN ARCHITECTURE FOR REALIZING TRANSMISSION FOR 2_2 MIMO CHANNEL.pdf. 13. AN ARCHITECTURE FOR REALIZING TRANSMISSION FOR 2_2 ...

Architecture Architecture docx.pdf
Optional Architecture Courses. Business Information Management I (BIM). Credit: 1.0. Grade: 9-12. Counts as Technology graduation credit. Interior Design.

Automated Architecture Consistency Checking for ...
implementation, design documents, and model transformations. .... of the same stage of a software development process, e.g., comparing UML sequence.

System Architecture for Programmable Connected ...
International Conference on Embedded Wireless. Systems and Networks (EWSN) 2016 .... PhD thesis, MIT Artificial Intelligence Laboratory, 1985. [2] Allseen ...