SlideShare a Scribd company logo
Domain Driven Design
DAY 1
Spoiler
• DDD is not for the perfectionist
Spoiler
• DDD is not for the perfectionist
Spoiler
• DDD is not for the perfectionist
• DDD is based on incremental changes (backed by TDD)
Spoiler
• DDD is not for the perfectionist
• DDD is based on incremental changes (backed by TDD)
• Those changes must be guided by business requirements
Delivering Software
• Focused on the final client
• Use the same language
• Iterate over the requirements
Delivering Software => Complexity
Delivering Software => Complexity
Delivering Software => Complexity
Technical Debt
Delivering Software => Complexity
Delivering Software => Complexity
Solution
• Focus on business direction
• Strategic DDD
• Keep software as small as possible
• Tactical DDD
Strategic DDD
•Business
Knowledge
Strategic DDD
• Business Knowledge
• Technology is not important if it doesn’t fulfill its objective
• Solve people problems
Strategic DDD
• Ubiquitous Language
• Bounded Context
• Context Mapping
Ubiquitous Language
• A set of business words
• Usually nouns and verbs
Agent
Property
Agency
Sell Buy
Ad Contact
Bounded Context
• A set of business words that are part of the Ubiquitous Language
for a specific business area
Agent
Property
Agency
Sell Buy
Ad Contact
Context Mapping
• A set of business words that are part of the Ubiquitous Language
whose purpose is to share knowledge between Bounded Contexts
Agent
Property
Agency
Sell Buy
Ad Contact
Context Mapping
• A set of business words that are part of the Ubiquitous Language
whose purpose is to share knowledge between Bounded Contexts
Agent
Property
Agency
Sell Buy
Ad Contact
Publish
Context Mapping
• A set of business words that are part of the Ubiquitous Language
whose purpose is to share knowledge between Bounded Contexts
Ad Opportunity
Contact Property
Search Demand
Exercise 1
• Define the Ubiquitous Language of Real Estate
• Define the Bounded Context of Management
• Define the Bounded Context of Classifieds
• Define Context Mappings between Management and Classifieds
Tactical DDD
• Based on Model Driven Design
• Design Data & Behavior as Models
• Based on Clean Architecture Concepts
• SOLID (again)
Back to the SOLID
• Single Responsibility
• Responsibility is not based on code, but
on abstractions
• A good abstraction is more valuable
than good code
• But a good abstraction leads to better
code!
• Component responsibility evolves
during the project lifecycle
Domain
Layer
Back to the SOLID
• Open Closed
• Open for lower level abstractions, closed
to different implementations
• Abstractions backed by other ones
Contact Contact
DAO
Contact Service
Business Logic
Persistence
Business Transaction
Back to the SOLID
• Liskov Substitution
• Ability to change different
implementations that expose the same
abstraction
• Constrained by invariants, pre-
conditions and post-conditions
Client Agent Agency
Contactable
Contact
Back to the SOLID
• Interface Segregation
• Expose different abstractions with the
same implementation
• Different abstractions != God object
Agent
Contactable Publisher
Back to the SOLID
• Dependency Inversion
• Abstractions are backed by other higher-
level abstractions
• An abstraction must not depend directly
or indirectly on itself
Controller
Application Service
Domain Services
Domains
LevelofAbstraction
Model Driven Design
• Responsibility is distributed in models
• Models are an accurate representation of a business concept for a
concrete problem
• Models are stateful and logic-aware
• Models are not necessarily objects (but usually defined with them)
Model Driven Design vs Service Driven Design
Model Driven Design
Model Driven Design (with ADT)
Model Driven Design
• Everything should be a model (no defined granularity)
• Model interaction backed by services
• Persistence outside models (DAO)
Exercise 2
• Model the following user stories:
• As an Agent, I want to create a Property
• As an Agent, I want to publish a Property as an Ad
• As a Client, I want to contact an Agent through an Ad
• As an Agent, I want to unpublish an Ad
• You can use Java, C# or JavaScript for this exercise
Model Driven Design
• Properties of a Model:
• A model has invariants
• A model has multiple contracts
• A model is able to interact with other models
• A model is composed by other models
Invariants
• An invariant is a set of constraints based on the system state
• You can’t create a user without an email
• You can’t create two properties with the same ID
• Invariant violations must fail-fast
• A model must not exist in the system if its invariants are not full-filled
Invariants
Contracts
• A contract is the definition of the abstraction that the model solves
• User is a contract
• Agent is a contract
• Both can be implemented by any model
Model Interaction
• A model needs to interact with the environment, so the system can
work
• A single model is completely useless
Model Composition
• Models are composed by other models
• Primitives are not models, but state
• int, String or long are not business objects
• Avoid Primitive Obsession
• A Garbage Collector isn´t a performance problem
Model Composition
Domain Driven Design
• Layered Architecture
• 3 essential Layers
• Application
• Domain
• Infrastructure
• Model-centric
• Focused on data integrity
Domain
Application
Infrastructure
Domain Driven Design - Domain Layer
• AKA Business Layer
• Split in two components
• Aggregate Roots
• Domain Services
• Depends on Infrastructure
Domain
Service
Aggregate
Root
Infrastructure
Service
Domain Driven Design – Aggregate Root
• An Aggregate Root is the central part of data and business integrity
• Handles interaction with other domain objects
• Handles invariants related with other domain objects
• Aggregate Roots are Entities
Domain Driven Design – Entity
• An Entity is a business object that can be referred unequivocally by
a unique identifier.
• Entities are property of a Bounded Context
• An entity can’t be found in more than one Bounded Context
• Entities are a composition of Value Objects and business logic
Domain Driven Design – Entity
Domain Driven Design – Value Object
• A Value Object is a representation of a business value with its own
invariants and business logic
• Value Objects do not have identity
• Value Objects can be composed
• Value Objects must be immutable and shareable
• Value Objects also represent Entities in other Bounded Contexts
Domain Driven Design – Value Object
Domain Driven Design – Domain Services
• Handle business transactions
• Backed by aggregate roots and infrastructure services
• Must be ACID
• Atomic
• Consistent
• Isolated
• Durable
Domain Driven Design – Domain Services
• As A Visitor, I want to login
• Must Exist
• Must not be banned
• Must have been
verified
Find Visitor By
Email
• Password must
match
• Update Login Date
Login
• Persists New User
Info
• Notifies other
system players
about the event
Save User
Domain Driven Design – Domain Services
• As A Visitor, I want to login
Domain
Service
Aggregate
Root
Infrastructure
Service
Domain Driven Design – Domain Services
• As A Visitor, I want to login
Domain Driven Design – Infrastructure Services
• Handle data persistence
• Handle data integrity
• Handle system-wide invariants
• Unique Keys
• Sub-domain Invariants
• Communicate with 3rd party systems (like Event Buses, APIs or DBs)
Domain Driven Design – Infrastructure Services
• They can be categorized in:
• Domain Wide Infrastructure Services
• Repositories (!= DAOs)
• Event Publishers
• Command Publishers
• System Wide Infrastructure Services
• Marshallers
• Controllers
• Views
Domain Driven Design – Infrastructure Services
• Domain Wide Infrastructure Services are very special
• Their contract are part of the domain, not part of the infrastructure
• Repository interfaces are on the ´domain´ package
• They understand part of the domain language but they are not part of the
domain
• They must validate some invariants
• The relationship is simple: the same the developers have with their Product Owners
Domain Driven Design – Application Services
• Handle domain-wide transactions
• Understand domain language
• Application transactions are
eventually consistent
ApplicationService
Domain Service
Domain Service
Domain Service
Domain Driven Design – Application Services
Domain Driven Design & Test Driven Development
Domain Driven Design & Test Driven Development
•Are Friends 
TDD
• A tool for designing software
• The developer designs software while acquiring business
knowledge
TDD Basics
Green
(Work)
Refactor
(Refine)
Red
(Design)
TDD for Domain Driven Design
Green
(Work)
Refactor
(Refine)
Red
(Design)
Optional
TDD for Domain Driven Design
• Red
• Design the simplest concept required for a functional prototype
• Less classes are best! Think always about abstractions
• Green
• Just make it work
• Refactor
• Do not refactor for better code
• Do not design if you don´t have enough business knowledge
• Design top-down if you are not sure about the functionality
TDD for Domain Driven Design
Red Green
Acquire
Business
Knowledge
Refactor
TDD – Refactor
• Refactor is not a tool for better code!
• Refactor is a tool for better abstractions!
• Do not refactor until you have better knowledge of the problem.
TDD – Refactor Direction
Application
Service
Domain
Service
Aggregate
Root
Abstraction Level
TDD – Refactor
• Do not forget component responsibility
• When refactoring, Domain Services must be always responsible of one
domain and ACID
• Do not break abstractions never
• If you need to break something, always break encapsulation instead of
abstractions
• Commits are a unit of time, software evolves, don’t try to create
perfect code

More Related Content

What's hot

Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)
IT Arena
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Harsh Jegadeesan
 
DDD Basics - Context mapping
DDD Basics - Context mappingDDD Basics - Context mapping
DDD Basics - Context mapping
Stijn Volders
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
its_skm
 
Modelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven DesignModelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven Design
Naeem Sarfraz
 
Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"
bincangteknologi
 
ZendCon 2011 UnCon Domain-Driven Design
ZendCon 2011 UnCon Domain-Driven DesignZendCon 2011 UnCon Domain-Driven Design
ZendCon 2011 UnCon Domain-Driven Design
Bradley Holt
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Nader Albert
 
SOAT Agile Day 2017 DDD
SOAT Agile Day 2017 DDDSOAT Agile Day 2017 DDD
SOAT Agile Day 2017 DDD
Gregory Boissinot
 
Domain Driven Design - Building Blocks
Domain Driven Design - Building BlocksDomain Driven Design - Building Blocks
Domain Driven Design - Building Blocks
Mark Windholtz
 
CQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureCQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architecture
Thomas Jaskula
 
Domain Driven Design Communication Techniques
Domain Driven Design Communication TechniquesDomain Driven Design Communication Techniques
Domain Driven Design Communication Techniques
Mark Windholtz
 
Domain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureDomain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal Architecture
Crishantha Nanayakkara
 
Domain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic PatternsDomain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic Patterns
Mark Windholtz
 
Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15
Mark Windholtz
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLC
Abdul Karim
 
DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018
DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018
DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018
Paulo Clavijo
 
Cultivating Your Design Heuristics
Cultivating Your Design HeuristicsCultivating Your Design Heuristics
Cultivating Your Design Heuristics
Rebecca Wirfs-Brock
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design Quickly
Mariam Hakobyan
 
Domain Driven Design - DDDSydney 2011
Domain Driven Design - DDDSydney 2011Domain Driven Design - DDDSydney 2011
Domain Driven Design - DDDSydney 2011
thinkddd
 

What's hot (20)

Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)Domain-Driven Design (Artur Trosin Product Stream)
Domain-Driven Design (Artur Trosin Product Stream)
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
DDD Basics - Context mapping
DDD Basics - Context mappingDDD Basics - Context mapping
DDD Basics - Context mapping
 
Domain driven design
Domain driven designDomain driven design
Domain driven design
 
Modelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven DesignModelling a complex domain with Domain-Driven Design
Modelling a complex domain with Domain-Driven Design
 
Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"Domain-Driven Design: The "What" and the "Why"
Domain-Driven Design: The "What" and the "Why"
 
ZendCon 2011 UnCon Domain-Driven Design
ZendCon 2011 UnCon Domain-Driven DesignZendCon 2011 UnCon Domain-Driven Design
ZendCon 2011 UnCon Domain-Driven Design
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
SOAT Agile Day 2017 DDD
SOAT Agile Day 2017 DDDSOAT Agile Day 2017 DDD
SOAT Agile Day 2017 DDD
 
Domain Driven Design - Building Blocks
Domain Driven Design - Building BlocksDomain Driven Design - Building Blocks
Domain Driven Design - Building Blocks
 
CQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureCQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architecture
 
Domain Driven Design Communication Techniques
Domain Driven Design Communication TechniquesDomain Driven Design Communication Techniques
Domain Driven Design Communication Techniques
 
Domain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal ArchitectureDomain Driven Design and Hexagonal Architecture
Domain Driven Design and Hexagonal Architecture
 
Domain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic PatternsDomain Driven Design Big Picture Strategic Patterns
Domain Driven Design Big Picture Strategic Patterns
 
Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15Domain Driven Design - Distillation - Chapter 15
Domain Driven Design - Distillation - Chapter 15
 
How to Implement Domain Driven Design in Real Life SDLC
How to Implement Domain Driven Design  in Real Life SDLCHow to Implement Domain Driven Design  in Real Life SDLC
How to Implement Domain Driven Design in Real Life SDLC
 
DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018
DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018
DDD Strategic Design - Context Maps - Paulo Clavijo - April 2018
 
Cultivating Your Design Heuristics
Cultivating Your Design HeuristicsCultivating Your Design Heuristics
Cultivating Your Design Heuristics
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design Quickly
 
Domain Driven Design - DDDSydney 2011
Domain Driven Design - DDDSydney 2011Domain Driven Design - DDDSydney 2011
Domain Driven Design - DDDSydney 2011
 

Similar to Schibsted Spain - Day 1 - DDD Course

Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDD
Eduards Sizovs
 
Code & Cannoli - Domain Driven Design
Code & Cannoli - Domain Driven DesignCode & Cannoli - Domain Driven Design
Code & Cannoli - Domain Driven Design
Frank Levering
 
An Introduction to Domain Driven Design in PHP
An Introduction to Domain Driven Design in PHPAn Introduction to Domain Driven Design in PHP
An Introduction to Domain Driven Design in PHP
Chris Renner
 
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
Domain Driven Design Ruby Ways -  JURNAL 05/10/2017Domain Driven Design Ruby Ways -  JURNAL 05/10/2017
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
Jonathan Wylliem
 
DDD with ASP.NET MVC - Steve Smith | FalafelCON 2014
DDD with ASP.NET MVC - Steve Smith | FalafelCON 2014DDD with ASP.NET MVC - Steve Smith | FalafelCON 2014
DDD with ASP.NET MVC - Steve Smith | FalafelCON 2014
FalafelSoftware
 
Domain-Driven Design with ASP.NET MVC
Domain-Driven Design with ASP.NET MVCDomain-Driven Design with ASP.NET MVC
Domain-Driven Design with ASP.NET MVC
Steven Smith
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Up2 Technology
 
2019-Nov: Domain Driven Design (DDD) and when not to use it
2019-Nov: Domain Driven Design (DDD) and when not to use it2019-Nov: Domain Driven Design (DDD) and when not to use it
2019-Nov: Domain Driven Design (DDD) and when not to use it
Mark Windholtz
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Tomas Dermisek
 
Ten Advices for Architects
Ten Advices for ArchitectsTen Advices for Architects
Ten Advices for Architects
Eberhard Wolff
 
Software Engineering - Trends & Industry Practices
Software Engineering - Trends & Industry PracticesSoftware Engineering - Trends & Industry Practices
Software Engineering - Trends & Industry Practices
Alfred Jett Grandeza
 
10 Hinweise für Architekten
10 Hinweise für Architekten10 Hinweise für Architekten
10 Hinweise für Architekten
adesso AG
 
Applying Domain-Driven Design to craft Rich Domain Models
Applying Domain-Driven Design to craft Rich Domain ModelsApplying Domain-Driven Design to craft Rich Domain Models
Applying Domain-Driven Design to craft Rich Domain Models
Alexander van Trijffel
 
DOMAIN DRIVER DESIGN
DOMAIN DRIVER DESIGNDOMAIN DRIVER DESIGN
DOMAIN DRIVER DESIGN
Mohammed Fazuluddin
 
Art of refactoring - Code Smells and Microservices Antipatterns
Art of refactoring - Code Smells and Microservices AntipatternsArt of refactoring - Code Smells and Microservices Antipatterns
Art of refactoring - Code Smells and Microservices Antipatterns
El Mahdi Benzekri
 
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
NETFest
 
Prashant technical practices-tdd for xebia event
Prashant   technical practices-tdd for xebia eventPrashant   technical practices-tdd for xebia event
Prashant technical practices-tdd for xebia event
Xebia India
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
Hannah Farrugia
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
Confiz
 
From Rails legacy to DDD - Pivorak, Lviv
From Rails legacy to DDD - Pivorak, LvivFrom Rails legacy to DDD - Pivorak, Lviv
From Rails legacy to DDD - Pivorak, Lviv
Andrzej Krzywda
 

Similar to Schibsted Spain - Day 1 - DDD Course (20)

Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDD
 
Code & Cannoli - Domain Driven Design
Code & Cannoli - Domain Driven DesignCode & Cannoli - Domain Driven Design
Code & Cannoli - Domain Driven Design
 
An Introduction to Domain Driven Design in PHP
An Introduction to Domain Driven Design in PHPAn Introduction to Domain Driven Design in PHP
An Introduction to Domain Driven Design in PHP
 
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
Domain Driven Design Ruby Ways -  JURNAL 05/10/2017Domain Driven Design Ruby Ways -  JURNAL 05/10/2017
Domain Driven Design Ruby Ways - JURNAL 05/10/2017
 
DDD with ASP.NET MVC - Steve Smith | FalafelCON 2014
DDD with ASP.NET MVC - Steve Smith | FalafelCON 2014DDD with ASP.NET MVC - Steve Smith | FalafelCON 2014
DDD with ASP.NET MVC - Steve Smith | FalafelCON 2014
 
Domain-Driven Design with ASP.NET MVC
Domain-Driven Design with ASP.NET MVCDomain-Driven Design with ASP.NET MVC
Domain-Driven Design with ASP.NET MVC
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
2019-Nov: Domain Driven Design (DDD) and when not to use it
2019-Nov: Domain Driven Design (DDD) and when not to use it2019-Nov: Domain Driven Design (DDD) and when not to use it
2019-Nov: Domain Driven Design (DDD) and when not to use it
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Ten Advices for Architects
Ten Advices for ArchitectsTen Advices for Architects
Ten Advices for Architects
 
Software Engineering - Trends & Industry Practices
Software Engineering - Trends & Industry PracticesSoftware Engineering - Trends & Industry Practices
Software Engineering - Trends & Industry Practices
 
10 Hinweise für Architekten
10 Hinweise für Architekten10 Hinweise für Architekten
10 Hinweise für Architekten
 
Applying Domain-Driven Design to craft Rich Domain Models
Applying Domain-Driven Design to craft Rich Domain ModelsApplying Domain-Driven Design to craft Rich Domain Models
Applying Domain-Driven Design to craft Rich Domain Models
 
DOMAIN DRIVER DESIGN
DOMAIN DRIVER DESIGNDOMAIN DRIVER DESIGN
DOMAIN DRIVER DESIGN
 
Art of refactoring - Code Smells and Microservices Antipatterns
Art of refactoring - Code Smells and Microservices AntipatternsArt of refactoring - Code Smells and Microservices Antipatterns
Art of refactoring - Code Smells and Microservices Antipatterns
 
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
.NET Fest 2019. Halil Ibrahim Kalkan. Implementing Domain Driven Design
 
Prashant technical practices-tdd for xebia event
Prashant   technical practices-tdd for xebia eventPrashant   technical practices-tdd for xebia event
Prashant technical practices-tdd for xebia event
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
 
From Rails legacy to DDD - Pivorak, Lviv
From Rails legacy to DDD - Pivorak, LvivFrom Rails legacy to DDD - Pivorak, Lviv
From Rails legacy to DDD - Pivorak, Lviv
 

Recently uploaded

Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
kalichargn70th171
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 

Recently uploaded (20)

Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
Why Mobile App Regression Testing is Critical for Sustained Success_ A Detail...
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 

Schibsted Spain - Day 1 - DDD Course

  • 2. Spoiler • DDD is not for the perfectionist
  • 3. Spoiler • DDD is not for the perfectionist
  • 4. Spoiler • DDD is not for the perfectionist • DDD is based on incremental changes (backed by TDD)
  • 5. Spoiler • DDD is not for the perfectionist • DDD is based on incremental changes (backed by TDD) • Those changes must be guided by business requirements
  • 6. Delivering Software • Focused on the final client • Use the same language • Iterate over the requirements
  • 9. Delivering Software => Complexity Technical Debt
  • 12. Solution • Focus on business direction • Strategic DDD • Keep software as small as possible • Tactical DDD
  • 14. Strategic DDD • Business Knowledge • Technology is not important if it doesn’t fulfill its objective • Solve people problems
  • 15. Strategic DDD • Ubiquitous Language • Bounded Context • Context Mapping
  • 16. Ubiquitous Language • A set of business words • Usually nouns and verbs Agent Property Agency Sell Buy Ad Contact
  • 17. Bounded Context • A set of business words that are part of the Ubiquitous Language for a specific business area Agent Property Agency Sell Buy Ad Contact
  • 18. Context Mapping • A set of business words that are part of the Ubiquitous Language whose purpose is to share knowledge between Bounded Contexts Agent Property Agency Sell Buy Ad Contact
  • 19. Context Mapping • A set of business words that are part of the Ubiquitous Language whose purpose is to share knowledge between Bounded Contexts Agent Property Agency Sell Buy Ad Contact Publish
  • 20. Context Mapping • A set of business words that are part of the Ubiquitous Language whose purpose is to share knowledge between Bounded Contexts Ad Opportunity Contact Property Search Demand
  • 21. Exercise 1 • Define the Ubiquitous Language of Real Estate • Define the Bounded Context of Management • Define the Bounded Context of Classifieds • Define Context Mappings between Management and Classifieds
  • 22. Tactical DDD • Based on Model Driven Design • Design Data & Behavior as Models • Based on Clean Architecture Concepts • SOLID (again)
  • 23. Back to the SOLID • Single Responsibility • Responsibility is not based on code, but on abstractions • A good abstraction is more valuable than good code • But a good abstraction leads to better code! • Component responsibility evolves during the project lifecycle Domain Layer
  • 24. Back to the SOLID • Open Closed • Open for lower level abstractions, closed to different implementations • Abstractions backed by other ones Contact Contact DAO Contact Service Business Logic Persistence Business Transaction
  • 25. Back to the SOLID • Liskov Substitution • Ability to change different implementations that expose the same abstraction • Constrained by invariants, pre- conditions and post-conditions Client Agent Agency Contactable Contact
  • 26. Back to the SOLID • Interface Segregation • Expose different abstractions with the same implementation • Different abstractions != God object Agent Contactable Publisher
  • 27. Back to the SOLID • Dependency Inversion • Abstractions are backed by other higher- level abstractions • An abstraction must not depend directly or indirectly on itself Controller Application Service Domain Services Domains LevelofAbstraction
  • 28. Model Driven Design • Responsibility is distributed in models • Models are an accurate representation of a business concept for a concrete problem • Models are stateful and logic-aware • Models are not necessarily objects (but usually defined with them)
  • 29. Model Driven Design vs Service Driven Design
  • 31. Model Driven Design (with ADT)
  • 32. Model Driven Design • Everything should be a model (no defined granularity) • Model interaction backed by services • Persistence outside models (DAO)
  • 33. Exercise 2 • Model the following user stories: • As an Agent, I want to create a Property • As an Agent, I want to publish a Property as an Ad • As a Client, I want to contact an Agent through an Ad • As an Agent, I want to unpublish an Ad • You can use Java, C# or JavaScript for this exercise
  • 34. Model Driven Design • Properties of a Model: • A model has invariants • A model has multiple contracts • A model is able to interact with other models • A model is composed by other models
  • 35. Invariants • An invariant is a set of constraints based on the system state • You can’t create a user without an email • You can’t create two properties with the same ID • Invariant violations must fail-fast • A model must not exist in the system if its invariants are not full-filled
  • 37. Contracts • A contract is the definition of the abstraction that the model solves • User is a contract • Agent is a contract • Both can be implemented by any model
  • 38. Model Interaction • A model needs to interact with the environment, so the system can work • A single model is completely useless
  • 39. Model Composition • Models are composed by other models • Primitives are not models, but state • int, String or long are not business objects • Avoid Primitive Obsession • A Garbage Collector isn´t a performance problem
  • 41. Domain Driven Design • Layered Architecture • 3 essential Layers • Application • Domain • Infrastructure • Model-centric • Focused on data integrity Domain Application Infrastructure
  • 42. Domain Driven Design - Domain Layer • AKA Business Layer • Split in two components • Aggregate Roots • Domain Services • Depends on Infrastructure Domain Service Aggregate Root Infrastructure Service
  • 43. Domain Driven Design – Aggregate Root • An Aggregate Root is the central part of data and business integrity • Handles interaction with other domain objects • Handles invariants related with other domain objects • Aggregate Roots are Entities
  • 44. Domain Driven Design – Entity • An Entity is a business object that can be referred unequivocally by a unique identifier. • Entities are property of a Bounded Context • An entity can’t be found in more than one Bounded Context • Entities are a composition of Value Objects and business logic
  • 45. Domain Driven Design – Entity
  • 46. Domain Driven Design – Value Object • A Value Object is a representation of a business value with its own invariants and business logic • Value Objects do not have identity • Value Objects can be composed • Value Objects must be immutable and shareable • Value Objects also represent Entities in other Bounded Contexts
  • 47. Domain Driven Design – Value Object
  • 48. Domain Driven Design – Domain Services • Handle business transactions • Backed by aggregate roots and infrastructure services • Must be ACID • Atomic • Consistent • Isolated • Durable
  • 49. Domain Driven Design – Domain Services • As A Visitor, I want to login • Must Exist • Must not be banned • Must have been verified Find Visitor By Email • Password must match • Update Login Date Login • Persists New User Info • Notifies other system players about the event Save User
  • 50. Domain Driven Design – Domain Services • As A Visitor, I want to login Domain Service Aggregate Root Infrastructure Service
  • 51. Domain Driven Design – Domain Services • As A Visitor, I want to login
  • 52. Domain Driven Design – Infrastructure Services • Handle data persistence • Handle data integrity • Handle system-wide invariants • Unique Keys • Sub-domain Invariants • Communicate with 3rd party systems (like Event Buses, APIs or DBs)
  • 53. Domain Driven Design – Infrastructure Services • They can be categorized in: • Domain Wide Infrastructure Services • Repositories (!= DAOs) • Event Publishers • Command Publishers • System Wide Infrastructure Services • Marshallers • Controllers • Views
  • 54. Domain Driven Design – Infrastructure Services • Domain Wide Infrastructure Services are very special • Their contract are part of the domain, not part of the infrastructure • Repository interfaces are on the ´domain´ package • They understand part of the domain language but they are not part of the domain • They must validate some invariants • The relationship is simple: the same the developers have with their Product Owners
  • 55. Domain Driven Design – Application Services • Handle domain-wide transactions • Understand domain language • Application transactions are eventually consistent ApplicationService Domain Service Domain Service Domain Service
  • 56. Domain Driven Design – Application Services
  • 57. Domain Driven Design & Test Driven Development
  • 58. Domain Driven Design & Test Driven Development •Are Friends 
  • 59. TDD • A tool for designing software • The developer designs software while acquiring business knowledge
  • 61. TDD for Domain Driven Design Green (Work) Refactor (Refine) Red (Design) Optional
  • 62. TDD for Domain Driven Design • Red • Design the simplest concept required for a functional prototype • Less classes are best! Think always about abstractions • Green • Just make it work • Refactor • Do not refactor for better code • Do not design if you don´t have enough business knowledge • Design top-down if you are not sure about the functionality
  • 63. TDD for Domain Driven Design Red Green Acquire Business Knowledge Refactor
  • 64. TDD – Refactor • Refactor is not a tool for better code! • Refactor is a tool for better abstractions! • Do not refactor until you have better knowledge of the problem.
  • 65. TDD – Refactor Direction Application Service Domain Service Aggregate Root Abstraction Level
  • 66. TDD – Refactor • Do not forget component responsibility • When refactoring, Domain Services must be always responsible of one domain and ACID • Do not break abstractions never • If you need to break something, always break encapsulation instead of abstractions • Commits are a unit of time, software evolves, don’t try to create perfect code