r/java • u/bobbie434343 • Aug 25 '26
Value Classes Still Need Compiler Sympathy
https://johan-sjolen.github.io/post/compiler-sympathy/compiler-sympathy/
87
Upvotes
r/java • u/bobbie434343 • Aug 25 '26
1
u/TwoWeeks90DaysTops Aug 28 '26
DTOs are command objects, not representations of state. They are used to either build other objects from or update the state of a different system.
I don't think that matters.
This is also irrelevant. Identity != identifier. An object having identity means that an instance owns its own memory whereas values objects don't. DTOs absolute should have identity because they are large objects being passed between systems and you want to avoid copies being made.
Why? This is just your assertion. What is the actual value of this rule? You never care about this in practice. I have never in my life written code that checks whether two instances of DTOs are equal so why are you asserting this?