Power Use of Value Objects in DDD
Recorded at:
- Share
-
- |
Read later
Reading List
Sponsored Content
Excellent presentation.
by
Raj Moodaley
Very Good
by
Chris Gardner
Very Good Presentation
by
Ashok Guduru
IMO a real-world business application should never use the primitive data types on domain objects. There will always be a value object perceivable for every single element of business object's data.
Thanks.
Great!
by
Justin Forder
Where to draw the line?
by
Pedro Dias
Conceptually, one is still speaking about "RecordId" as an abstract consept, thus, according to your line of thought, it warrants the use of a RecordId class, however, this is extremely hard to sell to a developer who could care less about order.
Value objects also have a dark side - they complicate the use of ORMs such as hibernate and EF.
Re: Where to draw the line?
by
Dan Bergh Johnsson
I'm curious to learn where you draw the line - Field Identifiers, such as primary keys on typical record objects - should these be value objects offering a range of validation features? (a database Id cannot be zero or negative).
I am very pragmatic about it. Does it smooth out discussions with product owners, dbas, gui designers, users or other stakeholders? Or, does it clarify code, leading to less repetition (DRY violations), bugs, or awkward code? In any of those cases: Yes. If none of those benefits, and no other: No, spend your time and energy somewhere else where you have a better payback for your efforts.
Conceptually, one is still speaking about "RecordId" as an abstract consept, thus, according to your line of thought, it warrants the use of a RecordId class,
In many cases technical constructs like "RecordId" or "Customer Number" take on a life of their own and become part of what stakeholders need to be conceptually aware of. It sounds like that in your example. Litmus test: check the parameters of the methods in the service layer API (called by presentation). If it is in there, an explicit value object class is probably a good idea.
however, this is extremely hard to sell to a developer who could care less about order.
Did not quite understand ... Do you mean "order" = "ordering/sorting" or "order" = "request for goods or similar"?
And in what way is it a "hard sell" to developers? Are they not interested in "fluffy domain stuff"?
Value objects also have a dark side - they complicate the use of ORMs such as hibernate and EF.
I would phrase that the other way around. ORMs have a dark side - they complicate the use of value objects; limiting your design power. :)
But seriously: that trouble is historically an undebatable fact, but in "modern" versions e g JPA 2.0 it has become *a lot* better.
Dan Bergh Johnsson
The Elements of Simple Design to the rescue
by
J. B. Rainsberger
I really like the idea of PhoneNumber becoming part of a glossary for what /we/ mean by "phone number" on this project right now.
What constitutes a valid text representation of a PhoneNumber depends...
by
J. B. Rainsberger
Still, wherever the validation rule resides, I hope to find it only in one place. :)
Informative, still have questions about persistence and Spring DI
by
Alexander Yin Yang
Also, about error handling. What if I need different behaviour for incorrect input. Let's say, in one case I need to accumulate errors from all of form fields before respond with error to client instead of instantly falling? Exceptions are seemed to be inappropriate here





Hello stranger!
You need to Register an InfoQ account or Login or login to post comments. But there's so much more behind being registered.Get the most out of the InfoQ experience.
Tell us what you think