I’m having lots of conversations with @rebeccawb about Bounded Contexts in Domain-Driven Design. This is a small snapshot of some of the tensions involved in picking good boundaries.
🧵⬇️ (1/15)
Some context:

A Bounded Context is an “understandability boundary”, a boundary around a model and its language. You can understand the model and the language in isolation, without having to understand other Bounded Contexts. (2/15)
An Interface is the set of contracts or message types or APIs between Bounded Contexts. They translate from one model and language to another. (3/15)
A Bounded Context or Interface is evolvable if we are able to make frequent, safe, and cheap changes to it.

When designing evolvable Bounded Contexts (BCs), there are fundamental tensions that affect our design. (4/15)
[1] A BC is evolvable on the inside if it is small and understandable and has a small stable Interface.

[2] A system of BCs is evolvable (adding, removing, reconfiguring BCs) if the Interfaces are small and understandable. (5/15)
[3] The tension between [1] and [2] is that choosing many small BCs implies having larger Interfaces, but choosing many small Interfaces implies having larger BCs. (6/15)
[4] The Interfaces themselves are more evolvable if they integrate fewer BCs, and less evolvable if they integrate more BCs.

[5] The consequence of [2] and [4] is that a small evolvable Interface makes adding BCs easier, but becomes less evolvable in the process. (7/15)
[6] It’s easier for a BC to offer a single generic shared Interface, than many specialised Interfaces for each consumer. Having many specialised Interfaces is harder to maintain when the BC changes. (8/15)
[7] It’s easier for a BC to consume a specialised Interface, adapted to that BC. Generic interfaces are bloated because they support other consumers, and therefore require more integration work. (9/15)
[8] Trading off [6] and [7] involves finding a small set of semi-specialised Interfaces, that are shared between some consumers with similar needs. (10/15)
[9] Coordination between teams (which is in fact coordination of understanding, aka sharing models and language) is expensive, which is one of the reasons we have BCs to begin with. (11/15)
[10] Achieving [8] requires more coordination between more teams than either a single generic Interface or individual specialised Interface. (12/15)
There are no solutions or hard rules to make these trade-offs. Instead, you need to use heuristics for making the trade-offs, and heuristics for knowing when to choose different trade-offs than the ones you originally made. (13/15)
Also available as a blog post over at my site verraes.net/2021/04/tensio… (14/15)
(Domain modelling, strategic design, and just generally figuring out problems like these is what my company does. DMs are open if you want us to work with you. )(15/15)

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Mathias Verraes

Mathias Verraes Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @mathiasverraes

12 Feb
The most important thing you can do when trying to learn Domain-Driven Design is still very much Eric's book amzn.to/3b1Uqrx People are not recommending this book enough because few have actually finished it.
It has a reputation of being hard to read, which is deserved. Read a little bit every day. Or read the bold parts first, then start over to read it thoroughly.
It also has a reputation of being too academic or too theoretical. This is undeserved: it is highly pragmatic, but it approaches software design from an angle that didn't exist anywhere else before, so it introduces many concepts that seem foreign at first.
Read 8 tweets
11 Feb
The larger the client, the more likely they hire me because they want to "get it right the first time and avoid rework", and the more likely they end up not hiring me because before they do, they want to agree on the scope of what I will do for them.
Repeat after me: All good design is redesign. Rework is a feature, not a bug.
Seriously, the best results happen when people hire without knowing what exactly they want to achieve.
Read 8 tweets
29 Dec 19
"As small as possible" (DB partitions, message size, μsvcs, Bounded Contexts, class names, method arity, ...) is almost universally bad advice in software design. Some critical logic is going to cross those boundaries and result in poorly implemented, preventable workarounds.
But, "Whenever something is wrong, something is too big" (Kohr 1957) is also true for software. Big things are more obviously bad. Small things look simple, because the wrongness hides not inside the things, but in their connections.
Things usually tend to get bigger, rarely smaller or stable. @CarloPescio calls this gravity (things with mass acquire more mass) in the Physics of Software. Our usual reaction is to advocate smallness.
Read 7 tweets
14 Dec 19
The problem is not that you shipped on Friday. The problem is that you have no way of knowing if shipping will break it. Most software is massively undermodeled and undertested.
Models (1) and tests (2) are two sides of software success: 1) do I understand this software so well that I can accurately predict the impact of a change in the system's behaviour 2) can I delonstrate confidence in its behaviour by repeatedly testing lots of scenarios
The irony is that both automated testing and modelling are crazy cheap compared to the perpetual burden and risk of undertested and undermodeled business-critical systems.
Read 10 tweets
23 Jul 19
I wish we'd stop debating OOP vs FP, and started debating individual paradigms. Immutability, encapsulation, global state, single assignment, actor model, pure functions, IO in the type system, inheritance, composition... all of these are perfectly possible in either OOP or FP.
Some are better, some are worse, some are highly dependent on context, let's figure that out instead of religuously bashing umbrella terms like OOP and FP. And there may be many more paradigms to discover.
Take encapsulation: in #Haskell, you can choose for a module not to export your type constructors, and only export smart constructors and functions operating on your data structures. Sounds close enough to encapsulation to me.
Read 8 tweets
5 Jun 19
1/9 Software design is invisible design. Its primary audience is the other designers.
2/9 Decision makers are used to design being something that produces visible outcomes: things, UIs, features, experiences. It's very hard for them to understand why they should care about software design.
3/9 But make no mistake: software design does impact users. If the software's model is congruent to the domain, it will help solve the users' problems, as oppose to generate more problems. It will lower communication cost about the system, and therefore enable speed.
Read 9 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!