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
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
assetexplorer- product-overview - presentation
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
medical staffing services at VALiNTRY
PPTX
history of c programming in notes for students .pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PPTX
Transform Your Business with a Software ERP System
PDF
Complete Guide to Website Development in Malaysia for SMEs
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Odoo Companies in India – Driving Business Transformation.pdf
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Operating system designcfffgfgggggggvggggggggg
Design an Analysis of Algorithms II-SECS-1021-03
assetexplorer- product-overview - presentation
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
medical staffing services at VALiNTRY
history of c programming in notes for students .pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Why Generative AI is the Future of Content, Code & Creativity?
Digital Systems & Binary Numbers (comprehensive )
17 Powerful Integrations Your Next-Gen MLM Software Needs
Design an Analysis of Algorithms I-SECS-1021-03
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Transform Your Business with a Software ERP System
Complete Guide to Website Development in Malaysia for SMEs
Computer Software and OS of computer science of grade 11.pptx
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf

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 [email protected] 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 [email protected] http://codinghelmet.com zoranh75