Domainlang keynote-eric-qcon
Transcript of Domainlang keynote-eric-qcon
![Page 1: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/1.jpg)
Domain-Driven Design
Useful Models for Complex Problems
Eric Evans
domainlanguage.com
![Page 2: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/2.jpg)
Why bother with models?
![Page 3: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/3.jpg)
„We should do a nice design, but we just don‟t have time.‟
![Page 4: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/4.jpg)
„Modeling and design take extra time, but they pay off in the long
run.‟
![Page 5: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/5.jpg)
Modeling and design are often the quickest path to the actual goal.
![Page 6: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/6.jpg)
What is your goal?
• Implement this feature?
• Complete a releasable set of stories with an acceptable level of bugs?
• Deliver a release that the team can continue to extend in the next release?
• Deliver a clear and cohesive user experience?
![Page 7: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/7.jpg)
The critical complexity of most software
projects is in understanding the domain
itself.
Critical Complexity Is
![Page 8: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/8.jpg)
Shipping Domain
![Page 9: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/9.jpg)
![Page 10: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/10.jpg)
![Page 11: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/11.jpg)
Long Beach, CA to Dallas, TX
Via rail voyage XYZ
Hong Kong to Long Beach, CA
Via vessel voyage ABC
![Page 12: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/12.jpg)
Cargo_ID Voyage_ID Load_Loc Unload_Loc
Database table: cargo_bookings
cargoId
origin
destination
weight
Cargo
Routing Service
origin
destination
cargoId
...
populate
cargo_bookings table
![Page 13: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/13.jpg)
Cargo_ID Voyage_ID Load_Loc Unload_Loc
Database table: cargo_bookings
cargoId
origin
destination
weight
Cargo
Routing Service
origin
destination
cargoId
...
populate
cargo_bookings table
side effect
![Page 14: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/14.jpg)
Cargo_ID Voyage_ID Load_Loc Unload_Loc
Database table: cargo_bookings
cargoId
origin
destination
weight
Cargo
Routing Service
origin
destination
cargoId
...
populate
cargo_bookings table
“Give the routing service the
required origin, destination,
and arrival time, and so on,
and it will look up the stops the
cargo will have to make and
put them in the database.”
![Page 15: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/15.jpg)
Cargo_ID Voyage_ID Load_Loc Unload_Loc
Database table: cargo_bookings
cargoId
origin
destination
weight
Cargo
Routing Service
origin
destination
cargoId
...
populate
cargo_bookings table
“Give the routing service the
required origin, destination,
and arrival time, and so on,
and it will look up the stops the
cargo will have to make and
put them in the database.”
“Each table row
shows load and
unload.”
![Page 16: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/16.jpg)
Cargo_ID Voyage_ID Load_Loc Unload_Loc
Database table: cargo_bookings
cargoId
origin
destination
weight
Cargo
Routing Service
origin
destination
cargoId
...
populate
cargo_bookings table
“What concepts are we
missing?”
![Page 17: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/17.jpg)
Cargo_ID Voyage_ID Load_Loc Unload_Loc
Database table: cargo_bookings
cargoId
origin
destination
weight
Cargo
Routing Service
origin
destination
cargoId
...
populate
cargo_bookings table
“Give the routing service the
required origin, destination,
and arrival time, and so on,
and it will look up the stops the
cargo will have to make and
put them in the database.”
![Page 18: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/18.jpg)
“A cargo makes a series of stops. At each stop it
is unloaded from a transport and loaded onto
another.”
![Page 19: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/19.jpg)
“The cargo is loaded
onto a transport at the
beginning of a leg and
unloaded at the end.”
“A cargo’s
itinerary is a series
of legs.”
![Page 20: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/20.jpg)
“A cargo’s
itinerary gives
instructions for
each stop, to
unload and load
onto a different
transport.”
![Page 21: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/21.jpg)
Stops or Legs?
Which is better?
![Page 22: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/22.jpg)
What is a model?
![Page 23: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/23.jpg)
Chinese Map
![Page 24: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/24.jpg)
Mercator Map
![Page 25: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/25.jpg)
![Page 26: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/26.jpg)
Mercator Map
![Page 27: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/27.jpg)
Some statements about this model
• The Earth is approximated as a sphere, with points of interest located on the surface.
• There are functions that map points on the surface of a sphere onto a cylinder (projections).
• Mercator‟s Projection preserves angles / direction of points relative to each other.
![Page 28: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/28.jpg)
![Page 29: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/29.jpg)
Defining Our Terms
domain A sphere of knowledge or activity.
model A system of abstractions representing selected aspects of the domain.
A model is a distilled form of domain knowledge, assumptions, rules and choices.
![Page 30: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/30.jpg)
It‟s not about “realism”
A model serves some use.
Usefulness is specific to particular scenarios.
There are always multiple models of the domain.
![Page 31: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/31.jpg)
Stops or Legs?
Which is more useful?
Useful for what?
![Page 32: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/32.jpg)
Shipping Reference Scenarios
• Route and book a new shipment
![Page 33: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/33.jpg)
Shipping Reference Scenarios
• Route and book a new shipment
• Reroute mid-transit at customer order
![Page 34: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/34.jpg)
Long Beach, CA to Dallas, TX
Via rail voyage XYZ
Hong Kong to Long Beach, CA
Via vessel voyage ABC
![Page 35: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/35.jpg)
Hong Kong to Seattle, WA
Via vessel voyage DEF
![Page 36: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/36.jpg)
X
Long Beach, CA to Seattle, WA
Via rail voyage UVW
Hong Kong to Long Beach, CA
Via vessel voyage ABC
![Page 37: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/37.jpg)
vesselVoyageId
loadLocationCode
/loadTime
unloadLocationCode
/unloadTime
Leg
/originLocationCode
/destinationLocationCode
/arrivalTime
Itinerary
*
0..1
{Itinerary must have origin, destination of Cargo}
Routing Service
an Itinerary with
appropriate origin/
destination
cargoId
origin
destination
weight
Cargo
origin
destination
...
![Page 38: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/38.jpg)
vesselVoyageId
loadLocationCode
/loadTime
unloadLocationCode
/unloadTime
Leg
/originLocationCode
/destinationLocationCode
/arrivalTime
Itinerary
*
0..1
{Itinerary must have origin, destination of Cargo}
Routing Service
an Itinerary with
appropriate origin/
destination
cargoId
origin
destination
weight
Cargo
origin
destination
...
“Feed the specified
origin, destination, and
so on into the routing
service, and we get
back an itinerary that
meets the customer‟s
request.”
![Page 39: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/39.jpg)
vesselVoyageId
loadLocationCode
/loadTime
unloadLocationCode
/unloadTime
Leg
/originLocationCode
/destinationLocationCode
/arrivalTime
Itinerary
*
0..1
{Itinerary must have origin, destination of Cargo}
Routing Service
an Itinerary with
appropriate origin/
destination
cargoId
origin
destination
weight
Cargo
origin
destination
...
“Each leg must load in
the same location as
the previous legs
unload.”
![Page 40: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/40.jpg)
Yes, But What If…?
• Route and book a new shipment.
• Before each voyage arrival, issue purchase orders to vendors in the port for unloading, loading, storage and routing within the terminal.
![Page 41: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/41.jpg)
„We have to get the model right first, before we write the code.‟
![Page 42: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/42.jpg)
Up Front Analysis Locks in Ignorance
• Models are distilled knowledge.
• At the beginning of a project, the team is as ignorant as it will ever be.
![Page 43: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/43.jpg)
![Page 44: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/44.jpg)
There are always multiple models.
![Page 45: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/45.jpg)
Blind Men and Elephant
![Page 46: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/46.jpg)
![Page 47: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/47.jpg)
Two Modelling Mistakes
• They keep trying to figure out the “true”
nature of an elephant.
• They insist on just one model, in spite
of incomplete information and possibly
different goals.
![Page 48: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/48.jpg)
Bounded Context An operational
definition of where a particular model is
well-defined and applicable. (Typically a
subsystem, or the work owned by a
particular team).
Define Bounded Context
![Page 49: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/49.jpg)
![Page 50: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/50.jpg)
![Page 51: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/51.jpg)
![Page 52: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/52.jpg)
![Page 53: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/53.jpg)
Precision designs are fragile. They require a bounded context containing a unified model.
![Page 54: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/54.jpg)
Not all of a large system will be well designed.
![Page 55: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/55.jpg)
Where to look for more
• Model Exploration – domainlanguage.com/ddd/whirlpool
– Section 3 in DDD book
• Context Boundaries – Chapter 14 in DDD book
• DDD Community (dddcommunity.org) – Experience reports
– Discussion groups
![Page 56: Domainlang keynote-eric-qcon](https://reader033.fdocuments.us/reader033/viewer/2022052822/554f3593b4c905cd048b4cf3/html5/thumbnails/56.jpg)
杭州站 · 2011年10月20日~22日 www.qconhangzhou.com(6月启动)
QCon北京站官方网站和资料下载 www.qconbeijing.com