Entities vs Value Objects: Which one is BETTER?

  Рет қаралды 712

Marco Lenzo

Marco Lenzo

Күн бұрын

Пікірлер: 17
@MarcoLenzo
@MarcoLenzo 3 ай бұрын
Do you use Value Objects enough in your models? Do you make the immutable? Let me know 🤓
@davidgg8462
@davidgg8462 2 ай бұрын
Very good video
@MarcoLenzo
@MarcoLenzo 2 ай бұрын
Thank you
@digitic3551
@digitic3551 3 ай бұрын
Gonna try yo use value objects more... As tou said, it's easier to maintain and the code is more readable ...
@MarcoLenzo
@MarcoLenzo 3 ай бұрын
Great!
@Talaria.School
@Talaria.School 3 ай бұрын
👏🏻
@MarcoLenzo
@MarcoLenzo 3 ай бұрын
👋
@richardsonhmm
@richardsonhmm 3 ай бұрын
Muito obrigado! [pt-br] 🫡
@MarcoLenzo
@MarcoLenzo 3 ай бұрын
It's my pleasure
@jairo_manrique
@jairo_manrique 2 ай бұрын
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
@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
@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-rm3xn
@YoQi-rm3xn 2 ай бұрын
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....
@MarcoLenzo
@MarcoLenzo 2 ай бұрын
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-rm3xn
@YoQi-rm3xn 2 ай бұрын
@@MarcoLenzo what is setRed setBlue and setGreen? They r not setters?
@MarcoLenzo
@MarcoLenzo 2 ай бұрын
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.
@YoQi-rm3xn
@YoQi-rm3xn 2 ай бұрын
@@MarcoLenzo yes please, would b great
Eventual Consistency: How It WORKS and Why It's IMPORTANT
7:25
Avoid These BAD Practices in Python OOP
24:42
ArjanCodes
Рет қаралды 73 М.
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,6 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 96 МЛН
Coding Unbreakable Encryption in C | One-Time Pad
17:42
HirschDaniel
Рет қаралды 4,4 М.
Why Musical IQ Soars After 30
9:38
Rick Beato
Рет қаралды 1,5 МЛН
TLS Handshake Explained - Computerphile
16:59
Computerphile
Рет қаралды 566 М.
ТЮРЕМЩИК В БОКСЕ! #shorts
00:58
HARD_MMA
Рет қаралды 2,6 МЛН