Alberto Brandolini (@ziobrando) gave a great talk at the last Domain-Driven Design eXchange in London. In this talk, among many other insights, he described a recurring pattern he had seen many times in several very different projects: « Collaborative Construction, Execution & Tracking. Sounds familiar? Maybe we didn’t notice something cool »
Analysis conflicts are hints
In various unrelated projects we see similar problems. Consider a project that deals with building a complex artifact like an advertising campaigns. Creating a campaign involves a lot of different communication channels between many people.
On this project, the boss said:
We should prevent the user from entering incorrect data.
Sure you don’t want to have corrupt data, which is reasonable: you don’t want to launch a campaign with wrong or corrupt data! However the users were telling a completely different story:
[the process with all the strict validations] cannot be applied in practice, there’s no way it can work!
Why this conflict? In fact they are talking about two different processes, and they could not notice that. Sure, it takes the acute eyes of a Domain-Driven Design practitioner to recognize that subtlety!
Alberto mentions what he calls the « Notorious Pub Hypothesis« : think about the pub where all the bad people gather at night, where you don’t go if you’re an honest citizen. The hypothesis comes from his mother asking:
Why doesn’t the police shut down this place? Actually there is some value in having this kind of place, since the police knows where all the bad guys are, it makes it easier to find them when you have to.
In a similar fashion, maybe there’s also a need somewhere for invalid data. What happens before we have strictly validated data? Just like the bad guys who exist even if we don’t like it, there is a whole universe outside of the application, in which the users are preparing the advertising campaign with more than one month of preparation of data, lots of emails and many other communication types, and all that is untraceable so far.Why not acknowledge that and include this process, a collaborative process, directly into the application?
Similar data, totally different semantics
Coming from a data-driven mindset, it is not easy to realize that it’s not because the data structures are pretty much the same that you have to live with only one type of representation in your application. Same data, completely different behavior: this suggests different Bounded Contexts!
The interesting pattern recurring in many applications is a split between two phases: one phase where multiple stakeholders collaborate on the construction of a deliverable, and a second phase where the built deliverable is stored, can be reviewed, versioned, searched etc.
The natural focus of most projects seems to be on the second phase; Alberto introduced the name Collaborative Construction to refer to the first phase, often missed in the analysis. Now we have a name for this pattern!
The insight in this story is to acknowledge the two contexts, one of collaborative construction, the other on managing the outcome of the construction.
Looks like « source Vs. executable »
During collaborative construction, it’s important to accept inconsistencies, warnings or even errors, incomplete data, missing details, because the work is in progress, it’s a draft. Also this work in progress is by definition changing quickly thanks to the contributions of every participant.
Once the draft is ready, it is then validated and becomes the final deliverable. This deliverable must be complete, valid and consistent, and cannot be changed any more. It is there forever. Every change becomes a new revision from now on.
We therefore evolve from a draft semantics to a « printed » or « signed » semantics. The draft requires comments, conversations, proposals, decisions. On the other hand the resulting deliverable may require a version history and release notes.
The insight that we have these two different bounded contexts now in turn helps dig deeper the analysis, to discover that we probably need different data and different behaviors for each context.
Some examples of this split in two contexts:
- The shopping cart is a work in progress, that once finalized becomes an order
- A request for quote or an auction process is a collaborative construction in search of the best trade condition, and it finally concludes (or not) into a trade
- A legal document draft is being worked on by many lawers, before it is signed off to become the legally binding contract, after the negotiations have happened.
- An example we all know very well, our source code in source control is a work in progress between several developers, and then the continuous integration compiles it into an executable and a set of reports, all immutable. It’s ok to have compilation errors and warnings while we’re typing code. It’s ok to have checkstyle violations until we commit. Once we release we want no warning and every test to pass. If we need to change something, we simply build another revision, each release cannot change (unless we patch but that’s another gory story)
Building software to deal with collaborative construction is quite demanding with respect to the User Experience (UX).
Can we find examples of Collaborative Construction in software? Sure, think about Google Wave (though it did not end well), Github (successful but not ready for normal users that are not developers), Facebook (though we’re not building anything useful with it).
Watch the video of the talk
Another note, among many other I took away from the talk, is that from time to time we developers should ask the question:
what if the domain expert is wrong?
It does happen that the domain expert is going to mislead the team and the project, because he’s giving a different answer every day, or because she’s focusing on only one half of the full domain problem. Or because he’s evil…
And don’t hesitate to watch the 50mn video of the talk, to hear many other lessons learnt, and also because it’s fun to listen to Alberto talking about zombies while talking about Domain-Driven Design!Follow me (@cyriux) on Twitter!