June 2017
Intermediate to advanced
394 pages
8h 52m
English
Doctrine requires that all database Entities have a unique identity. Because we want to persist Money Value Objects, we need to then add an artificial identity so Doctrine can handle its persistence. There are two options: including the surrogate identity in the Money Value Object, or placing it in an extended class.
The issue with the first option is that the new identity is only required due to the Database persistence layer. This identity is not part of the Domain.
An issue with the second option is the amount of alterations required in order to avoid this so-called boundary leak. With a class extension, creating new instances of the Money Value Object class from any Domain Object isn't recommended, ...