9.2. What is a Domain Model?
The quintessential object -oriented analysis step is the decomposition of a domain into noteworthy concepts or objects.A domain model is a visual representation of conceptual classes or real-situation objects in a domain [MO95, Fowler96]. Domain models have also been called conceptual models (the term used in the first edition of this book), domain object models , and analysis object models .[2]
[2] They are also related to conceptual entity relationship models, which are capable of showing purely conceptual views of domains, but that have been widely re-interpreted as data models for database design. Domain models are not data models.
Definition In the UP, the term "Domain Model" means a representation of real-situation conceptual classes, not of software objects. The term does not mean a set of diagrams describing software classes, the domain layer of a software architecture, or software objects with responsibilities. |
[3] Capitalization of "Domain Model" or terms is used to emphasize it as an official model name defined in the UP, versus the general well-known concept of "domain models."
Applying UML notation, a domain model is illustrated with a set of class diagrams in which no operations (method signatures) are defined. It provides a conceptual perspective . It may show:
- domain objects or conceptual classes
- associations between conceptual classes
- attributes of conceptual classes
Definition: Why Call a Domain Model a "Visual Dictionary"?
Please reflect on Figure 9.2 for a moment. See how it visualizes and relates words or concepts in the domain. It also shows an abstraction of the conceptual classes, because there are many other things one could communicate about registers, sales, and so forth.The information it illustrates (using UML notation) could alternatively have been expressed in plain text (in the UP Glossary). But it's easy to understand the terms and especially their relationships in a visual language, since our brains are good at understanding visual elements and line connections.Therefore, the domain model is a visual dictionary of the noteworthy abstractions, domain vocabulary, and information content of the domain.
Definition: Is a Domain Model a Picture of Software Business Objects?
A UP Domain Model, as shown in Figure 9.3, is a visualization of things in a real-situation domain of interest, not of software objects such as Java or C# classes, or software objects with responsibilities (see Figure 9.4). Therefore, the following elements are not suitable in a domain model:
- Software artifacts, such as a window or a database, unless the domain being modeled is of software concepts, such as a model of graphical user interfaces.
- Responsibilities or methods.[4]
[4] In object modeling, we usually speak of responsibilities related to software objects. And methods are purely a software concept. But, the domain model describes real-situation concepts, not software objects. Considering object responsibilities during design work is very important; it is just not part of this model.
Figure 9.3. A domain model shows real-situation conceptual classes, not software classes.
Figure 9.4. A domain model does not show software artifacts or classes.
Definition: What are Two Traditional Meanings of "Domain Model"?
In the UP and thus this chapter, "Domain Model" is a conceptual perspective of objects in a real situation of the world, not a software perspective. But the term is overloaded; it also has been used (especially in the Smalltalk community where I did most of my early OO development work in the 1980s) to mean "the domain layer of software objects." That is, the layer of software objects below the presentation or UI layer that is composed of domain objects software objects that represent things in the problem domain space with related "business logic" or "domain logic" methods. For example, a Board software class with a getSquare method.Which definition is correct? Well, all of them! The term has long established uses in different communities to mean different things.I've seen lots of confusion generated by people using the term in different ways, without explaining which meaning they intend, and without recognizing that others may be using it differently.In this book, I'll usually write domain layer to indicate the second software-oriented meaning of domain model, as that's quite common.
Definition: What are Conceptual Classes?
The domain model illustrates conceptual classes or vocabulary in the domain. Informally, a conceptual class is an idea, thing, or object. More formally, a conceptual class may be considered in terms of its symbol, intension, and extension [MO95] (see Figure 9.5).
- Symbol
words or images representing a conceptual class. - Intension
the definition of a conceptual class. - Extension
the set of examples to which the conceptual class applies.
Figure 9.5. A conceptual class has a symbol, intension, and extension.
[View full size image]
Definition: Are Domain and Data Models the Same Thing?
A domain model is not a data model (which by definition shows persistent data to be stored somewhere), so do not exclude a class simply because the requirements don't indicate any obvious need to remember information about it (a criterion common in data modeling for relational database design, but not relevant to domain modeling) or because the conceptual class has no attributes. For example, it's valid to have attributeless conceptual classes, or conceptual classes that have a purely behavioral role in the domain instead of an information role.