Value Objects in CQRS - where to use

前端 未结 5 566
甜味超标
甜味超标 2021-01-30 00:00

Let\'s say we have CQRS-inspired architecture, with components such as Commands, Domain Model, Domain Events, Read Model DTOs.
Of course, we can use Value Objects in our Dom

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-30 00:07

    Value Objects are or at least should be immutable. Once instantiated with a value that value will never change throughout the lifetime of the object. Thus, passing VOs as data to DTOs (such as Events) should not be an issue since all you can do with them is get their value. At the most their value in a differing representation such as toString() as opposed to an original getValue() which might return an integer or whatever the value is.

提交回复
热议问题