Is it correct from DDD POV to compare ValueObject to different types? #498
Replies: 4 comments 1 reply
-
That's just against type names in order to get a |
Beta Was this translation helpful? Give feedback.
-
The other part is
Per DDD, ValueObject talks about equality but not comparability. What does IComparable mean to an Address VO?
and maybe another class
? |
Beta Was this translation helpful? Give feedback.
-
This is just to be able to sort a collection of VOs using LINQ. Also, I think comparability is directly related to equitability -- if you can check if 2 VOs are equal, then you can also compare them if they aren't.
Initially, the class threw an exception because I though there should be no valid scenarios with VO hierarchies, but I changed that after I found a valid use case for VO inheritance: https://enterprisecraftsmanship.com/posts/hierarchy-value-objects/ |
Beta Was this translation helpful? Give feedback.
-
I don't have a good solution here but these are the problems.
|
Beta Was this translation helpful? Give feedback.
-
I saw this unit test.
CSharpFunctionalExtensions/CSharpFunctionalExtensions.Tests/ValueObjectTests/IComparableTests.cs
Line 113 in 049db33
and I was thinking if it is correct to compare ValueObject with primitive types?
When the types are different, ValueObject is doing a string compare.
https://github.com/vkhorikov/CSharpFunctionalExtensions/blob/049db331491e7894361ef9d0640f8375a906eed3/CSharpFunctionalExtensions/ValueObject/ValueObject.cs
Is that correct?
Beta Was this translation helpful? Give feedback.
All reactions