-
Notifications
You must be signed in to change notification settings - Fork 909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Value object with identity? #22
Comments
It's for special cases of Value Objects that must be persisted through an On Aug 28, 2016 8:13 AM, "Beka Tsotsoria" [email protected] wrote:
|
Thanks for the reply! So basically identity is enforced by ORM and not the domain, right? I understand that it gives convenience to configure ORM to handle mapping between domain and persistence entities without writing translation code manually, but does not it leak abstraction? I say leaky abstraction cause, ID is not used on Value Objects in terms of business and there can exist different repository implementation which can store and retrieve collection of value objects without enforcing them to have identity. I understand that we might "say no to perfect code" sometimes in favour of some another benefit (like convenience in this case) and I don't see any problem as long as team respects Value Object semantics and does not access them directly via ID, but is not possible to improve this somehow? Or is it a thing I should really worry about? |
It's one way to solve the particular problem, a way that is discussed in my On Aug 29, 2016 3:04 PM, "Beka Tsotsoria" [email protected] wrote:
|
After little googling I came across to an idea where one suggests to extend subclasses of IdentifiedValueObject like GroupMember at the persistence layer and declare ID (and potentially other persistence related fields) on this extended object, this way IdentifiedValueObject will not be needed anymore and domain layer will be free from the persistence concerns. I'll definitely read IDDD sooner or a later! |
@sevteen I was thinking the same whereas actually by declaring ID in the extended object directly, you just added persistence data in your domain. By using the IdentifiedValueObject, you don't explicitely have to add this knowledge. Moreover the id being private in the super class, you never come accross as a developper in your child OneToMany value object. |
Can anyone explain why IdentifiedValueObject has identity? Does not it violate definition of Value Object? Is it domain identity or persistence identity?
The text was updated successfully, but these errors were encountered: