Modern business applications rely heavily on rich domain classes, which in turn rely heavily on polymorphic execution, code reuse and similar concepts.
How can we extend rich domain classes to support complex requirements?
In this presentation, Zoran Horvat will show why an object composition approach is favored over class inheritance when it comes to code reuse and polymorphism.
The presentation covers:
How class inheritance can lead to combinatorial explosion of classes
What the limitations of object composition are
What design patterns help consume composed objects
Techniques for creating rich features on composed objects
Watch the webinar recording here: http://www.postsharp.net/blog/post/webinar-recording-object-composition
1 of 70
Downloaded 37 times
More Related Content
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
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 mammals tail using all your strength
}
18. Animal obj = ...
if (obj is Mammal)
{
Mammal mammal = (Mammal)obj; // e.g. a tiger
// Pull mammals 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 mammals 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 mammals 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 mammals 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 mammals 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 mammals 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 mammals 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 mammals 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 mammals 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 mammals 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 mammals 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
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