Designing a system is hard, it’s even harder to build a distributed (microservices) style architecture…
Let's try and walk through a simplified example of carving out our bounded contexts and the processes, finding our service boundaries, on the way to building better applications.
We will focus on moving from "monolith" to "distributed" thinking, moving from one single entity driven data model to multiple vertical bounded contexts.
3. #DotNextConf @farmar
Monolith Design
Something like this:
3
Account
Id
IsClosed
OpenDate
Customer
Id
CustomerId
Phone
Address
LineItem
Id
Quantity
Price
Order
Id
OrderNumber
OrderDate
ShippingDate
OrderStatus
Id
OrderStatusName
Payment
Id
PaymentDate
Total
Product
Id
Name
Suplier
User
Id
UserName
UserStatus
Id
UserStatusName
New
Active
Blocked
Band
New
Hold
Shipped
Delivered
Closed
13. #DotNextConf @farmar
Domain Driven Design
13
“Every software program relates to some activity or interest of its user.”
Eric Evans, Domain-Driven Design: Tackling Complexity in the Heart of Software
14. #DotNextConf @farmar
Domain Driven Design
14
“DDD deals with large models by dividing
them into different Bounded Contexts
and being explicit about their interrelationships.”
Martin Fowler
22. #DotNextConf @farmar
Find Units Of Work
As a user I can authenticate [UserAuthentication?]:
[UserName] (Could be email?)
[Password]
Does Authorization (access control) belong here as
well?
22
23. #DotNextConf @farmar
Find Units Of Work
CustomerContactDetails:
[CustomerId]
[ContactEmail] (is that the logging email?)
[CustomerPhoneNumberId] (optional?)
[CustomerAddressId] (optional?)
Email and Mobile Validation Process
23
24. #DotNextConf @farmar
Find Units Of Work
CustomerAccount:
[UserAuthenticationId]
[AccountName]
[AccountType]
[First Name]?
[Last Name]?
[AccountActive]
24
25. #DotNextConf @farmar
Find Units Of Work
PaymentDetails:
Add one or more payment methods
Add Billing Address
Add payment methods process(is it a
thing?)
25
34. #DotNextConf @farmar
Work Your Way Up
Start in the edge of the system
Use APIs where possible
Include the data in every iteration
34
35. #DotNextConf @farmar
Work Your Way Up
Find the bounded Context
Reduce it to the smallest model you can
Find the “Service” Boundaries and it’s
processes
35
40. #DotNextConf @farmar
Summary
Keep your boundaries
Reduce coupling between bounded
contexts
Use asynchronous communication (for
state changes)
Publish Subscribe between bounded
contexts
40
43. #DotNextConf @farmar
One more thing
Get free access to Advanced Distributed
Systems Design course recording with Udi
Dahan
http://go.particular.net/dotnextru19
43
Book written by Eric Evens in 2003
Bounded Context is a central pattern in Domain-Driven Design (DDD).
It is the focus of DDD's Strategic Design Section which is all about dealing with large models and teams.
Business/product/user driven development
Eric Evens – book written in 2003
Bounded Context is a central pattern in Domain-Driven Design (DDD).
It is the focus of DDD's Strategic Design Section which is all about dealing with large models and teams.
Martin Fowler – International Speaker and Author (Patterns of Enterprise Application Architecture, Refactoring)
* Information *surrounding* idea which *clarifies meaning*
If you can imagine a point or limit that indicates where two things become different
A boundary is basically what limits us.
**Autonomy**
** Coupling **
Example…An Ecommerce
An Account could mean:
* User credentials to log into the program – “User Credentials”
* A container of money – “Current Business Account”
When we try and implement this in software design we should explicitly separate the 2 concepts
Another example can be user:
One meaning the actual user interacting with the system “Logged In User”
And an Account may be a bank account or a user account,
To have a Bounded Context you need a model, and an explicit boundary around it.
Many data-driven application with shared database lack a boundary