215
CHAPTER 6 | Tackle Business Complexity in a Microservice with DDD and CQRS Patterns
constructed, you must provide the required values, but you must not allow them to change during the
object’s lifetime.
Value objects allow you to perform certain tricks for performance, thanks to their immutable nature.
This is especially true in systems where there may be thousands of value object instances, many of
which have the same values. Their immutable nature allows them to be reused; they can be
interchangeable objects, since their values are the same and they have no identity. This type of
optimization can sometimes make a difference between software that runs slowly and software with
good performance. Of course, all these cases depend on the application environment and deployment
context.
Dostları ilə paylaş: