Defining value objects
As we have already seen in Chapter 2, Wrapping Business Rules inside the Domain Hexagon, entities are the elements we use to classify system components that have an identity. On the other hand, the value objects don't have an identity. We use value objects to describe those system parts where there is no need to define an identity. Then, we have aggregates that serve to encapsulate the objects' related entities and values.
I recommend starting by creating value objects first because they are like the building blocks, the raw material we'll use to build more elaborated value objects, and—most importantly—the entities. Now, we'll add all the value object classes on the Domain hexagon module created in the previous section when we bootstrapped the Domain hexagon. We'll use the following steps to define value objects:
- Let's start with the
Id
value object class, as follows:package dev.davivieira.topologyinventory...