Do you use Value Objects enough in your models? Do you make the immutable? Let me know 🤓
@davidgg84622 ай бұрын
Very good video
@MarcoLenzo2 ай бұрын
Thank you
@digitic35513 ай бұрын
Gonna try yo use value objects more... As tou said, it's easier to maintain and the code is more readable ...
@MarcoLenzo3 ай бұрын
Great!
@Talaria.School3 ай бұрын
👏🏻
@MarcoLenzo3 ай бұрын
👋
@richardsonhmm3 ай бұрын
Muito obrigado! [pt-br] 🫡
@MarcoLenzo3 ай бұрын
It's my pleasure
@jairo_manrique2 ай бұрын
Hi Marco, great video thanks. Im a little bit confused on how manage order Items in order aggregate without expose the item set, how iterate over them, update item quantity (may be a easy method) and mapping to dto? And, what method explotion mean? I appreciate your advice a lot.
@MarcoLenzoАй бұрын
Hi, excuse me for the late reply. I'm not sure I understand your problem with the item set. Why don't you want it in the aggregate? It's fine having it there.
@MarcoLenzoАй бұрын
Hi! Excuse me for the late reply. Why don't you want the item set in the aggregate? You can have a set or list of VOs in an entity or aggregate.
@YoQi-rm3xn2 ай бұрын
Setters shouldn't be private for RGBColor VO as rule of thumb ??? Creating VO with "new" and "public" constructor? Setter would return a new instance everytime of RGBColor, something is not good....
@MarcoLenzo2 ай бұрын
If you notice, RGBColor is a Java record. In Java records, all fields are (implicitly) final and there are no setters to foster immutability. Give it a try and let me know.
@YoQi-rm3xn2 ай бұрын
@@MarcoLenzo what is setRed setBlue and setGreen? They r not setters?
@MarcoLenzo2 ай бұрын
Oh now I understand what you are referring to. Those are examples of side-effect free functions. They are not typical setters. Maybe I should have given a different example naming the functions differently to avoid confusion. The idea is that VOs are not data containers with no behavior. It is fine for them to implement functions that act on its state. However, when this happens, we need to enforce immutability, thus we are forced to return new instances. This way there is no risk to change the state of some other object that was holding a reference to the initial VO. You can find this concept explained in the book by Vernon "Implementing DDD" in the chapter dealing with Value Objects. Hope this clarifies it. Excuse me for the poor example. Also search the web for side-effect free functions and you'll find a lot of material. I'll try to cover them in another video.