InfoQ

Presentation

Recorded at:
Recorded at

Power Use of Value Objects in DDD

Presented by Dan Bergh Johnsson on Nov 20, 2009

Community
Architecture
Topics
Domain-Driven Design
Tags
QCon London 2009 ,
QCon
The next QCon is in London Mar 10-12, Join us!
Summary
Dan Bergh Johnsson refreshes the listeners’ memory on using value objects showing by example how their good use can revolutionize a program’s architecture, simplifying it, making it more readable and testable, in a word, better.

Bio
Dan Bergh Johnsson has been teaching at the Computing Science department at Uppsala University, Sweden, and has been using unit testing, DDD, and Agile for his consulting activity. He is also a speaker at national and international conferences such as Colorado Software Summit, ExpertZone, SoftDev, and JavaZone.

About the conference
QCon is a conference that is organized by the community, for the community.The result is a high quality conference experience where a tremendous amount of attention and investment has gone into having the best content on the most important topics presented by the leaders in our community. QCon is designed with the technical depth and enterprise focus of interest to technical team leads, architects, and project managers.
Excellent presentation. by Raj Moodaley Posted Nov 21, 2009 7:27 AM
Very Good by Chris Gardner Posted Nov 21, 2009 11:36 AM
Very Good Presentation by Ashok Guduru Posted Nov 21, 2009 4:33 PM
Great! by Justin Forder Posted Nov 28, 2009 10:27 AM
Where to draw the line? by Pedro Dias Posted Dec 2, 2009 12:30 AM
Re: Where to draw the line? by Dan Bergh Johnsson Posted Dec 5, 2009 5:57 PM
  1. Back to top

    Excellent presentation.

    Nov 21, 2009 7:27 AM by Raj Moodaley

    Good example of how value objects can simplify the code and extend the domain language

  2. Back to top

    Very Good

    Nov 21, 2009 11:36 AM by Chris Gardner

    Highly recommended. Dan illustrated that code that might appear wholly in an entity or DTO can more appropriately be moved to a Value Object. Something that I inferred from the presentation is that a DDD style Policy or Specification would also benefit from operating on a number of smart Value Objects.

  3. Back to top

    Very Good Presentation

    Nov 21, 2009 4:33 PM by Ashok Guduru

    A very good example showing the difference between DTO and VO for the people confusing between them.

    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.

  4. Back to top

    Great!

    Nov 28, 2009 10:27 AM by Justin Forder

    Very clear presentation, immediately useful, requires no previous exposure to DDD.

  5. Back to top

    Where to draw the line?

    Dec 2, 2009 12:30 AM by Pedro Dias

    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).

    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.

  6. Back to top

    Re: Where to draw the line?

    Dec 5, 2009 5:57 PM 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

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.