SlideShare a Scribd company logo
1 of 70
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
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
}
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
}
.
Watch the webinar recording here:
https://www.postsharp.net/blog/we
binar-recording-object-composition
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
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

Viewers also liked

ZendCon 2011 UnCon Domain-Driven Design
ZendCon 2011 UnCon Domain-Driven DesignZendCon 2011 UnCon Domain-Driven Design
ZendCon 2011 UnCon Domain-Driven DesignBradley Holt
 
Domain driven design in a nutshell
Domain driven design in a nutshellDomain driven design in a nutshell
Domain driven design in a nutshellToni Esteves
 
Success by Challenging Assumptions (Part I)
Success by Challenging Assumptions (Part I)Success by Challenging Assumptions (Part I)
Success by Challenging Assumptions (Part I)LaDonna Coy
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design QuicklyMariam Hakobyan
 
Introduction to Domain Driven Design
Introduction to Domain Driven DesignIntroduction to Domain Driven Design
Introduction to Domain Driven DesignChristos Tsakostas
 
Domain State model OOAD
Domain State model  OOADDomain State model  OOAD
Domain State model OOADRaghu Kumar
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignRyan Riley
 
Domain Driven Design and Hexagonal Architecture with Rails
Domain Driven Design and Hexagonal Architecture with RailsDomain Driven Design and Hexagonal Architecture with Rails
Domain Driven Design and Hexagonal Architecture with RailsDeclan Whelan
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven DesignDavid Berliner
 
Why Domain-Driven Design Matters
Why Domain-Driven Design MattersWhy Domain-Driven Design Matters
Why Domain-Driven Design MattersMathias Verraes
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design IntroductionTung Nguyen Thanh
 
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 MVCSteven Smith
 
Domain Driven Design (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)Tom Kocjan
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#Pascal Laurin
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slidesthinkddd
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modelingMario Fusco
 
Implementing DDD Concepts in PHP
Implementing DDD Concepts in PHPImplementing DDD Concepts in PHP
Implementing DDD Concepts in PHPSteve Rhoades
 

Viewers also liked (20)

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 in a nutshell
Domain driven design in a nutshellDomain driven design in a nutshell
Domain driven design in a nutshell
 
Success by Challenging Assumptions (Part I)
Success by Challenging Assumptions (Part I)Success by Challenging Assumptions (Part I)
Success by Challenging Assumptions (Part I)
 
Domain Driven Design Quickly
Domain Driven Design QuicklyDomain Driven Design Quickly
Domain Driven Design Quickly
 
Introduction to Domain Driven Design
Introduction to Domain Driven DesignIntroduction to Domain Driven Design
Introduction to Domain Driven Design
 
Introduction to-ddd
Introduction to-dddIntroduction to-ddd
Introduction to-ddd
 
Domain State model OOAD
Domain State model  OOADDomain State model  OOAD
Domain State model OOAD
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Domain Driven Design and Hexagonal Architecture with Rails
Domain Driven Design and Hexagonal Architecture with RailsDomain Driven Design and Hexagonal Architecture with Rails
Domain Driven Design and Hexagonal Architecture with Rails
 
Refactoring for Domain Driven Design
Refactoring for Domain Driven DesignRefactoring for Domain Driven Design
Refactoring for Domain Driven Design
 
Domain object model
Domain object modelDomain object model
Domain object model
 
Why Domain-Driven Design Matters
Why Domain-Driven Design MattersWhy Domain-Driven Design Matters
Why Domain-Driven Design Matters
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
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 (DDD)
Domain Driven Design (DDD)Domain Driven Design (DDD)
Domain Driven Design (DDD)
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slides
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modeling
 
Implementing DDD Concepts in PHP
Implementing DDD Concepts in PHPImplementing DDD Concepts in PHP
Implementing DDD Concepts in PHP
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 

Recently uploaded

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 

Recently uploaded (20)

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 

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
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 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 }
  • 20.
  • 21.
  • 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 } .
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38. Watch the webinar recording here: https://www.postsharp.net/blog/we binar-recording-object-composition
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 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
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 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