Domain-Driven Design (DDD) intersects with a broad range of the intellectual heritage in the software design discipline including object-orientation, design patterns and refactoring. And as such, it can be viewed as a synthesis of these knowledge assets tailored towards domain-oriented application software development.
Although this view is valid and productive, there could be another way of viewing accomplishment of DDD. It is the theme of this short discussion.
In this context, DDD could be thought as a quiet departure from “software design” to something we may call “information design” with a special emotional attachment.
What is a Domain Model?
But first thing first. We must have a rethink on one basic question. What is a domain model?
It sounds ridiculous. A domain model is a model of a domain. Isn’t it?
Let us discuss about this on a concrete example: version control systems (VCSs). We now have a bunch of VCSs, each of which offers a somewhat different model than another. For instance, with Subversion, “commit” means a registration of source code changes to the central (and solitary) repository, whereas, with Git, the same word means a registration of source code changes to a particular member of a set of distributed repositories. “Commit” is in the vocabulary of ubiquitous language
of each VCS. And if so, this difference in the meaning should be the reflection of a difference of the underlying domain models of the two VCSs.
From this example, we can see that the difference between these two models comes from the difference in approach to solve problems in the same domain. A domain model is not a model of a domain itself. Instead, it actually is a model of a solution for the domain. It was not before each VCS was given birth that each model was recognized.
This idea is quite simple and straightforward. Let us take spreadsheet software as another example. They share a unique domain model consisting of sheets, cells, formula and so on. This domain model did not exist before the birth of VisiCalc and evolved after that. Although we may use spreadsheets for our accounting calculation, it is not that accounting domain had the spreadsheet concept in its history, but the concept and model were engineered to solve problems in a broad domain, which incidentally includes a part of accounting.
Two Domain Models
Traditionally, domain models tend to be seen as “analysis models”, which are subjects of analysis, not design. However, our new vision that a domain model is a model of a solution challenges this view. A solution is something we design, even if we analyze designs of the existing solutions from time to time.
“Analysis” is rather a passive word in that it treats things which already exist, while a design creates something that did not exist before. In traditional OO approaches, an analysis model tend to be viewed as an abstraction of the real world, which already exists and naturally is not a subject of design, while a design governs the functionalities and the structures of software we (as engineers) build. From the engineering perspective, this separation looks very natural.
The point here is that from a domain-driven designer’s perspective, a “real world” would consist of two subcomponents - physical and informational.
In the physical world, people work, things move, and money is earned. They are what we imagine by the word “business”. To let businesses move on, we record and exchange information - orders, invoices, inventory records, financial statements, and so on. This is another component of the real world - information processing.
Accordingly, a domain model is divided into two distinct models: physical world models and informational models.
With such a world view, we would consider the physical world models as usually just given and uncontrollable for us, while we can design most parts of the informational models.
Two Domain Models and OOA
In his DDD book, Evans repeatedly speaks about initial superficial models and deep models. In his example from a container shipping application, the superficial model contains physical entities like Ships
and Containers
, while the deep model contains such abstract concepts as Vessel Voyages
and Bills of Lading
(e.g. p.189 “Deep Models”). The distinction between these models is at least partially not of the “depth” but of the “subject” of each model - physical and informational.
Evans tells a story which is suggestive on how traditional OOA ignores this distinction:
Whenever new object modelers showed up on the project, what was their first suggestion? The missing classes: ship and container. They were smart people. They just hadn’t gone through the processes of discovery.
(p.190)
With the idea of two domain models, we understand this would not have been only because “they just hadn’t gone through the processes of discovery”, but also because the body of knowledge of OOA (or at least its generally accepted understanding) has lacked the distinction of physical world models and informational models.
However, this ignorance is not surprising, because the distinction between the two models is not always apparent. It is because information has infiltrated into every corner of our world and passes as if they were physical. Are bank checks physical or informational? How do we distinguish them from truly physical objects? Or, do we have to do so at all? I have no definitive answer here. In many cases you can safely omit checks from your informational models (as if they were physical), while you might have to include “cash in hand” in your models (which refers to bank bills, coins, and checks, collectively) instead. But it is not a dogma. We have to use our judgment. Nevertheless, drawing a line between physical and informational models could still bring insights in modeling, because in the end what we have to represent with our software are informational models, not physical business models.
An Implication of DDD
Ubiquitous language
and model-driven design
are two practices at the heart of DDD. In the light of two domain models, ubiquitous language
could be understood as a device to separate an informational model from a physical world model and make it subject of design, not analysis. It extends the realm of us, developers. And model-driven design
urges us to keep software structure to be exact reflection of the informational model. It prevents our profession from dissolving into analysts and developers.
Thus, design of informational models is in our hands. Informational models had been designed even before our information technology age. Double-entry book-keeping system is a remarkable instance of those models. Train operation diagrams and music scores are other examples. These models had been designed by people on the “business-side” (because there was no IT-side). By contrast, the responsibility to design informational models seems to be floating in our IT age. Our IT has been too awkward for business people. Therefore they often have felt uncomfortable designing informational models which are to be implemented with IT. Analysts might be the people in charge. But they analyze, do not design. Furthermore, it is difficult to design if you are disconnected from feedbacks that implementation would provide (this is also what model-driven design
cares). We, developers are in the best position to accept this responsibility, off course with a tight cooperation with business-side people.
Now an essential act of our profession is the information design underpinned by the software design.
This is what DDD implies.
Kei Sugimoto @sugimoto_kei
Programmer and Designer of fusion_place, a management infrastructure software
http://www.fusions.co.jp