Answer the question
In order to leave comments, you need to log in
Questions about ValueObject?
There is a User ValueObject called Address which contains 7 fields.
Country, State, City, Zipcode, District, House, Apartment.
When selecting from the user table, it also selects ObjectValue, you can either skip it somehow, so as not to select unnecessary information once again.
Previously, I did this as a separate entity, built connections User -> Address, however, if necessary, I did a join.
However, DDD allows you to add a user field and make it a ValueObject address, so we avoid unnecessary joins and unnecessary selection from an extra table.
1 - is it possible to somehow miss the ValueObject when loading the Entity?
2 - how to filter our entities if we have objects there and not simple string / integer fields? (Doctrine2 PhP)
3 - best way to validate ValueObject?
4 - Maybe you should use UserAddress as a separate entity, for statistics, etc. etc.?
5 - And what about such fields as UserEmail, but is it necessary to make it, email as ValueObject? What will it give?
6 - What about fields like boolean and itneger? For example UserIsVerified and UserRating? How then to build requests, statistics of who is activated and ratings?
7 - Is it worth touching the id at all and making it a UserId? Or leave autoincrement?
Regarding the 7th, I think conflicts may arise if the database is stupid, and not having time to select the last key, create a ValueObject and save a new entity, an error may occur, since with brakes the probability of 2 identical primary key UserId will be high.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question