SlideShare ist ein Scribd-Unternehmen logo
1 von 48
Downloaden Sie, um offline zu lesen
API/
Hi, I'm Victor Rentea
Java Champion – drinking since 2006
Trainer – 3000+ devs / 80+ companies, since 2013
Speaker – Conferences & Meetups
Hibernate
Spring Java8/FP
Java Performance Secure Coding
Reactive
Architecture Clean Code Unit Testing
$
Hibernate
Spring Java8/FP
Architecture Clean Code Unit Testing
Masterclass
Company
Training
Video
Courses
YouTube
Channel
💗 Join My
Community
Blog
@victorrentea
VictorRentea.ro
victorrentea@gmail.com
Java Performance Secure Coding
Reactive
172 VictorRentea.ro
a training by
Chapter 1. Data Structures
173 VictorRentea.ro
a training by
Can I have a chicken?
The data structure they send you
The data structure you want to use in your core logic
DTO
domain
Object
175 VictorRentea.ro
a training by
DTOs*
are Evil
*Data Transfer Objects – data structures that move across APIs
176 VictorRentea.ro
a training by
☢ Beware of Foreign Data Structures ☢
➢ Bloated (more fields than you need)
➢ Flat
➢ Different perspective 🐔 (bounded context)
➢ Fixed design (often generated or in client-lib)
➢ Mutable (pain from frameworks otherwise)
➢ No constraints (nulls, validation, invariants)
➢ Diverging in time (v2)
We 💗 small, cohesive data structures
We 💗 Logic next to data (OOP)
We 💗 Immutable objects
We 💗 Deep, Rich Domain Model
We 💗 Models to guard their invariants
We want control over our structures
Because DTOs are: In our core logic:
We 💗 Structures tailored to our problem
177 Š VictorRentea.ro
a training by
Don't implement complex logic
on foreign data structures
Elders Wisdom
What's complex?
What's foreign?
178 VictorRentea.ro
a training by
Bounded Context A
(TeamA)
The Curious Case of Nanoservices
DTOs can be shared
within the same Bounded Context (team)
=tiny microservice
eg. 5 devs maintaining
20 microservices
1
2
3
Bounded Context B
(TeamB)
X
But not with others
What's foreign?
179 VictorRentea.ro
a training by
⚠ Returning entities as JSON ⚠
➢ Couples your clients to your internal entity structure
➢ Is risky to marshal
and of course...
180 VictorRentea.ro
a training by
Decouple
DTO
Domain
Model
< >
Price: more classes + more mapping
Exception:
Boundary Systems
= Huge Adapters without own Domain
Software Ecosystem
A
- Manually Crafted DTO
- Generated DTOs:
XML: .xsd/.wsdl ➔ xjc
JSON: .yaml ➔ swagger-gen
Auto-Generated
Mappers
181 VictorRentea.ro
a training by
Auto-Generated Mappers
Converting Entity  DTO with
as long as the field names match,
mapping happens automatically
eg MapStruct
Temptation to keep the models in sync
Entities and DTOs must be allowed to diverge
Customer.firstName  CustomerDto.firstName
War Stories: When mapping gets complex, deep knowledge of MapStruct is required
➔ Consider switching to manual mapping (simpler) ?
182 Š VictorRentea.ro
a training by
Don't implement complex logic
on foreign data structures
Elders Wisdom
183 VictorRentea.ro
a training by
Chapter 2. Logic
184 VictorRentea.ro
a training by
you
185 VictorRentea.ro
a training by
The Code - anonymous developer
186 VictorRentea.ro
a training by
Layers
SUB-DOMAINS
Controller
Service
Repository
APIs
order Product user
customer
API
infrastructure
too complex ➔
187 VictorRentea.ro
a training by
Layers
Controller
Repository
APIs
Facade / Application Service
Layered Architecture
DOMAIN Service
188 VictorRentea.ro
a training by
Controller
Repository
call
direction
pull orchestration up,
let Repos trivial
Relaxed Layered Architecture
allows skipping layers
Layered Architecture
DOMAIN Service
Facade / Application Service
190 VictorRentea.ro
a training by
by pushing details in lower-level classes
Muscle
Fascicle
Fiber
Myofibril
Myofilaments
Goal = Simplify the top-level view of your flow
Facade = Separation by Layers of Abstraction
191
Code is NOT a Construction
VictorRentea.ro
192
193 VictorRentea.ro
a training by
requirements
Logic
Service
Facade
HOW?
Entities
OOP
1) One class/use-case
GetOrderByIdService - ⚠ tiny class
PlaceOrderService - ⚠ god class
-or-
2) N use-cases in a class
class OrderFacade { ⚠ god class
placeOrder()
getOrderById()
}
5-10%..more?💪
Continuously Extract
ApplicationService DomainService
simplify the most complex flows
194 VictorRentea.ro
a training by
Mapper
DTO
Facade
Facade Domain
Service
Domain
Service Domain Services
Ideas inspired by the book Java EE Patterns - Rethinking Best Practices, by Adam Bien
Push Domain Logic into
Start implementing every use-case in a
Facade
For trivial User Cases
a method is enough
eg. getOrderById
When logic gets complex,
or has to be reused
(evolutionary architecture)
195 VictorRentea.ro
a training by
Mapper
DTO
Facade Domain
Service
Domain
Service
take and return only
Domain Objects or primitives
Don't Depend on DTOs
Domain Boundary
DTOs are Evil
VO
Entity
id
Convert them to your Domain Objects ASAP
Domain Services
196 VictorRentea.ro
a training by
Cohesive Domain Services
OrderService
PlaceOrderService
⚠Bloat Risk, if Order is a large Entity
@VictorRentea
197
Facade Roles - Summary
• Converts DTOs  Entities
• inline, via [Auto-]Mappers, or Dto constructors/methods.
• Validates inputs
• @javax.validation.NotNull, if ...
• Transaction / use-case
• Except in high-TPS systems
• Orchestrates the workflow of a 🧠 use-case
• By delegating to lower-level components
@VictorRentea
198
Dependency Inversion
199 VictorRentea.ro
a training by
Domain
Service
Domain
Service
External
Service
domain
DTO
call
may get in
200 VictorRentea.ro
a training by
External
Service
DTO
Adapter
Domain
Service
Domain
Service
domain
201 VictorRentea.ro
a training by
External
Service
DTO
Adapter
Domain
Service
Domain
Service
<dependency>
domain infrastructure
VictorRentea.ro
202
External
Service
DTO
IAdapter Adapter
implements
class UserApiClient
implements IUserAdapter {
public User getById(id){
<external call>
}
}
interface IUserAdapter {
User getById(id);
}
class OrderService {
@Autowired
IUserAdapter adapter;
...
adapter.getById(id);
}
express your need in
a domain interface…
and implement it in a
lower-level module…
When you need
to call outside…
so nothing foreign
enters your domain.
Domain
Service
Domain
Service
<dependency>
domain infrastructure
203 VictorRentea.ro
a training by
calls
Dependency Inversion Principle
<dependency>
higher-level
module
lower-level
module
"Best of OOP"
- Uncle Bob
Abstractions should not depend on details
Low level classes
are not visible
(SOLID Principles)
Dependency Inversion
204 VictorRentea.ro
a training by
calls
<dependency>
higher-level
module
lower-level
module RMI,
HTTP
gRPC..
FTP
Queue
DB
DTO
Dependency Inversion
206 VictorRentea.ro
a training by
Stop Code Dependencies
from complex logic ➔ externals
Dependency Inversion
Package Dependency Checks - via static code analysis
- by compiler
@Test
public void dependencyInversionTest() {
ArchRuleDefinition
.noClasses().that().resideInAPackage("..domain")
.should().dependOnClassesThat().resideInAPackage("..infra")
.check(new ClassFileImporter().importPackages("my.corp.app"));
}
testImplementation com.tngtech.archunit:archunit-junit4:0.15.0 or NDepend (C#)
https://nx.dev/latest/angular/structure/monorepo-tags
https://github.com/MaibornWolff/ts-arch
207 VictorRentea.ro
a training by
An Agnostic Domain
lets you focus on
YOUR problem
Agnostic Domain
209 VictorRentea.ro
a training by
infrastructure
EXTERNAL
API
Value Object
Entity
id
Domain
Service
IAdapter
Onion Architecture
Behold, the famous
Database
domain
Repo
Dep Inv
Dep Inv
DTO
Agnostic Domain
application
DTO
Your
Client
Validation
Separate
Persistence
Model
if DB == enemy
Façade
Mapper
Controller
Msg Handler
Adapter
Spring Data
IRepo
210 VictorRentea.ro
a training by
DTO
Value Object
Entity
id
Domain
Service
application Database
domain
DTO
Onion Architecture
Pragmatic
Agnostic Domain
EXTERNAL
API
Your
Client
Façade
Mapper
Controller
Adapter
IAdapter
IRepo
Dep Inv
"Light-CQRS"
Selecting DTOs directly from queries
211 VictorRentea.ro
a training by
Independent of Intrusive Frameworks
Testable Standalone
without a DB, UI, Web Server, etc...
https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
Independent of UI
mobile, web, or desktop
Independent of DB
avoid PL/SQL, no vendor lock-in
Independent of External APIs
= external Bounded Contexts
Is an ORM intrusive?
Keep core logic ...
Agnostic Domain
aka Hexagonal
aka Ports-and-Adapters
aka Clean Architecture
Onion Architecture
Learn Hibernate: https://www.youtube.com/watch?v=iw0tOx7Zbjc
Façade
DTO
Mapper
Value Object
Entity
id
Domain
Service
Domain
Service
IRepo
application
IAdapter
Adapter
External
API
DTO
domain
Controller
DIP
DIP
UI
3rd party
213 VictorRentea.ro
a training by
Anemic Domain Model
("classic" approach)
Rich Domain Model
(Domain-Driven Design)
vs
Getters & Setters for all fields
All logic written in Services
Getters but less setters
Logic using fields of class X stays in X
Self-validating model
eg. Address constructor validates its consistency
Aggregates as consistency boundaries
Invariants enforced by Services
eg. Shipment requires a postal code, unless city=Bucharest
214 VictorRentea.ro
a training by
Chapter 3. Value Objects
215 VictorRentea.ro
a training by
How many fields it has?
Can you make it immutable?
Tell me about that big entity ...
How do you feel about moving logic inside?
216 VictorRentea.ro
a training by
How many fields it has?
Can you make it immutable?
How do you feel about moving logic inside?
Yes!
(use @Embeddable for JPA)
But, How to identify Value Objects?
Extract Value Objects from Entities:
217 VictorRentea.ro
a training by
Conceptual Whole
Money {amount, currency}
FullName {first, last}
Changes Together
LastModified-Time/-ByUser
How to identify Value Objects?
Screens
InvoicingDetails
Moves Together
PriceComputationInput
218 VictorRentea.ro
a training by
Key Points
DTOs are evil
Build a Deep, Rich Domain Model
Protect your Domain with DIP or ArchUnit
Don't let persistence concerns influence your Model design
Continuously Refactor to keep code suple
The entire team should understand the Design Goals
Be Pragmatic. Think Critically! dogmas
@victorrentea
VictorRentea.ro
victorrentea@gmail.com
== What I teach ==
Thank You !

Weitere ähnliche Inhalte

Was ist angesagt?

The tests are trying to tell you something@VoxxedBucharest.pptx
The tests are trying to tell you something@VoxxedBucharest.pptxThe tests are trying to tell you something@VoxxedBucharest.pptx
The tests are trying to tell you something@VoxxedBucharest.pptxVictor Rentea
 
Clean Lambdas & Streams in Java8
Clean Lambdas & Streams in Java8Clean Lambdas & Streams in Java8
Clean Lambdas & Streams in Java8Victor Rentea
 
Unit Testing like a Pro - The Circle of Purity
Unit Testing like a Pro - The Circle of PurityUnit Testing like a Pro - The Circle of Purity
Unit Testing like a Pro - The Circle of PurityVictor Rentea
 
Vertical Slicing Architectures
Vertical Slicing ArchitecturesVertical Slicing Architectures
Vertical Slicing ArchitecturesVictor Rentea
 
Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipVictor Rentea
 
Unit testing - 9 design hints
Unit testing - 9 design hintsUnit testing - 9 design hints
Unit testing - 9 design hintsVictor Rentea
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Steve Pember
 
Clean Code @Voxxed Days Cluj 2023 - opening Keynote
Clean Code @Voxxed Days Cluj 2023 - opening KeynoteClean Code @Voxxed Days Cluj 2023 - opening Keynote
Clean Code @Voxxed Days Cluj 2023 - opening KeynoteVictor Rentea
 
Clean architecture
Clean architectureClean architecture
Clean architectureLieven Doclo
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean ArchitectureMattia Battiston
 
No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...
No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...
No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...Alex Cachia
 
Clean Code - The Next Chapter
Clean Code - The Next ChapterClean Code - The Next Chapter
Clean Code - The Next ChapterVictor Rentea
 
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
Evolving a Clean, Pragmatic Architecture - A Craftsman's GuideEvolving a Clean, Pragmatic Architecture - A Craftsman's Guide
Evolving a Clean, Pragmatic Architecture - A Craftsman's GuideVictor Rentea
 
Clean architecture
Clean architectureClean architecture
Clean architectureandbed
 
The Proxy Fairy, and The Magic of Spring Framework
The Proxy Fairy, and The Magic of Spring FrameworkThe Proxy Fairy, and The Magic of Spring Framework
The Proxy Fairy, and The Magic of Spring FrameworkVictor Rentea
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean ArchitectureBadoo
 
A testing strategy for hexagonal applications
A testing strategy for hexagonal applicationsA testing strategy for hexagonal applications
A testing strategy for hexagonal applicationsMatthias Noback
 
Domain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and MicroservicesDomain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and MicroservicesRadosław Maziarka
 

Was ist angesagt? (20)

The tests are trying to tell you something@VoxxedBucharest.pptx
The tests are trying to tell you something@VoxxedBucharest.pptxThe tests are trying to tell you something@VoxxedBucharest.pptx
The tests are trying to tell you something@VoxxedBucharest.pptx
 
Clean Lambdas & Streams in Java8
Clean Lambdas & Streams in Java8Clean Lambdas & Streams in Java8
Clean Lambdas & Streams in Java8
 
Unit Testing like a Pro - The Circle of Purity
Unit Testing like a Pro - The Circle of PurityUnit Testing like a Pro - The Circle of Purity
Unit Testing like a Pro - The Circle of Purity
 
Vertical Slicing Architectures
Vertical Slicing ArchitecturesVertical Slicing Architectures
Vertical Slicing Architectures
 
Clean Code
Clean CodeClean Code
Clean Code
 
Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software Craftsmanship
 
Unit testing - 9 design hints
Unit testing - 9 design hintsUnit testing - 9 design hints
Unit testing - 9 design hints
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
 
Clean Code @Voxxed Days Cluj 2023 - opening Keynote
Clean Code @Voxxed Days Cluj 2023 - opening KeynoteClean Code @Voxxed Days Cluj 2023 - opening Keynote
Clean Code @Voxxed Days Cluj 2023 - opening Keynote
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Real Life Clean Architecture
Real Life Clean ArchitectureReal Life Clean Architecture
Real Life Clean Architecture
 
No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...
No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...
No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...
 
Clean Code - The Next Chapter
Clean Code - The Next ChapterClean Code - The Next Chapter
Clean Code - The Next Chapter
 
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
Evolving a Clean, Pragmatic Architecture - A Craftsman's GuideEvolving a Clean, Pragmatic Architecture - A Craftsman's Guide
Evolving a Clean, Pragmatic Architecture - A Craftsman's Guide
 
Clean code
Clean codeClean code
Clean code
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
The Proxy Fairy, and The Magic of Spring Framework
The Proxy Fairy, and The Magic of Spring FrameworkThe Proxy Fairy, and The Magic of Spring Framework
The Proxy Fairy, and The Magic of Spring Framework
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
A testing strategy for hexagonal applications
A testing strategy for hexagonal applicationsA testing strategy for hexagonal applications
A testing strategy for hexagonal applications
 
Domain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and MicroservicesDomain Driven Design - Strategic Patterns and Microservices
Domain Driven Design - Strategic Patterns and Microservices
 

Ähnlich wie Clean pragmatic architecture @ devflix

Robotlegs on Top of Gaia
Robotlegs on Top of GaiaRobotlegs on Top of Gaia
Robotlegs on Top of GaiaJesse Warden
 
FIWARE Wednesday Webinars - How to Debug IoT Agents
FIWARE Wednesday Webinars - How to Debug IoT AgentsFIWARE Wednesday Webinars - How to Debug IoT Agents
FIWARE Wednesday Webinars - How to Debug IoT AgentsFIWARE
 
Building an Observability Platform in 389 Difficult Steps
Building an Observability Platform in 389 Difficult StepsBuilding an Observability Platform in 389 Difficult Steps
Building an Observability Platform in 389 Difficult StepsDigitalOcean
 
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...InfluxData
 
SecuritĂŠ des container
SecuritĂŠ des containerSecuritĂŠ des container
SecuritĂŠ des containerRachid Zarouali
 
ITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep dive
ITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep diveITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep dive
ITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep diveITCamp
 
Get the Exact Identity Solution You Need - In the Cloud - Overview
Get the Exact Identity Solution You Need - In the Cloud - OverviewGet the Exact Identity Solution You Need - In the Cloud - Overview
Get the Exact Identity Solution You Need - In the Cloud - OverviewForgeRock
 
Optimizing Direct X On Multi Core Architectures
Optimizing Direct X On Multi Core ArchitecturesOptimizing Direct X On Multi Core Architectures
Optimizing Direct X On Multi Core Architecturespsteinb
 
Practical Tools for Enterprise Uses of Hyperledger Fabric (Audit and System ...
 Practical Tools for Enterprise Uses of Hyperledger Fabric (Audit and System ... Practical Tools for Enterprise Uses of Hyperledger Fabric (Audit and System ...
Practical Tools for Enterprise Uses of Hyperledger Fabric (Audit and System ...Hyperleger Tokyo Meetup
 
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17Muga Nishizawa
 
Multi-tenancy with Rails
Multi-tenancy with RailsMulti-tenancy with Rails
Multi-tenancy with RailsPaul Gallagher
 
Integrating DDS into AXCIOMA, the component approach
Integrating DDS into AXCIOMA, the component approachIntegrating DDS into AXCIOMA, the component approach
Integrating DDS into AXCIOMA, the component approachRemedy IT
 
Banner XE CAUSE 2013 Part 2
Banner XE CAUSE 2013 Part 2Banner XE CAUSE 2013 Part 2
Banner XE CAUSE 2013 Part 2Jim Kane
 
Aop, Metaprogramming and codegeneration with PHP
Aop, Metaprogramming and codegeneration with PHPAop, Metaprogramming and codegeneration with PHP
Aop, Metaprogramming and codegeneration with PHPSerge Smertin
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopLinaro
 
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...OpenDNS
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - DetroitMartin Gutenbrunner
 
Undefined Behavior and Compiler Optimizations (NDC Oslo 2018)
Undefined Behavior and Compiler Optimizations (NDC Oslo 2018)Undefined Behavior and Compiler Optimizations (NDC Oslo 2018)
Undefined Behavior and Compiler Optimizations (NDC Oslo 2018)Patricia Aas
 
Android Industrial Mobility - Droidcon Italy - Turin 9-10 April 2015
Android Industrial Mobility - Droidcon Italy - Turin 9-10 April 2015Android Industrial Mobility - Droidcon Italy - Turin 9-10 April 2015
Android Industrial Mobility - Droidcon Italy - Turin 9-10 April 2015Pietro F. Maggi
 
The Flink - Apache Bigtop integration
The Flink - Apache Bigtop integrationThe Flink - Apache Bigtop integration
The Flink - Apache Bigtop integrationMĂĄrton Balassi
 

Ähnlich wie Clean pragmatic architecture @ devflix (20)

Robotlegs on Top of Gaia
Robotlegs on Top of GaiaRobotlegs on Top of Gaia
Robotlegs on Top of Gaia
 
FIWARE Wednesday Webinars - How to Debug IoT Agents
FIWARE Wednesday Webinars - How to Debug IoT AgentsFIWARE Wednesday Webinars - How to Debug IoT Agents
FIWARE Wednesday Webinars - How to Debug IoT Agents
 
Building an Observability Platform in 389 Difficult Steps
Building an Observability Platform in 389 Difficult StepsBuilding an Observability Platform in 389 Difficult Steps
Building an Observability Platform in 389 Difficult Steps
 
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
 
SecuritĂŠ des container
SecuritĂŠ des containerSecuritĂŠ des container
SecuritĂŠ des container
 
ITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep dive
ITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep diveITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep dive
ITCamp 2013 - Raffaele Rialdi - Windows Runtime (WinRT) deep dive
 
Get the Exact Identity Solution You Need - In the Cloud - Overview
Get the Exact Identity Solution You Need - In the Cloud - OverviewGet the Exact Identity Solution You Need - In the Cloud - Overview
Get the Exact Identity Solution You Need - In the Cloud - Overview
 
Optimizing Direct X On Multi Core Architectures
Optimizing Direct X On Multi Core ArchitecturesOptimizing Direct X On Multi Core Architectures
Optimizing Direct X On Multi Core Architectures
 
Practical Tools for Enterprise Uses of Hyperledger Fabric (Audit and System ...
 Practical Tools for Enterprise Uses of Hyperledger Fabric (Audit and System ... Practical Tools for Enterprise Uses of Hyperledger Fabric (Audit and System ...
Practical Tools for Enterprise Uses of Hyperledger Fabric (Audit and System ...
 
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17
 
Multi-tenancy with Rails
Multi-tenancy with RailsMulti-tenancy with Rails
Multi-tenancy with Rails
 
Integrating DDS into AXCIOMA, the component approach
Integrating DDS into AXCIOMA, the component approachIntegrating DDS into AXCIOMA, the component approach
Integrating DDS into AXCIOMA, the component approach
 
Banner XE CAUSE 2013 Part 2
Banner XE CAUSE 2013 Part 2Banner XE CAUSE 2013 Part 2
Banner XE CAUSE 2013 Part 2
 
Aop, Metaprogramming and codegeneration with PHP
Aop, Metaprogramming and codegeneration with PHPAop, Metaprogramming and codegeneration with PHP
Aop, Metaprogramming and codegeneration with PHP
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP Workshop
 
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - Detroit
 
Undefined Behavior and Compiler Optimizations (NDC Oslo 2018)
Undefined Behavior and Compiler Optimizations (NDC Oslo 2018)Undefined Behavior and Compiler Optimizations (NDC Oslo 2018)
Undefined Behavior and Compiler Optimizations (NDC Oslo 2018)
 
Android Industrial Mobility - Droidcon Italy - Turin 9-10 April 2015
Android Industrial Mobility - Droidcon Italy - Turin 9-10 April 2015Android Industrial Mobility - Droidcon Italy - Turin 9-10 April 2015
Android Industrial Mobility - Droidcon Italy - Turin 9-10 April 2015
 
The Flink - Apache Bigtop integration
The Flink - Apache Bigtop integrationThe Flink - Apache Bigtop integration
The Flink - Apache Bigtop integration
 

Mehr von Victor Rentea

Microservice Resilience Patterns @VoxxedCern'24
Microservice Resilience Patterns @VoxxedCern'24Microservice Resilience Patterns @VoxxedCern'24
Microservice Resilience Patterns @VoxxedCern'24Victor Rentea
 
Distributed Consistency.pdf
Distributed Consistency.pdfDistributed Consistency.pdf
Distributed Consistency.pdfVictor Rentea
 
Testing Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdfTesting Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdfVictor Rentea
 
From Web to Flux @DevoxxBE 2023.pptx
From Web to Flux @DevoxxBE 2023.pptxFrom Web to Flux @DevoxxBE 2023.pptx
From Web to Flux @DevoxxBE 2023.pptxVictor Rentea
 
Test-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxTest-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxVictor Rentea
 
Profiling your Java Application
Profiling your Java ApplicationProfiling your Java Application
Profiling your Java ApplicationVictor Rentea
 
OAuth in the Wild
OAuth in the WildOAuth in the Wild
OAuth in the WildVictor Rentea
 
Refactoring blockers and code smells @jNation 2021
Refactoring   blockers and code smells @jNation 2021Refactoring   blockers and code smells @jNation 2021
Refactoring blockers and code smells @jNation 2021Victor Rentea
 
Hibernate and Spring - Unleash the Magic
Hibernate and Spring - Unleash the MagicHibernate and Spring - Unleash the Magic
Hibernate and Spring - Unleash the MagicVictor Rentea
 
Integration testing with spring @JAX Mainz
Integration testing with spring @JAX MainzIntegration testing with spring @JAX Mainz
Integration testing with spring @JAX MainzVictor Rentea
 
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021Victor Rentea
 
Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021Victor Rentea
 
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...Victor Rentea
 
Pure Functions and Immutable Objects
Pure Functions and Immutable ObjectsPure Functions and Immutable Objects
Pure Functions and Immutable ObjectsVictor Rentea
 
Definitive Guide to Working With Exceptions in Java
Definitive Guide to Working With Exceptions in JavaDefinitive Guide to Working With Exceptions in Java
Definitive Guide to Working With Exceptions in JavaVictor Rentea
 
Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipVictor Rentea
 
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...Victor Rentea
 

Mehr von Victor Rentea (18)

Microservice Resilience Patterns @VoxxedCern'24
Microservice Resilience Patterns @VoxxedCern'24Microservice Resilience Patterns @VoxxedCern'24
Microservice Resilience Patterns @VoxxedCern'24
 
Distributed Consistency.pdf
Distributed Consistency.pdfDistributed Consistency.pdf
Distributed Consistency.pdf
 
Testing Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdfTesting Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdf
 
From Web to Flux @DevoxxBE 2023.pptx
From Web to Flux @DevoxxBE 2023.pptxFrom Web to Flux @DevoxxBE 2023.pptx
From Web to Flux @DevoxxBE 2023.pptx
 
Test-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptxTest-Driven Design Insights@DevoxxBE 2023.pptx
Test-Driven Design Insights@DevoxxBE 2023.pptx
 
Profiling your Java Application
Profiling your Java ApplicationProfiling your Java Application
Profiling your Java Application
 
OAuth in the Wild
OAuth in the WildOAuth in the Wild
OAuth in the Wild
 
Refactoring blockers and code smells @jNation 2021
Refactoring   blockers and code smells @jNation 2021Refactoring   blockers and code smells @jNation 2021
Refactoring blockers and code smells @jNation 2021
 
Hibernate and Spring - Unleash the Magic
Hibernate and Spring - Unleash the MagicHibernate and Spring - Unleash the Magic
Hibernate and Spring - Unleash the Magic
 
Integration testing with spring @JAX Mainz
Integration testing with spring @JAX MainzIntegration testing with spring @JAX Mainz
Integration testing with spring @JAX Mainz
 
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
 
Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021
 
TDD Mantra
TDD MantraTDD Mantra
TDD Mantra
 
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
 
Pure Functions and Immutable Objects
Pure Functions and Immutable ObjectsPure Functions and Immutable Objects
Pure Functions and Immutable Objects
 
Definitive Guide to Working With Exceptions in Java
Definitive Guide to Working With Exceptions in JavaDefinitive Guide to Working With Exceptions in Java
Definitive Guide to Working With Exceptions in Java
 
Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software Craftsmanship
 
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
 

KĂźrzlich hochgeladen

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

KĂźrzlich hochgeladen (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Clean pragmatic architecture @ devflix

  • 2. Hi, I'm Victor Rentea Java Champion – drinking since 2006 Trainer – 3000+ devs / 80+ companies, since 2013 Speaker – Conferences & Meetups Hibernate Spring Java8/FP Java Performance Secure Coding Reactive Architecture Clean Code Unit Testing
  • 3. $ Hibernate Spring Java8/FP Architecture Clean Code Unit Testing Masterclass Company Training Video Courses YouTube Channel 💗 Join My Community Blog @victorrentea VictorRentea.ro victorrentea@gmail.com Java Performance Secure Coding Reactive
  • 4. 172 VictorRentea.ro a training by Chapter 1. Data Structures
  • 5. 173 VictorRentea.ro a training by Can I have a chicken?
  • 6. The data structure they send you The data structure you want to use in your core logic DTO domain Object
  • 7. 175 VictorRentea.ro a training by DTOs* are Evil *Data Transfer Objects – data structures that move across APIs
  • 8. 176 VictorRentea.ro a training by ☢ Beware of Foreign Data Structures ☢ ➢ Bloated (more fields than you need) ➢ Flat ➢ Different perspective 🐔 (bounded context) ➢ Fixed design (often generated or in client-lib) ➢ Mutable (pain from frameworks otherwise) ➢ No constraints (nulls, validation, invariants) ➢ Diverging in time (v2) We 💗 small, cohesive data structures We 💗 Logic next to data (OOP) We 💗 Immutable objects We 💗 Deep, Rich Domain Model We 💗 Models to guard their invariants We want control over our structures Because DTOs are: In our core logic: We 💗 Structures tailored to our problem
  • 9. 177 Š VictorRentea.ro a training by Don't implement complex logic on foreign data structures Elders Wisdom What's complex? What's foreign?
  • 10. 178 VictorRentea.ro a training by Bounded Context A (TeamA) The Curious Case of Nanoservices DTOs can be shared within the same Bounded Context (team) =tiny microservice eg. 5 devs maintaining 20 microservices 1 2 3 Bounded Context B (TeamB) X But not with others What's foreign?
  • 11. 179 VictorRentea.ro a training by ⚠ Returning entities as JSON ⚠ ➢ Couples your clients to your internal entity structure ➢ Is risky to marshal and of course...
  • 12. 180 VictorRentea.ro a training by Decouple DTO Domain Model < > Price: more classes + more mapping Exception: Boundary Systems = Huge Adapters without own Domain Software Ecosystem A - Manually Crafted DTO - Generated DTOs: XML: .xsd/.wsdl ➔ xjc JSON: .yaml ➔ swagger-gen Auto-Generated Mappers
  • 13. 181 VictorRentea.ro a training by Auto-Generated Mappers Converting Entity  DTO with as long as the field names match, mapping happens automatically eg MapStruct Temptation to keep the models in sync Entities and DTOs must be allowed to diverge Customer.firstName  CustomerDto.firstName War Stories: When mapping gets complex, deep knowledge of MapStruct is required ➔ Consider switching to manual mapping (simpler) ?
  • 14. 182 Š VictorRentea.ro a training by Don't implement complex logic on foreign data structures Elders Wisdom
  • 15. 183 VictorRentea.ro a training by Chapter 2. Logic
  • 17. 185 VictorRentea.ro a training by The Code - anonymous developer
  • 18. 186 VictorRentea.ro a training by Layers SUB-DOMAINS Controller Service Repository APIs order Product user customer API infrastructure too complex ➔
  • 19. 187 VictorRentea.ro a training by Layers Controller Repository APIs Facade / Application Service Layered Architecture DOMAIN Service
  • 20. 188 VictorRentea.ro a training by Controller Repository call direction pull orchestration up, let Repos trivial Relaxed Layered Architecture allows skipping layers Layered Architecture DOMAIN Service Facade / Application Service
  • 21. 190 VictorRentea.ro a training by by pushing details in lower-level classes Muscle Fascicle Fiber Myofibril Myofilaments Goal = Simplify the top-level view of your flow Facade = Separation by Layers of Abstraction
  • 22. 191 Code is NOT a Construction
  • 24. 193 VictorRentea.ro a training by requirements Logic Service Facade HOW? Entities OOP 1) One class/use-case GetOrderByIdService - ⚠ tiny class PlaceOrderService - ⚠ god class -or- 2) N use-cases in a class class OrderFacade { ⚠ god class placeOrder() getOrderById() } 5-10%..more?💪 Continuously Extract ApplicationService DomainService simplify the most complex flows
  • 25. 194 VictorRentea.ro a training by Mapper DTO Facade Facade Domain Service Domain Service Domain Services Ideas inspired by the book Java EE Patterns - Rethinking Best Practices, by Adam Bien Push Domain Logic into Start implementing every use-case in a Facade For trivial User Cases a method is enough eg. getOrderById When logic gets complex, or has to be reused (evolutionary architecture)
  • 26. 195 VictorRentea.ro a training by Mapper DTO Facade Domain Service Domain Service take and return only Domain Objects or primitives Don't Depend on DTOs Domain Boundary DTOs are Evil VO Entity id Convert them to your Domain Objects ASAP Domain Services
  • 27. 196 VictorRentea.ro a training by Cohesive Domain Services OrderService PlaceOrderService ⚠Bloat Risk, if Order is a large Entity
  • 28. @VictorRentea 197 Facade Roles - Summary • Converts DTOs  Entities • inline, via [Auto-]Mappers, or Dto constructors/methods. • Validates inputs • @javax.validation.NotNull, if ... • Transaction / use-case • Except in high-TPS systems • Orchestrates the workflow of a 🧠 use-case • By delegating to lower-level components
  • 30. 199 VictorRentea.ro a training by Domain Service Domain Service External Service domain DTO call may get in
  • 31. 200 VictorRentea.ro a training by External Service DTO Adapter Domain Service Domain Service domain
  • 32. 201 VictorRentea.ro a training by External Service DTO Adapter Domain Service Domain Service <dependency> domain infrastructure
  • 33. VictorRentea.ro 202 External Service DTO IAdapter Adapter implements class UserApiClient implements IUserAdapter { public User getById(id){ <external call> } } interface IUserAdapter { User getById(id); } class OrderService { @Autowired IUserAdapter adapter; ... adapter.getById(id); } express your need in a domain interface… and implement it in a lower-level module… When you need to call outside… so nothing foreign enters your domain. Domain Service Domain Service <dependency> domain infrastructure
  • 34. 203 VictorRentea.ro a training by calls Dependency Inversion Principle <dependency> higher-level module lower-level module "Best of OOP" - Uncle Bob Abstractions should not depend on details Low level classes are not visible (SOLID Principles) Dependency Inversion
  • 35. 204 VictorRentea.ro a training by calls <dependency> higher-level module lower-level module RMI, HTTP gRPC.. FTP Queue DB DTO Dependency Inversion
  • 36. 206 VictorRentea.ro a training by Stop Code Dependencies from complex logic ➔ externals Dependency Inversion Package Dependency Checks - via static code analysis - by compiler @Test public void dependencyInversionTest() { ArchRuleDefinition .noClasses().that().resideInAPackage("..domain") .should().dependOnClassesThat().resideInAPackage("..infra") .check(new ClassFileImporter().importPackages("my.corp.app")); } testImplementation com.tngtech.archunit:archunit-junit4:0.15.0 or NDepend (C#) https://nx.dev/latest/angular/structure/monorepo-tags https://github.com/MaibornWolff/ts-arch
  • 37. 207 VictorRentea.ro a training by An Agnostic Domain lets you focus on YOUR problem Agnostic Domain
  • 38. 209 VictorRentea.ro a training by infrastructure EXTERNAL API Value Object Entity id Domain Service IAdapter Onion Architecture Behold, the famous Database domain Repo Dep Inv Dep Inv DTO Agnostic Domain application DTO Your Client Validation Separate Persistence Model if DB == enemy Façade Mapper Controller Msg Handler Adapter Spring Data IRepo
  • 39. 210 VictorRentea.ro a training by DTO Value Object Entity id Domain Service application Database domain DTO Onion Architecture Pragmatic Agnostic Domain EXTERNAL API Your Client Façade Mapper Controller Adapter IAdapter IRepo Dep Inv "Light-CQRS" Selecting DTOs directly from queries
  • 40. 211 VictorRentea.ro a training by Independent of Intrusive Frameworks Testable Standalone without a DB, UI, Web Server, etc... https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html Independent of UI mobile, web, or desktop Independent of DB avoid PL/SQL, no vendor lock-in Independent of External APIs = external Bounded Contexts Is an ORM intrusive? Keep core logic ... Agnostic Domain aka Hexagonal aka Ports-and-Adapters aka Clean Architecture Onion Architecture Learn Hibernate: https://www.youtube.com/watch?v=iw0tOx7Zbjc
  • 42. 213 VictorRentea.ro a training by Anemic Domain Model ("classic" approach) Rich Domain Model (Domain-Driven Design) vs Getters & Setters for all fields All logic written in Services Getters but less setters Logic using fields of class X stays in X Self-validating model eg. Address constructor validates its consistency Aggregates as consistency boundaries Invariants enforced by Services eg. Shipment requires a postal code, unless city=Bucharest
  • 43. 214 VictorRentea.ro a training by Chapter 3. Value Objects
  • 44. 215 VictorRentea.ro a training by How many fields it has? Can you make it immutable? Tell me about that big entity ... How do you feel about moving logic inside?
  • 45. 216 VictorRentea.ro a training by How many fields it has? Can you make it immutable? How do you feel about moving logic inside? Yes! (use @Embeddable for JPA) But, How to identify Value Objects? Extract Value Objects from Entities:
  • 46. 217 VictorRentea.ro a training by Conceptual Whole Money {amount, currency} FullName {first, last} Changes Together LastModified-Time/-ByUser How to identify Value Objects? Screens InvoicingDetails Moves Together PriceComputationInput
  • 47. 218 VictorRentea.ro a training by Key Points DTOs are evil Build a Deep, Rich Domain Model Protect your Domain with DIP or ArchUnit Don't let persistence concerns influence your Model design Continuously Refactor to keep code suple The entire team should understand the Design Goals Be Pragmatic. Think Critically! dogmas