Kingdom Driven Design
Arnaud Bouchez – Synopse / LiveMon
Kingdom Driven Design
Kingdom Driven Design
Arnaud Bouchez
– Delphi / FPC
‱ Various solutions (from Vatican to gaming industry)
‱ Real-time Monitoring solution (LiveMon)
– Open Source
‱ mORMot (SOA ORM MVC framework)
‱ SynPDF SynMustache SynDB SynCrypto
– Training and consultancy
‱ Synopse one-man company
‱ mORMot for Architecture and (Domain-Driven-)Design
Kingdom Driven Design
Kingdom Driven Design
https://LiveMon.com
 Infrastructure Monitoring
 Log Management
 Artificial Intelligence
 External Monitoring
 Industry Standard Compatible
Kingdom Driven Design
https://LiveMon.com
Object Pascal (FPC) and mORMot
for the local agent
for the server side
and the (rich) client side via a REST binary API
JavaScript clients via a REST JSON API
Kingdom Driven Design
https://LiveMon.com
Object Pascal (FPC) and mORMot
for building MicroServices
distributed on thousands of servers
e.g. execute a regex on logs at 2TB/second
or store millions of events per second
with a fair price
Kingdom Driven Design
https://LiveMon.com
Object Pascal (FPC) and mORMot
following a cut-down Domain-Driven-Design
= introducing Kingdom-Driven-Design
Kingdom Driven Design
Kingdom Driven Design
‱ Domain Driven Design
‱ Return Of Experience
‱ Kingdom Driven Design
Kingdom Driven Design
Kingdom Driven Design
‱ Domain Driven Design
‱ Return Of Experience
‱ Kingdom Driven Design
Kingdom Driven Design
Domain Driven Design
is a paranoid set
of Design and Architecture rules
to isolate the Model
of a well-identified Domain code
to ease large projects maintenance
and/or explore some new territories
Kingdom Driven Design
Domain Driven Design
http://martinfowler.com/bliki/DesignStaminaHypothesis.html
Kingdom Driven Design
Domain Driven Design
Kingdom Driven Design
Domain Driven Design
Kingdom Driven Design
Domain Driven Design
The Domain
‱ Well-identified
‱ Access to Domain Experts
‱ Complex and/or Exploring
‱ Valuable
Kingdom Driven Design
Domain Driven Design
The Domain
‱ Model Driven Design
– Iterative modelization
– Domain code describes (complex) reality
– Several Bounded Contexts
Kingdom Driven Design
Domain Driven Design
The Domain
‱ Ubiquitous Language
Code naming follows reality
and is not polluted by technology
Kingdom Driven Design
Kingdom Driven Design
Domain Driven Design
Keep your Domain code clean
‱ Strict Isolation
Objects, DB, API, legacy, 3rd party
Kingdom Driven Design
Domain Driven Design
Keep your Domain code clean
‱ Paranoid Isolation
Objects, DB, API, legacy, 3rd party
Kingdom Driven Design
Domain Driven Design
Paranoid Objects Isolation
‱ Plain Old Delphi Objects (PODO)
– Value Objects
– Entities
– Aggregates
– Events
Kingdom Driven Design
Domain Driven Design
Paranoid DB Isolation
‱ Agnostic Persistence layer
of the PODO Aggregates
‱ Injected in Application Layer
‱ Easily mocked/stubbed
‱ NO logic in the database - CRUD
Kingdom Driven Design
Domain Driven Design
Paranoid API Isolation
‱ Never leak the Domain
– Keep Domain objects and services private
– Define adapter interfaces in Domain,
implement in separated Infrastructure layer
– Application Layer as isolation layer
Kingdom Driven Design
Domain Driven Design
Paranoid API Isolation
‱ Application Layer
– Workflow Orchestration via Injection
– Customized public APIs
– Below presentation Layer (rich or web client)
– Define Data Transfer Objects (DTOs)
Kingdom Driven Design
Domain Driven Design
Paranoid Legacy Isolation
‱ Domain code is new/first/clean
– NO copy & paste
– Test Driven Design
‱ Legacy code injected as Seams
– e.g. for the persistence layer
or as external services
Kingdom Driven Design
Domain Driven Design
Paranoid 3rd party Isolation
‱ Service Abstraction by Adapters
– interfaces defined in Domain
– class implemented outside the Domain
(may be as a SaaS client)
in the Infrastructure Layer
– injected by the Application Layer
Kingdom Driven Design
Domain Driven Design
Domain-Driven-Design
Kingdom Driven Design
Domain Driven Design
Domain-Driven-Design
Unbreakable Isolation
Kingdom Driven Design
Domain Driven Design
is FUN, isn’t?
Kingdom Driven Design
Kingdom Driven Design
‱ Domain Driven Design
‱ Return Of Experience
‱ Kingdom Driven Design
Kingdom Driven Design
Return Of Experience
‱ DDD in a DotNet project
‱ DDD in a Delphi project
more than 5 years of DDD code writing
and consulting
Kingdom Driven Design
Return Of Experience
DDD in a DotNet project
‱ WCF, WPF, legacy DB
‱ Legacy Delphi & Java apps
‱ Verbose and not clean
‱ Services difficult to deploy
Kingdom Driven Design
Return Of Experience
DDD in a DotNet project
Legacy & Hybrid Cost
Kingdom Driven Design
Return Of Experience
DDD in a Delphi project
‱ IoT high performance solution
– “Things” agnostic (Domain as HAL)
– Data sharding and CQRS
– written from scratch
– mORMot as toolbox
Kingdom Driven Design
Return Of Experience
DDD in a Delphi project
‱ Following DDD rules has a cost
– higher time-to-market, skilled developpers
– users still prefer direct “Things” layer access
– business don’t care (much) about DDD
Kingdom Driven Design
Return Of Experience
DDD in a Delphi project
‱ mORMot toolbox helped but

– persistence layer PODO to ORM mapping
– asynch DDD service to synch public API
– defining and translating a lot of DTOs
Kingdom Driven Design
Return Of Experience
“Le mieux est le pire ennemi du bien”
Charles-Louis de Montesquieu
Kingdom Driven Design
Return Of Experience
“Le mieux est le pire ennemi du bien”
Charles-Louis de Montesquieu
“Perfect is the worst enemy of good”
Kingdom Driven Design
Kingdom Driven Design
‱ Domain Driven Design
‱ Return Of Experience
‱ Kingdom Driven Design
Kingdom Driven Design
Kingdom Driven Design
From DDD to KDD
reintroduce laziness
Kingdom Driven Design
Kingdom Driven Design
From DDD to KDD
reintroduce laziness
i.e. “the quality that makes you go to great effort to
reduce overall energy expenditure. It makes you write
labor-saving programs that other people will find
useful and document what you wrote so you don't
have to answer so many questions about it.”
Larry Wall
Kingdom Driven Design
Kingdom Driven Design
From DDD to KDD
‱ a pragmatic cut-down version of DDD
‱ focusing on SOLID principles
‱ leveraging the Object Pascal platform
Kingdom Driven Design
Kingdom Driven Design
From DDD to KDD
Kingdom isolation with no paranoia
embrace business/human/time contingency
Kingdom Driven Design
Kingdom Driven Design
Taxonomic
ranks
Kingdom Driven Design
Kingdom Driven Design
Kingdom
‱ Slightly closer to technology
‱ Disclaimer:
– DDD had nothing to do with taxonomy
– KDD is still Model-Driven-Design
– Let your Kingdom come!
Kingdom Driven Design
Kingdom Driven Design
The Kingdom
‱ Well-identified
‱ (Complex)
‱ Access to Kingdom Experts
‱ Per Bounded Contexts
Kingdom Driven Design
Kingdom Driven Design
Keep your Kingdom code clean
‱ Ubiquitous Language
Code naming follows reality
but could be slightly polluted by technology
(e.g. ORM or serialization class)
Kingdom Driven Design
Kingdom Driven Design
Keep your Kingdom code clean
‱ Pragmatic Isolation
Objects, DB, API, legacy, 3rd party
‱ Rooted in SOLID principles
practical OOP, Injection, MicroServices
‱ Leverage language and libraries
RTTI, interfaces, SOA
Kingdom Driven Design
Kingdom Driven Design
Pragmatic Objects Isolation
‱ Use language/library features
– Value Objects = records or variants
– Entities = persistent classes
– Aggregates = ORM classes
– Events = records or variants
Kingdom Driven Design
Kingdom Driven Design
Pragmatic DB Isolation
‱ Agnostic Persistence layer
is what an ORM is for
 direct ORM use
 no persistence interface / service
‱ NO logic in the database - CRUD
Kingdom Driven Design
Kingdom Driven Design
Pragmatic API Isolation
‱ Keep the Kingdom uncoupled
– Define adapter interfaces in Kingdom,
implement in separated Infrastructure layer
– Application Layer as orchestration layer
(just like Domain-Driven-Design)
Kingdom Driven Design
Kingdom Driven Design
Pragmatic API Isolation
‱ But may leak the Kingdom
– Keep Kingdom services private
– May expose Kingdom objects
i.e. leak objects as properties (content)
not with methods (process)
e.g. JSON REST exposure
Kingdom Driven Design
Kingdom Driven Design
Pragmatic API Isolation
‱ Application Layer / public APIs
– Workflow Orchestration via Injection
Orchestrate rather than Isolate
– Define Data Transfer Objects (DTOs)
and/or expose Kingdom objects (JSON/variant)
following pragmatic arbitrations
Kingdom Driven Design
Kingdom Driven Design
Pragmatic Legacy Isolation
‱ Kingdom code
– copy & paste & adapt existing objects/DB
– uncoupling as much as possible
– introduce Test Driven Design
‱ Legacy code injected as Seams
– e.g. persistence layer or external services
Kingdom Driven Design
Kingdom Driven Design
Kingdom 3rd party Isolation
‱ Service Abstraction by Adapters
– interfaces defined in Kingdom
– class implemented outside the Kingdom
(may be as a SaaS client)
in the Infrastructure Layer
– injected by the Application Layer
Kingdom Driven Design
Domain Driven Design
Domain-Driven-Design
Unbreakable Isolation
Kingdom Driven Design
Domain Driven Design
X
Kingdom Layer
Kingdom
Model
Kingdom Services
Kingdom-Driven-Design
Kingdom Driven Design
Kingdom Driven Design
is Domain-Driven-Design but
‱ direct ORM persistence
and library (ab)use (e.g. serialization)
‱ (maybe) leaked objects
‱ SOLID principles roots
Kingdom Driven Design
Kingdom Driven Design
is Domain-Driven-Design but
‱ direct ORM persistence
tied to a given ORM/library
‱ (maybe) leaked objects
harden any breaking change
‱ SOLID principles roots
more technical code
Kingdom Driven Design
Kingdom Driven Design
Distributed MicroServices architecture
Monolithic
Distributed
SOLID SOA
Kingdom Driven Design
Kingdom Driven Design
‱ favors SOLID code over isolated code
‱ uncoupled MicroServices vs uncoupled code
‱ prefers convention over configuration
‱ small skilled team vs Conway’s Law separation
‱ leverages language/toolbox features
‱ for pragmatic Time-To-Market
Kingdom Driven Design
Kingdom Driven Design
‱ Domain Driven Design
‱ Return Of Experience
‱ Kingdom Driven Design
Kingdom Driven Design
mORMot as KDD Toolbox

 to be continued 
Kingdom Driven Design
‱ Questions?
Kingdom Driven Design

Ekon23 (1) Kingdom-Driven-Design

  • 1.
    Kingdom Driven Design ArnaudBouchez – Synopse / LiveMon Kingdom Driven Design
  • 2.
    Kingdom Driven Design ArnaudBouchez – Delphi / FPC ‱ Various solutions (from Vatican to gaming industry) ‱ Real-time Monitoring solution (LiveMon) – Open Source ‱ mORMot (SOA ORM MVC framework) ‱ SynPDF SynMustache SynDB SynCrypto – Training and consultancy ‱ Synopse one-man company ‱ mORMot for Architecture and (Domain-Driven-)Design
  • 3.
  • 4.
    Kingdom Driven Design https://LiveMon.com Infrastructure Monitoring  Log Management  Artificial Intelligence  External Monitoring  Industry Standard Compatible
  • 5.
    Kingdom Driven Design https://LiveMon.com ObjectPascal (FPC) and mORMot for the local agent for the server side and the (rich) client side via a REST binary API JavaScript clients via a REST JSON API
  • 6.
    Kingdom Driven Design https://LiveMon.com ObjectPascal (FPC) and mORMot for building MicroServices distributed on thousands of servers e.g. execute a regex on logs at 2TB/second or store millions of events per second with a fair price
  • 7.
    Kingdom Driven Design https://LiveMon.com ObjectPascal (FPC) and mORMot following a cut-down Domain-Driven-Design = introducing Kingdom-Driven-Design
  • 8.
    Kingdom Driven Design KingdomDriven Design ‱ Domain Driven Design ‱ Return Of Experience ‱ Kingdom Driven Design
  • 9.
    Kingdom Driven Design KingdomDriven Design ‱ Domain Driven Design ‱ Return Of Experience ‱ Kingdom Driven Design
  • 10.
    Kingdom Driven Design DomainDriven Design is a paranoid set of Design and Architecture rules to isolate the Model of a well-identified Domain code to ease large projects maintenance and/or explore some new territories
  • 11.
    Kingdom Driven Design DomainDriven Design http://martinfowler.com/bliki/DesignStaminaHypothesis.html
  • 12.
  • 13.
  • 14.
    Kingdom Driven Design DomainDriven Design The Domain ‱ Well-identified ‱ Access to Domain Experts ‱ Complex and/or Exploring ‱ Valuable
  • 15.
    Kingdom Driven Design DomainDriven Design The Domain ‱ Model Driven Design – Iterative modelization – Domain code describes (complex) reality – Several Bounded Contexts
  • 16.
    Kingdom Driven Design DomainDriven Design The Domain ‱ Ubiquitous Language Code naming follows reality and is not polluted by technology
  • 17.
  • 18.
    Kingdom Driven Design DomainDriven Design Keep your Domain code clean ‱ Strict Isolation Objects, DB, API, legacy, 3rd party
  • 19.
    Kingdom Driven Design DomainDriven Design Keep your Domain code clean ‱ Paranoid Isolation Objects, DB, API, legacy, 3rd party
  • 20.
    Kingdom Driven Design DomainDriven Design Paranoid Objects Isolation ‱ Plain Old Delphi Objects (PODO) – Value Objects – Entities – Aggregates – Events
  • 21.
    Kingdom Driven Design DomainDriven Design Paranoid DB Isolation ‱ Agnostic Persistence layer of the PODO Aggregates ‱ Injected in Application Layer ‱ Easily mocked/stubbed ‱ NO logic in the database - CRUD
  • 22.
    Kingdom Driven Design DomainDriven Design Paranoid API Isolation ‱ Never leak the Domain – Keep Domain objects and services private – Define adapter interfaces in Domain, implement in separated Infrastructure layer – Application Layer as isolation layer
  • 23.
    Kingdom Driven Design DomainDriven Design Paranoid API Isolation ‱ Application Layer – Workflow Orchestration via Injection – Customized public APIs – Below presentation Layer (rich or web client) – Define Data Transfer Objects (DTOs)
  • 24.
    Kingdom Driven Design DomainDriven Design Paranoid Legacy Isolation ‱ Domain code is new/first/clean – NO copy & paste – Test Driven Design ‱ Legacy code injected as Seams – e.g. for the persistence layer or as external services
  • 25.
    Kingdom Driven Design DomainDriven Design Paranoid 3rd party Isolation ‱ Service Abstraction by Adapters – interfaces defined in Domain – class implemented outside the Domain (may be as a SaaS client) in the Infrastructure Layer – injected by the Application Layer
  • 26.
    Kingdom Driven Design DomainDriven Design Domain-Driven-Design
  • 27.
    Kingdom Driven Design DomainDriven Design Domain-Driven-Design Unbreakable Isolation
  • 28.
    Kingdom Driven Design DomainDriven Design is FUN, isn’t?
  • 29.
    Kingdom Driven Design KingdomDriven Design ‱ Domain Driven Design ‱ Return Of Experience ‱ Kingdom Driven Design
  • 30.
    Kingdom Driven Design ReturnOf Experience ‱ DDD in a DotNet project ‱ DDD in a Delphi project more than 5 years of DDD code writing and consulting
  • 31.
    Kingdom Driven Design ReturnOf Experience DDD in a DotNet project ‱ WCF, WPF, legacy DB ‱ Legacy Delphi & Java apps ‱ Verbose and not clean ‱ Services difficult to deploy
  • 32.
    Kingdom Driven Design ReturnOf Experience DDD in a DotNet project Legacy & Hybrid Cost
  • 33.
    Kingdom Driven Design ReturnOf Experience DDD in a Delphi project ‱ IoT high performance solution – “Things” agnostic (Domain as HAL) – Data sharding and CQRS – written from scratch – mORMot as toolbox
  • 34.
    Kingdom Driven Design ReturnOf Experience DDD in a Delphi project ‱ Following DDD rules has a cost – higher time-to-market, skilled developpers – users still prefer direct “Things” layer access – business don’t care (much) about DDD
  • 35.
    Kingdom Driven Design ReturnOf Experience DDD in a Delphi project ‱ mORMot toolbox helped but
 – persistence layer PODO to ORM mapping – asynch DDD service to synch public API – defining and translating a lot of DTOs
  • 36.
    Kingdom Driven Design ReturnOf Experience “Le mieux est le pire ennemi du bien” Charles-Louis de Montesquieu
  • 37.
    Kingdom Driven Design ReturnOf Experience “Le mieux est le pire ennemi du bien” Charles-Louis de Montesquieu “Perfect is the worst enemy of good”
  • 38.
    Kingdom Driven Design KingdomDriven Design ‱ Domain Driven Design ‱ Return Of Experience ‱ Kingdom Driven Design
  • 39.
    Kingdom Driven Design KingdomDriven Design From DDD to KDD reintroduce laziness
  • 40.
    Kingdom Driven Design KingdomDriven Design From DDD to KDD reintroduce laziness i.e. “the quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don't have to answer so many questions about it.” Larry Wall
  • 41.
    Kingdom Driven Design KingdomDriven Design From DDD to KDD ‱ a pragmatic cut-down version of DDD ‱ focusing on SOLID principles ‱ leveraging the Object Pascal platform
  • 42.
    Kingdom Driven Design KingdomDriven Design From DDD to KDD Kingdom isolation with no paranoia embrace business/human/time contingency
  • 43.
    Kingdom Driven Design KingdomDriven Design Taxonomic ranks
  • 44.
    Kingdom Driven Design KingdomDriven Design Kingdom ‱ Slightly closer to technology ‱ Disclaimer: – DDD had nothing to do with taxonomy – KDD is still Model-Driven-Design – Let your Kingdom come!
  • 45.
    Kingdom Driven Design KingdomDriven Design The Kingdom ‱ Well-identified ‱ (Complex) ‱ Access to Kingdom Experts ‱ Per Bounded Contexts
  • 46.
    Kingdom Driven Design KingdomDriven Design Keep your Kingdom code clean ‱ Ubiquitous Language Code naming follows reality but could be slightly polluted by technology (e.g. ORM or serialization class)
  • 47.
    Kingdom Driven Design KingdomDriven Design Keep your Kingdom code clean ‱ Pragmatic Isolation Objects, DB, API, legacy, 3rd party ‱ Rooted in SOLID principles practical OOP, Injection, MicroServices ‱ Leverage language and libraries RTTI, interfaces, SOA
  • 48.
    Kingdom Driven Design KingdomDriven Design Pragmatic Objects Isolation ‱ Use language/library features – Value Objects = records or variants – Entities = persistent classes – Aggregates = ORM classes – Events = records or variants
  • 49.
    Kingdom Driven Design KingdomDriven Design Pragmatic DB Isolation ‱ Agnostic Persistence layer is what an ORM is for  direct ORM use  no persistence interface / service ‱ NO logic in the database - CRUD
  • 50.
    Kingdom Driven Design KingdomDriven Design Pragmatic API Isolation ‱ Keep the Kingdom uncoupled – Define adapter interfaces in Kingdom, implement in separated Infrastructure layer – Application Layer as orchestration layer (just like Domain-Driven-Design)
  • 51.
    Kingdom Driven Design KingdomDriven Design Pragmatic API Isolation ‱ But may leak the Kingdom – Keep Kingdom services private – May expose Kingdom objects i.e. leak objects as properties (content) not with methods (process) e.g. JSON REST exposure
  • 52.
    Kingdom Driven Design KingdomDriven Design Pragmatic API Isolation ‱ Application Layer / public APIs – Workflow Orchestration via Injection Orchestrate rather than Isolate – Define Data Transfer Objects (DTOs) and/or expose Kingdom objects (JSON/variant) following pragmatic arbitrations
  • 53.
    Kingdom Driven Design KingdomDriven Design Pragmatic Legacy Isolation ‱ Kingdom code – copy & paste & adapt existing objects/DB – uncoupling as much as possible – introduce Test Driven Design ‱ Legacy code injected as Seams – e.g. persistence layer or external services
  • 54.
    Kingdom Driven Design KingdomDriven Design Kingdom 3rd party Isolation ‱ Service Abstraction by Adapters – interfaces defined in Kingdom – class implemented outside the Kingdom (may be as a SaaS client) in the Infrastructure Layer – injected by the Application Layer
  • 55.
    Kingdom Driven Design DomainDriven Design Domain-Driven-Design Unbreakable Isolation
  • 56.
    Kingdom Driven Design DomainDriven Design X Kingdom Layer Kingdom Model Kingdom Services Kingdom-Driven-Design
  • 57.
    Kingdom Driven Design KingdomDriven Design is Domain-Driven-Design but ‱ direct ORM persistence and library (ab)use (e.g. serialization) ‱ (maybe) leaked objects ‱ SOLID principles roots
  • 58.
    Kingdom Driven Design KingdomDriven Design is Domain-Driven-Design but ‱ direct ORM persistence tied to a given ORM/library ‱ (maybe) leaked objects harden any breaking change ‱ SOLID principles roots more technical code
  • 59.
    Kingdom Driven Design KingdomDriven Design Distributed MicroServices architecture Monolithic Distributed SOLID SOA
  • 60.
    Kingdom Driven Design KingdomDriven Design ‱ favors SOLID code over isolated code ‱ uncoupled MicroServices vs uncoupled code ‱ prefers convention over configuration ‱ small skilled team vs Conway’s Law separation ‱ leverages language/toolbox features ‱ for pragmatic Time-To-Market
  • 61.
    Kingdom Driven Design KingdomDriven Design ‱ Domain Driven Design ‱ Return Of Experience ‱ Kingdom Driven Design
  • 62.
    Kingdom Driven Design mORMotas KDD Toolbox 
 to be continued 
  • 63.
    Kingdom Driven Design ‱Questions? Kingdom Driven Design