Replaceability
In your model an immutable Value should be held as a reference by an Entity as long as its constant state describes the currently correct Whole Value. If that is no longer true, the entire Value is completely replaced with a new Value that does represent the currently correct whole.
The concept of replaceability is readily understood in the context of numbers. Say that you have the concept of a total that is an integer in your domain. If the total is currently set to the value 3 but must now be the value 4, you don’t, of course, modify the integer 3 itself to become the number 4. Instead you simply set the total to the integer 4:
int total = 3; // later... total = 4;
This is obvious, but it helps make a point. In this example ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access