19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Distributed Domain Driven
Design
jeremie chassaing
thinkbeforeco...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Domain Driven Design
• Domain Driven Design offers a lot of
inte...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Services
• “When a significant process or transformation in
the ...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Services
• Service can be implemented
– As in-process interface ...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Services
• Services should be Stateless
– Real statelessness
– P...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Services
• It enables
– Load balancing
– Failover
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Value Objects
• “When you care only about the attributes of an
e...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Value Objects
• Value Objects are immutable
• It enables easy us...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Entities
• “An object defined primarily by its identity is
calle...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Entities
• Here, we have problems for distribution:
– Life cycle...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Entities
• “It is difficult to guarantee the consistency of
chan...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Aggregates
• “Cluster the Entities and Value Objects into
Aggreg...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Aggregates
Car
vehicle id
rotate()
Wheel
local identity
Tire
loc...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Aggregates
• Aggregates define a boundary
• Inside, consistency ...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Aggregates
• Aggregates define a boundary
• Inside, consistency ...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Aggregates
• If you need a transaction that spans more
than one ...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Aggregates
• Once Boundaries are well defined, you
can distribut...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Aggregates
• Sharding
Aggegates with (Id % 3 == 0)
Aggegates wit...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Aggregates
• Sharding strategies depend on your
domain
• Some Ag...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Aggregates
• Aggregates should be a natural partition
point of y...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Bounded Contexts
• “A Bounded Context delimits the applicability...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Bounded Contexts
• Bounded Contexts also define a boundary
that ...
19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de
Conclusion
• Domain Driven Design inherently provide
patterns fo...
Upcoming SlideShare
Loading in …5
×

Distributed domaindrivedesign

1,225 views

Published on

Distributed Domain Driven Design
PrioConference 2010
Nuremberg, Germany

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,225
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Distributed domaindrivedesign

  1. 1. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Distributed Domain Driven Design jeremie chassaing thinkbeforecoding.com
  2. 2. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Domain Driven Design • Domain Driven Design offers a lot of interesting patterns for distribution • The partitions of your system will emerge from the Domain model and its Ubiquitous Language
  3. 3. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Services • “When a significant process or transformation in the domain is not a natural responsibility of an Entity or Value Object, add an operation to the model as a standalone interface declared as a Service. Define the interface in terms of the language of the model and make sure the operation name is part of the Ubiquitous Language. Make the Service stateless”
  4. 4. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Services • Service can be implemented – As in-process interface implementation – As an out of process service, the interface can just be a stub to access the service end point
  5. 5. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Services • Services should be Stateless – Real statelessness – Perceived statelessness (cache, etc) • Service can be instantiated many times without conflict • Clients can switch from one to another since Services don’t hold state
  6. 6. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Services • It enables – Load balancing – Failover
  7. 7. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Value Objects • “When you care only about the attributes of an element of the model, classify it as Value Object. Make it express the meaning of the attributes it conveys and give it related functionality. Treat the Value Object as immutable.”
  8. 8. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Value Objects • Value Objects are immutable • It enables easy use in concurrent code • They can be shared or duplicated as needed
  9. 9. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Entities • “An object defined primarily by its identity is called an Entity. Entities have special modeling and design considerations. They have life cycles that can radically change their form and content, but a thread of continuity must be maintained. Their identity must be defined so that they can be effectively tracked.”
  10. 10. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Entities • Here, we have problems for distribution: – Life cycle – Identity • Entities are inherently mutable. • We have to protect against concurrent changes to make Entities consistent
  11. 11. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Entities • “It is difficult to guarantee the consistency of changes to objects in a model with complex associations. Invariants need to be maintained that apply to closely related groups of objects, not just discrete objects. Yet cautious locking schemes cause multiple users to interfere pointlessly with each other and make a system unusable.”
  12. 12. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Aggregates • “Cluster the Entities and Value Objects into Aggregates and define boundaries around each. Choose one Entity to be the root of each Aggregate, and control all access to the objects inside the boundary through the root. Allow external objects to hold references to the root only. […] Because the root controls access, it cannot be blindsided by changes to the internals. This arrangement makes it practical to enforce all invariants for objects in the Aggregate and for the Aggregate as a whole in any state change.”
  13. 13. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Aggregates Car vehicle id rotate() Wheel local identity Tire local id mileage Position time period mileage 4 4 * {mileage = sum(Position.mileage)}{time period must not overlap on same wheel}
  14. 14. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Aggregates • Aggregates define a boundary • Inside, consistency is guaranteed • …
  15. 15. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Aggregates • Aggregates define a boundary • Inside, consistency is guaranteed • Outside, consistency can not be guaranteed
  16. 16. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Aggregates • If you need a transaction that spans more than one aggregate, something is wrong • Check that you need it to be consistent • …Or change your boundaries
  17. 17. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Aggregates • Once Boundaries are well defined, you can distribute Aggregates • The identity of an Aggregate is the identity of its root • Execute commands on one Aggregate synchronously • Execute commands on distinct aggregates asynchronously
  18. 18. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Aggregates • Sharding Aggegates with (Id % 3 == 0) Aggegates with (Id % 3 == 1) Aggegates with (Id % 3 == 2)
  19. 19. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Aggregates • Sharding strategies depend on your domain • Some Aggregates that need very high throughput can be isolated to dedicated servers
  20. 20. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Aggregates • Aggregates should be a natural partition point of your domain
  21. 21. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Bounded Contexts • “A Bounded Context delimits the applicability of a particular model so that team members have a clear and shared understanding of what has to be consistent and how it relates to other Contexts. Within that Context, work to keep the model logically unified, but do not worry about applicability outside those bounds.”
  22. 22. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Bounded Contexts • Bounded Contexts also define a boundary that can be used as a partition point • Bounded Context can be implemented as independent services using DDD patterns for internal distribution
  23. 23. 19. und 20. Oktober 2010 in Nürnbergwww.prioconference.de Conclusion • Domain Driven Design inherently provide patterns for distributed architectures • Partition points should not come from the implementation details • Partition points should be found in the Domain and the Ubiquitous Language

×