- "A deep model has power because it contains the central concepts and abstractions that can succinctly and flexibly express essential knowledge of the users’ activities, their problems, and their solutions. The first step is to somehow represent the essential concepts of the domain in the model. Refinement comes later, after successive iterations of knowledge crunching and refactoring. But this process really gets into gear when an important concept is recognized and made explicit in the model and design."
- "Many transformations of domain models and the corresponding code happen when developers recognize a concept that has been hinted at in discussion or present implicitly in the design, and they then represent it explicitly in the model with one or more objects or relationships."
- Digging Out Concepts
- Listen to Language
- "Listen to the language the domain experts use. Are there terms that succinctly state something complicated? Are they correcting your word choice (perhaps diplomatically)? Do the puzzled looks on their faces go away when you use a particular phrase? These are hints of a concept that might benefit the model."
- "This is not the old “nouns are objects” notion. Hearing a new word produces a lead, which you follow up with conversation and knowledge crunching, with the goal of carving out a clean, useful concept."
- Scrutinize Awkwardness
- "The concept you need is not always floating on the surface, emerging in conversation or documents. You may have to dig and invent. The place to dig is the most awkward part of your design. The place where procedures are doing complicated things that are hard to explain. The place where every new requirement seems to add complexity."
- "Now you have to actively engage the domain experts in the search. If you are lucky, they may enjoy playing with ideas and experimenting with the model. If you are not that lucky, you and your fellow developers will have to come up with the ideas, using the domain expert as a validator, watching for discomfort or recognition on his or her face."
- Contemplate Contradictions
- "Different domain experts see things different ways based on their experience and needs. Even the same person provides information that is logically inconsistent after careful analysis. Such pesky contradictions, which we encounter all the time when digging into program requirements, can be great clues to deeper models."
- Read the Book
- "Different domain experts see things different ways based on their experience and needs. Even the same person provides information that is logically inconsistent after careful analysis. Such pesky contradictions, which we encounter all the time when digging into program requirements, can be great clues to deeper models."
- Try, Try Again
- "The examples I’ve given don’t convey the amount of trial and error involved. I might follow half a dozen leads in conversation before finding one that seems clear and useful enough to try out in the model. I’ll end up replacing that one at least once later, as additional experience and knowledge crunching serve up better ideas."
- "All these changes of direction are not just thrashing. Each change embeds deeper insight into the model."
- How to Model Less Obvious Kinds of Concepts
- "Things, event very abstract ones [...], are the meat of most object models, along with the actions those things take. [...] But other important categories of concepts can be made explicit in a model as well."
- Explicit Constraints
- "Constraints make up a particularly important category of model concepts. They often emerge implicitly, and expressing them explicitly can greatly improve a design."
- "[W]arning signs that a constraint is distorting the design of its host object.
- "Evaluating a constraint requires data that does not otherwise fit the object’s definition."
- "Related rules appear in multiple objects, forcing duplication or inheritance between objects that are not otherwise a family"
- "A lot of design and requirements conversation revolves around the constraints, but in the implementation, they are hidden away in procedural code."
- Processes as Domain Objects
- "What I am talking about here are processes that exist in the domain, which we have to represent in the model. When these emerge, they tend to make for awkward object designs."
- "The key to distinguishing a process that ought to be made explicit from one that should be hidden is simple: Is this something the domain experts talk about, or is it just part of the mechanism of the computer program?"
- Specification
- "Business rules often do not fit the responsibility of any of the obvious entities or value objects, and their variety and combinations can overwhelm the basic meaning of the domain object. But moving the rules out of the domain layer is even worse, since the domain code no longer expresses the model."
- "Create explicit predicate-like value objects for specialized purposes. A specification is a predicate that determines if an object does or does not satisfy some criteria"
- Applying and Implementing Specification
- "Much of the value of SPECIFICATION is that it unifies application functionality that may seem quite different. We might need to specify the state of an object for one or more of these three purposes. "
- Validation - "To validate an object to see if it fulfills some need or is ready for some purpose"
- Given an object, return whether or not the specification is satisfied by the object.
- Selection (Querying) - "To select an object from a collection (as in the case of querying for overdue invoices)"
- While this could be applied at the code level using the same code used for specification, there are a number a situations where this would prove impractical, and instead approaches of specifying the specification so that it can be applied at a sql query level may be necessary, and various approaches for this are discussed.
- Building to Order (Generating) - "To specify the creation of a new object to fit some need"
- You can create a generator that takes in a specification to satisfy, and the generator will return an object that satisfies the specification.
- "Building to order can mean creation of an object from scratch, but it can also be a configuration of preexisting objects to satisfy the spec."
Technology is always changing. It makes the industry interesting and exciting to work in, but it also makes it hard for you, as a developer, to keep up with the changes, let alone get ahead. And yet staying on top of these changes, and thriving because of them, is a rewarding and worthwhile goal, because by doing so, you unlock the potential of what you can accomplish. Here, I explore the how of doing just that.
Friday, July 10, 2020
Domain Driven Design Chapter 9 Summary
Chapter 9: Making Implicit Concepts Explicit
Labels:
domain-driven-design