Home > Articles

  • Print
  • + Share This
This chapter is from the book

Highlighting the Core

Some elements of a domain are more important than others. In the book Domain-Driven Design, Eric Evans explains that when a domain grows to a large number of elements, it becomes difficult to understand, even if only a small subset of the elements are really important. A simple way to guide developers to focus on particular subsets is to highlight them in the code repository itself. He calls that subset the highlighted core.

Therefore: Flag each element of the core domain within the primary repository of the model without particularly trying to elucidate its role. Make it effortless for a developer to know what is in or out of the core.

Using annotations to flag the core concepts directly in the code is a natural approach, and it evolves well over time. Code elements such as classes or interfaces get renamed, are moved from one module to another, and sometimes end up deleted.

The following is a perfect simple example of curation by annotations:

1  /**
2   * A fuel card with its type, id, holder name
3   */
4  @ValueObject
5  @CoreConcept
6  public class FueldCard {
7   private final String id;
8   private final String name;
9   ...

It is an internal documentation integrated into the search capabilities of an IDE. You can see the list of all core concepts just by searching every reference of the annotation in the project, which is always up-to-date (see Figure 5.2).


Figure 5.2 The highlighted core is available instantly and at any time in the IDE through a search on all references to the @CoreConcept annotation

And, of course, tools can also scan the source and use the highlighted core as a convenient and relevant way to improve curation. For example, a tool to generate a diagram may show different levels of detail in different cases, such as showing everything when there are fewer than seven elements and focusing only on the highlighted core when there are many more than seven elements. A living glossary typically uses this technique to highlight the most important elements in the glossary by showing them first or by printing them in a bold font.

  • + Share This
  • 🔖 Save To Your Account