DDD practitioners acknowledge the importance of Ubiquitous Language (UL), only to ... treat it as a dry dictionary (a vocabulary for entities and value objects). Instead of analyzing the *deep* semantics of UL, we prefer to shape models from scratch using tactical framing (aggregates, repositories, etc.). That increases a margin of potential misunderstanding and error, especially for such topics as setting the boundaries (between modules of our solutions) or identifying the most crucial dependencies ("is it intra- or inter-modular?").
Try to bridge the gap between living UL and a living domain model by building Semantic Spatial Maps (SSMs) of Ubiquitous Language.
What do I mean by a semantic map (of the problem domain)?
A graphical visualization (in 2D space, a "spatial" map) of the problem domain (based on UL) that is substantial in properly structuring the future solution (esp. identifying the boundaries and contracts, telling which dependencies represent coupling and which cohesion).
What would such a map contain?
- concepts (nouns) - that have a (hopefully unambiguous) meaning in UL; they are represented by nodes in the map
- relationships (between concepts) - named, they correspond to dependencies; they aren't necessarily bi-directional, use the direction that is "natural" (more frequent?) from UL's perspective
- mesh - a 2D space that contains interconnected concepts and relationships
- the key characteristics of a relationship are: its presence, the name, potentially the direction, but also the distance (length)
- distance represents the proximity of (connected) concepts - how closely they belong together conceptually (based on our domain knowledge - understanding of those concepts' meaning)
- situations - interactions that involve a part of the mesh (a subset of concepts) - each situation is named, and it represents some activity/behavior; spatially (visually) situation is a layer that covers involved concepts and the space between them
- individual layer's intensity is a measure of the situation's complexity (more on the complexity later, in one of the subsequent posts)
- density of mesh is a sum of situations' intensity in a given point of the mesh; in other words: how many situations (and how complex) are located within a subsection of the mesh (and overlap on the top of another)
Such a semantic spatial map has some interesting properties:
- proximity (based primarily on judgment) can be easily validated with the density (based on interactions and complexity) - e.g., if close concepts have a high density, then they are highly cohesive and form a proper shoal ("module")
- it'd be visually apparent whether a shoal (which looks like a "clump" of closely associated concepts) has a well-defined contract and its internal details (concepts that represent the internal logic) are well bound inside and do not "leak out"
- overcomplicated situations (that spans across many concepts from different shoals) would be too obvious to miss
How to build such an SSM?
- In fact: how about building it in an automated way, based upon a textual description (structured UL); I haven't tried that in practice, and I can't prove it would work, but ... it sounds like something feasible (& ... tempting).
- I can also imagine a graphical editor, where one builds a mesh by manually adding all the concepts, defining relationships, layering situations, etc. TBH, generating a textual description (human-readable UL dump) based on such a mesh should also be possible.
I realize the description above may sound very dry (without any actual map to illustrate the theory!) but bear with me — first things first. The building blocks described above are a product of practical experimentation - I've started with something completely different and evolved it continuously (visually, of course - by applying the method on actual real-life domains and scenarios).
In the next blog post in the series, I plan to show you real SSMs, so you can see some meshes in action. Needless to say - all the constructive feedback is more than appreciated.