SlideShare a Scribd company logo
Applying Object Composition
to Build Rich Domain Models
Zoran Horvat
CEO & Principal Consultant, Coding Helmet Consultancy
zh@sysexpand.com
http://codinghelmet.com
zoranh75
https://pluralsight.com/authors/zoran-horvat
zh@sysexpand.com
http://codinghelmet.com
zoranh75
Watch the webinar recording here:
https://www.postsharp.net/blog/we
binar-recording-object-composition
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Animal obj = ...
Animal obj = ...
if (obj is Mammal)
{
}
Animal obj = ...
if (obj is Mammal)
{
Mammal mammal = (Mammal)obj; // e.g. a tiger
}
Animal obj = ...
if (obj is Mammal)
{
Mammal mammal = (Mammal)obj; // e.g. a tiger
// Pull mammal’s tail using all your strength
}
Animal obj = ...
if (obj is Mammal)
{
Mammal mammal = (Mammal)obj; // e.g. a tiger
// Pull mammal’s tail using all your strength
// Run as fast as you can
}
Animal obj = ...
if (obj is Mammal)
{
Mammal mammal = (Mammal)obj; // e.g. a tiger
// Pull mammal’s tail using all your strength
// Run as fast as you can
}
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Animal obj = ...
if (obj is Mammal)
{
Mammal mammal = (Mammal)obj; // e.g. a tiger
// Pull mammal’s tail using all your strength
// Run as fast as you can
}
Animal obj = ...
if (obj is Mammal)
{
Mammal mammal = (Mammal)obj; // e.g. a tiger
// Pull mammal’s tail using all your strength
// Run as fast as you can
}
else if (obj is WaterMammal)
{
WaterMammal mammal = (WaterMammal)obj; // e.g. a whale
// Pull mammal’s fins using all your strength
// Swim as fast as you can
}
Animal obj = ...
if (obj is Mammal)
{
Mammal mammal = (Mammal)obj; // e.g. a tiger
// Pull mammal’s tail using all your strength
// Run as fast as you can
}
else if (obj is WaterMammal)
{
WaterMammal mammal = (WaterMammal)obj; // e.g. a whale
// Pull mammal’s fins using all your strength
// Swim as fast as you can
}
Logic
duplication,
but no true
code duplication!
Animal obj = ...
if (obj is Mammal)
{
Mammal mammal = (Mammal)obj; // e.g. a tiger
// Pull mammal’s tail using all your strength
// Run as fast as you can
}
else if (obj is WaterMammal)
{
WaterMammal mammal = (WaterMammal)obj; // e.g. a whale
// Pull mammal’s fins using all your strength
// Swim as fast as you can
}
.
Logic
duplication,
but no true
code duplication!
Animal obj = ...
if (obj is Mammal)
{
Mammal mammal = (Mammal)obj; // e.g. a tiger
// Pull mammal’s tail using all your strength
// Run as fast as you can
}
else if (obj is WaterMammal)
{
WaterMammal mammal = (WaterMammal)obj; // e.g. a whale
// Pull mammal’s fins using all your strength
// Swim as fast as you can
}
.
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Watch the webinar recording here:
https://www.postsharp.net/blog/we
binar-recording-object-composition
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Watch the webinar recording here:
https://www.postsharp.net/blog/we
binar-recording-object-composition
Animal Classification Environment Abilities
Animal Classification Environment Abilities
Mammal Ground Walk, Run
Animal Classification Environment Abilities
Mammal Ground Walk, Run
Mammal Ground Walk, Run
Animal Classification Environment Abilities
Mammal Ground Walk, Run
Mammal Ground Walk, Run
Bird Ground Walk, Run
Bird Ground Walk, Run
Animal Classification Environment Abilities
Mammal Ground Walk, Run
Mammal Ground Walk, Run
Bird Ground Walk, Run
Bird Ground Walk, Run
Reptile Ground Walk
Animal Classification Environment Abilities
Mammal Ground Walk, Run
Mammal Ground Walk, Run
Bird Ground Walk, Run
Bird Ground Walk, Run
Reptile Ground Walk
Gastropod Ground Walk (?)
Animal Classification Environment Abilities
Mammal Ground Walk, Run
Mammal Ground Walk, Run
Bird Ground Walk, Run
Bird Ground Walk, Run
Reptile Ground Walk
Gastropod Ground Walk (?)
Mammal SaltWater Surface, Dive, Underwater
Mammal SaltWater Surface, Dive, Underwater
Animal Classification Environment Abilities
Mammal Ground Walk, Run
Mammal Ground Walk, Run
Bird Ground Walk, Run
Bird Ground Walk, Run
Reptile Ground Walk
Gastropod Ground Walk (?)
Mammal SaltWater Surface, Dive, Underwater
Mammal SaltWater Surface, Dive, Underwater
BonyFish SaltWater Underwater, Glide
BonyFish FreshWater Underwater
Animal Classification Environment Abilities
Mammal Ground Walk, Run
Mammal Ground Walk, Run
Bird Ground Walk, Run
Bird Ground Walk, Run
Reptile Ground Walk
Gastropod Ground Walk (?)
Mammal SaltWater Surface, Dive, Underwater
Mammal SaltWater Surface, Dive, Underwater
BonyFish SaltWater Underwater, Glide
BonyFish FreshWater Underwater
Bird Air, Ground Fly, Walk
Bird Air, Ground Fly
Animal Classification Environment Abilities
Mammal Ground Walk, Run
Mammal Ground Walk, Run
Bird Ground Walk, Run
Bird Ground Walk, Run
Reptile Ground Walk
Gastropod Ground Walk (?)
Mammal SaltWater Surface, Dive, Underwater
Mammal SaltWater Surface, Dive, Underwater
BonyFish SaltWater Underwater, Glide
BonyFish FreshWater Underwater
Bird Air, Ground Fly, Walk
Bird Air, Ground Fly
Mammal Ground Walk, Run, Glide
Animal Classification Environment Abilities
Mammal Ground Walk, Run
Mammal Ground Walk, Run
Bird Ground Walk, Run
Bird Ground Walk, Run
Reptile Ground Walk
Gastropod Ground Walk (?)
Mammal SaltWater Surface, Dive, Underwater
Mammal SaltWater Surface, Dive, Underwater
BonyFish SaltWater Underwater, Glide
BonyFish FreshWater Underwater
Bird Air, Ground Fly, Walk
Bird Air, Ground Fly
Mammal Ground Walk, Run, Glide
Mammal Air, Ground Fly
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Applying Object Composition to Build Rich Domain Models
Double
dispatch
ability.Accept(visitor);
void Run.Accept(AbilityVisitor visitor)
{
visitor.Accept(this); // Accept(Run)
}
Watch the webinar recording here:
https://www.postsharp.net/blog/we
binar-recording-object-composition
Questions?
Zoran Horvat
CEO & Principal Consultant, Coding Helmet Consultancy
zh@sysexpand.com
http://codinghelmet.com
zoranh75

More Related Content

PPTX
Advanced Defensive Coding Techniques (with Introduction to Design by Contract)
PPTX
Performance is a Feature!
PPTX
Building Better Architecture with UX-Driven Design
PPTX
Applying a Methodical Approach to Website Performance
PDF
Solving Localization Challenges with Design Pattern Automation
ODP
jTransfo lightning talk
PPTX
Mapping Problem Domain Objects to Object-Persistence Formats(OOAD)
PDF
Modularity and Domain Driven Design; a killer combination?
Advanced Defensive Coding Techniques (with Introduction to Design by Contract)
Performance is a Feature!
Building Better Architecture with UX-Driven Design
Applying a Methodical Approach to Website Performance
Solving Localization Challenges with Design Pattern Automation
jTransfo lightning talk
Mapping Problem Domain Objects to Object-Persistence Formats(OOAD)
Modularity and Domain Driven Design; a killer combination?

Viewers also liked (20)

KEY
ZendCon 2011 UnCon Domain-Driven Design
PPT
Domain driven design in a nutshell
PPTX
Success by Challenging Assumptions (Part I)
PPTX
Domain Driven Design Quickly
PDF
Introduction to Domain Driven Design
PDF
Introduction to-ddd
PPTX
Domain State model OOAD
PPTX
Domain Driven Design
PDF
Domain Driven Design and Hexagonal Architecture with Rails
PDF
Refactoring for Domain Driven Design
PPT
Domain object model
PDF
Why Domain-Driven Design Matters
PDF
Domain Driven Design Introduction
PDF
Domain-Driven Design with ASP.NET MVC
PPT
Domain Driven Design (DDD)
PPTX
Implementing DDD with C#
PPTX
A Practical Guide to Domain Driven Design: Presentation Slides
PDF
From object oriented to functional domain modeling
PPTX
Implementing DDD Concepts in PHP
PPTX
Domain Driven Design 101
ZendCon 2011 UnCon Domain-Driven Design
Domain driven design in a nutshell
Success by Challenging Assumptions (Part I)
Domain Driven Design Quickly
Introduction to Domain Driven Design
Introduction to-ddd
Domain State model OOAD
Domain Driven Design
Domain Driven Design and Hexagonal Architecture with Rails
Refactoring for Domain Driven Design
Domain object model
Why Domain-Driven Design Matters
Domain Driven Design Introduction
Domain-Driven Design with ASP.NET MVC
Domain Driven Design (DDD)
Implementing DDD with C#
A Practical Guide to Domain Driven Design: Presentation Slides
From object oriented to functional domain modeling
Implementing DDD Concepts in PHP
Domain Driven Design 101
Ad

Similar to Applying Object Composition to Build Rich Domain Models (13)

PPTX
Why Copy-Paste is Bad for Your Code
PPTX
Gamificaciónnnnnn completo para estudiantes
DOCX
Application Animal Characteristics In today’.docx
PPTX
Object oriented programming
PPTX
Option D Relacion de Conceptos basicos de modelamiento
PPT
09 inheritance and_uml
DOC
Lab exp (creating classes and objects)
PPTX
Approaching Patterns How to Apply
PPT
cs1311lecture22wdl.ppt
PPT
Pplymorphism
PPT
cs1311lecture22wdl (1).ppt
PPT
cs1311lecture22wdl.ppt this is oops feature polymorphism
ZIP
Genetic Algorithms and Particle Swarm Optimisation @ Flash Brighton, 28th Jul...
Why Copy-Paste is Bad for Your Code
Gamificaciónnnnnn completo para estudiantes
Application Animal Characteristics In today’.docx
Object oriented programming
Option D Relacion de Conceptos basicos de modelamiento
09 inheritance and_uml
Lab exp (creating classes and objects)
Approaching Patterns How to Apply
cs1311lecture22wdl.ppt
Pplymorphism
cs1311lecture22wdl (1).ppt
cs1311lecture22wdl.ppt this is oops feature polymorphism
Genetic Algorithms and Particle Swarm Optimisation @ Flash Brighton, 28th Jul...
Ad

Recently uploaded (20)

PDF
medical staffing services at VALiNTRY
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Digital Strategies for Manufacturing Companies
PPTX
Essential Infomation Tech presentation.pptx
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Transform Your Business with a Software ERP System
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
System and Network Administration Chapter 2
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
System and Network Administraation Chapter 3
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
medical staffing services at VALiNTRY
How Creative Agencies Leverage Project Management Software.pdf
Digital Strategies for Manufacturing Companies
Essential Infomation Tech presentation.pptx
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Transform Your Business with a Software ERP System
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Wondershare Filmora 15 Crack With Activation Key [2025
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
System and Network Administration Chapter 2
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
wealthsignaloriginal-com-DS-text-... (1).pdf
System and Network Administraation Chapter 3
Design an Analysis of Algorithms I-SECS-1021-03
2025 Textile ERP Trends: SAP, Odoo & Oracle

Applying Object Composition to Build Rich Domain Models

  • 1. Applying Object Composition to Build Rich Domain Models Zoran Horvat CEO & Principal Consultant, Coding Helmet Consultancy zh@sysexpand.com http://codinghelmet.com zoranh75
  • 3. Watch the webinar recording here: https://www.postsharp.net/blog/we binar-recording-object-composition
  • 15. Animal obj = ... if (obj is Mammal) { }
  • 16. Animal obj = ... if (obj is Mammal) { Mammal mammal = (Mammal)obj; // e.g. a tiger }
  • 17. Animal obj = ... if (obj is Mammal) { Mammal mammal = (Mammal)obj; // e.g. a tiger // Pull mammal’s tail using all your strength }
  • 18. Animal obj = ... if (obj is Mammal) { Mammal mammal = (Mammal)obj; // e.g. a tiger // Pull mammal’s tail using all your strength // Run as fast as you can }
  • 19. Animal obj = ... if (obj is Mammal) { Mammal mammal = (Mammal)obj; // e.g. a tiger // Pull mammal’s tail using all your strength // Run as fast as you can }
  • 22. Animal obj = ... if (obj is Mammal) { Mammal mammal = (Mammal)obj; // e.g. a tiger // Pull mammal’s tail using all your strength // Run as fast as you can }
  • 23. Animal obj = ... if (obj is Mammal) { Mammal mammal = (Mammal)obj; // e.g. a tiger // Pull mammal’s tail using all your strength // Run as fast as you can } else if (obj is WaterMammal) { WaterMammal mammal = (WaterMammal)obj; // e.g. a whale // Pull mammal’s fins using all your strength // Swim as fast as you can }
  • 24. Animal obj = ... if (obj is Mammal) { Mammal mammal = (Mammal)obj; // e.g. a tiger // Pull mammal’s tail using all your strength // Run as fast as you can } else if (obj is WaterMammal) { WaterMammal mammal = (WaterMammal)obj; // e.g. a whale // Pull mammal’s fins using all your strength // Swim as fast as you can }
  • 25. Logic duplication, but no true code duplication! Animal obj = ... if (obj is Mammal) { Mammal mammal = (Mammal)obj; // e.g. a tiger // Pull mammal’s tail using all your strength // Run as fast as you can } else if (obj is WaterMammal) { WaterMammal mammal = (WaterMammal)obj; // e.g. a whale // Pull mammal’s fins using all your strength // Swim as fast as you can } .
  • 26. Logic duplication, but no true code duplication! Animal obj = ... if (obj is Mammal) { Mammal mammal = (Mammal)obj; // e.g. a tiger // Pull mammal’s tail using all your strength // Run as fast as you can } else if (obj is WaterMammal) { WaterMammal mammal = (WaterMammal)obj; // e.g. a whale // Pull mammal’s fins using all your strength // Swim as fast as you can } .
  • 38. Watch the webinar recording here: https://www.postsharp.net/blog/we binar-recording-object-composition
  • 48. Watch the webinar recording here: https://www.postsharp.net/blog/we binar-recording-object-composition
  • 50. Animal Classification Environment Abilities Mammal Ground Walk, Run
  • 51. Animal Classification Environment Abilities Mammal Ground Walk, Run Mammal Ground Walk, Run
  • 52. Animal Classification Environment Abilities Mammal Ground Walk, Run Mammal Ground Walk, Run Bird Ground Walk, Run Bird Ground Walk, Run
  • 53. Animal Classification Environment Abilities Mammal Ground Walk, Run Mammal Ground Walk, Run Bird Ground Walk, Run Bird Ground Walk, Run Reptile Ground Walk
  • 54. Animal Classification Environment Abilities Mammal Ground Walk, Run Mammal Ground Walk, Run Bird Ground Walk, Run Bird Ground Walk, Run Reptile Ground Walk Gastropod Ground Walk (?)
  • 55. Animal Classification Environment Abilities Mammal Ground Walk, Run Mammal Ground Walk, Run Bird Ground Walk, Run Bird Ground Walk, Run Reptile Ground Walk Gastropod Ground Walk (?) Mammal SaltWater Surface, Dive, Underwater Mammal SaltWater Surface, Dive, Underwater
  • 56. Animal Classification Environment Abilities Mammal Ground Walk, Run Mammal Ground Walk, Run Bird Ground Walk, Run Bird Ground Walk, Run Reptile Ground Walk Gastropod Ground Walk (?) Mammal SaltWater Surface, Dive, Underwater Mammal SaltWater Surface, Dive, Underwater BonyFish SaltWater Underwater, Glide BonyFish FreshWater Underwater
  • 57. Animal Classification Environment Abilities Mammal Ground Walk, Run Mammal Ground Walk, Run Bird Ground Walk, Run Bird Ground Walk, Run Reptile Ground Walk Gastropod Ground Walk (?) Mammal SaltWater Surface, Dive, Underwater Mammal SaltWater Surface, Dive, Underwater BonyFish SaltWater Underwater, Glide BonyFish FreshWater Underwater Bird Air, Ground Fly, Walk Bird Air, Ground Fly
  • 58. Animal Classification Environment Abilities Mammal Ground Walk, Run Mammal Ground Walk, Run Bird Ground Walk, Run Bird Ground Walk, Run Reptile Ground Walk Gastropod Ground Walk (?) Mammal SaltWater Surface, Dive, Underwater Mammal SaltWater Surface, Dive, Underwater BonyFish SaltWater Underwater, Glide BonyFish FreshWater Underwater Bird Air, Ground Fly, Walk Bird Air, Ground Fly Mammal Ground Walk, Run, Glide
  • 59. Animal Classification Environment Abilities Mammal Ground Walk, Run Mammal Ground Walk, Run Bird Ground Walk, Run Bird Ground Walk, Run Reptile Ground Walk Gastropod Ground Walk (?) Mammal SaltWater Surface, Dive, Underwater Mammal SaltWater Surface, Dive, Underwater BonyFish SaltWater Underwater, Glide BonyFish FreshWater Underwater Bird Air, Ground Fly, Walk Bird Air, Ground Fly Mammal Ground Walk, Run, Glide Mammal Air, Ground Fly
  • 69. Watch the webinar recording here: https://www.postsharp.net/blog/we binar-recording-object-composition
  • 70. Questions? Zoran Horvat CEO & Principal Consultant, Coding Helmet Consultancy zh@sysexpand.com http://codinghelmet.com zoranh75