Clean architecture
Why? How? For who?
Nicolas De Boose
CTO - beelance.io
Hexagonal
Architecture
MVP
Onion
Architecture
Use-Case
Driven Approach
(BCE)
Screaming
Architecture
https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
The typical project journey
"Web" MVC
Controller
DB
ViewModel
"Web" MVC
Controller
DB
View
fn
Model
After 1 year
of dev
1. Divide and .. keep control
API
CLI
DB
API
AMQP
AMQP
API
CLI
DB
API
AMQP
AMQP
API
CLI
DB
API
AMQP
AMQP
API
CLI
DB
API
AMQP
AMQP
API
CLI
DB
API
AMQP
AMQP
API
CLI
W S
DB
API
AMQP
AMQP
API
CLI
W S
DB
API
<i>
AMQP
AMQP
API
CLI
W S
DB
API
<i>
AMQP
AMQP
API
CLI
W S
DB
API
<i>
AMQP
AMQP
API
CLI
W S
DB
API
<i>
Primary actors Secondary actors
AMQP
AMQP
2. Keep it where it belongs
What is the most important inyour application ?
Use cases ARE the center of your application
Login
Register
Add to basket
Confirm basket
Logout
Add product
Add credit card
Search
Register
Register
Input boundary
Output boundary
Register
Input boundary
Output boundary
3. Simplify the view
• search-products.html.twig
• search-products.blade.php
• search-products.tpl
Use caseView
Use casePresenter
VM
View
Presenter
HTML
VMhtml
TwigBlade Presenter
JSON
VMjson
json_encode Presenter
CLI
VMcli
Sf consolePHP CLI
Presenter <l>
Controller
Presenter
View
Use case
Response
ViewModel
Request
Repository <l>
Repository
Implementation
DB
Entity
Model
Service
Presentation layer
Domain layer
Data layer
Presenter <l>
Controller
Presenter
View
Use case
Response
ViewModel
Request
Repository <l>
Repository
Implementation
DB
Entity
Model
Service
Presentation layer
Domain layer
Data layer
Presenter <l>
Use case
Response
Request
Repository <l>
Repository
Implementation
DB
Entity
Model
Service
Presentation layer
Domain layer
Data layer
Presenter <l>Presenter
Response
ViewModel
Repository
Implementation
DB
Presentation layer
Domain layer
Data layer
View
ViewModel
Repository
Implementation
DB
Presentation layer
Domain layer
Data layer
Conclusion
Independent of Framework
Testable
Independent of UI
Independent of Database
Independent of any external library
Structure
More classes
Need time to adapt
Be pragmatic !
https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
https://github.com/Nikoms/eco-logic
https://github.com/Nikoms/clean-architecture-example
http://www.mechantblog.com
http://www.beelance.io
Merci
https://joind.in/talk/ad08d
@NicoDeBoose
Bonus slides
Afupday lille-2020
Afupday lille-2020
Afupday lille-2020

Afupday lille-2020