Focus of developer:
- Not to code
- But to solve problems
Good thing to share a mental model with the:
- Domain Experts
- Development Team
- Other stakeholders
- And... CODE! (still)
Why?
- Faster TTM
- More business value
- Less waster (clearer requirements)
- Easier maintenance
- Increased "connection" among teams
How? General guidelines:
- Focus on business events and workflows rahter than DS
- Partition problem domain to subdomains
- Ubiquitous Language
Example used through this book:
We're a tiny company that manufactures parts for other companies: widgets, gizmos and the like. We've been growing quite fast, and our current processes are not able to keep up.
Right now, everything we do is pape-based, we'd like to computerize all that so our staff can handle larger volumes of orders.
In particular, we'd like to have a self-service website so that customers can do some tasks themselves. Things like placing an order, checking order status, and so on.
Whenever some new elements come into play, you can consider that they either come from:
- information from domain experts
- arbitrary decisions for implementation purposes
How to discover those events? => Event storming!
Event storming can only be achieved with everybody (business, devs, etc.), majors steps include:
- question others' answers (ie. find gaps in requirements)
- extend the chains of events as far as you can (ie. edges)
- be explicit about the different ownerships (ie. x y team, customer, etc.)
- aggregate everything in a consistent way (ie. big picture)
Example with an Order-Taking System:
- Order-taking Team
- Order Form Received
- Order Placed
- Order Shipped
- Order Change Requested
- Order Cancellation Requested
- Acknowledgment Sent To Customer
- Shipping Team
- Return Requested
- Quote Form Received
- Quote Provided
- New Customer Request Received
- New Customer Registred
- Dispatch Message Sent To Customer
- Customer
- Signed for delivery
Once we have events, we look at what are the events that trigger them.
If the command was "Make X happen" then if the workflow made X happen, the corresponding domain event should be "X happened".
Long story short:
- Event (triggers) =>
- Command (input data needed for workflow) =>
- (Business) Workflow (output list of events) => Non-Terminal Full Cycle JCVD!
- GOTO 1. ^^"""" ;-)
Translated to our example:
- Event: Order Form Received
- Command: Place Order
- Workflow: Place Order Workflow outputs: "Order Placed (for shipping)" + "Order Placed (for billing)"
Notes:
- it goes without saying that not every single event needs to be associated with a command!
- not every command suceeds, we'll discuss about that later (see chapter 10)
Example - Subdomains:
- Problem Space (real world):
- Order-taking Domain
- Shipping Domain
- Billing Domain
Note: the domains can overlap a bit with each other.
Problem Space != Solution Space (implementation): Only capture the information that is relevant to solving a particular problem.
- Solution Space (domain world):
- Order-taking Context
- Shipping Context
- Billing Context
- Customer
- => [Order/Quote Received]
- => Order-taking Context
- => [Order/Quote Received]
- Order-taking Context
- => [Quote Returned]
- => Customer
- => [Order Placed]:
- => Shipping Context
- => Billing Context
- => [Quote Returned]
Notes: relationship between domains and bounded contexts is not always 1:1
-
Domain: area of knowledge associated with the problem, that which a domain expert is expert in.
-
Domain Model: set of simplifications representing the relevant aspects of a domain regarding a particular problem.
-
Scenario: a User(pov)-Centric Goal Description (e.g placing an order), similar to a user story in agile. A use case is a more detailed version of a scenario.
-
Business Process: Business-Centric Goal Description.
-
Workflow: exact steps of a Business Process. We'll limit ourselves to a single person / team scope, so that it can be divided in smaller workflows when combined togetther.
-
Ubiquitous Language: sets of concepts and vocabulary that is associated with the domain and is shared by both the team members and the source code.
-
Bounded contexts (ie. think of boundaries) kinda subsystem in the implementation.
-
Context Map: high level diagram showing a the relationhsips between bounded contexts.
-
Domain Event: record of something that happened in the system, always described in the past tense.
-
Command: request for some process to happen and is triggered by a person or another event. If the process suceeds, the state of the system changes and one or more Domain Events are recorded.