views:

69

answers:

1

Hi all,

I was wondering how you use your ddd model within a web application. Within Eric Evan Cargo application there's the Cargo class which contains the value object Itinerary. Within Itinerary is a collection of Legs, again a value object. All value objects hide the surrogate id to the outside world. So when using this domain model, how would I create a web app, where you can click on a cargo itinerary, list all legs and then show the details of a leg by redirecting to a new "leg detail" page. Usually I would pass the LegId within the query fields and read it out again on the detail page. But since it has no id, how would you do that?

Using the index of a leg which might change when the collection gets sorted?

Passing all values within the query fields since this is the value object identity?

Sounds like a step backwards to me :)

+1  A: 

If the leg has no id, the only way you have to refer to it is through the Cargo, which has an identity, and therefore can be associated with a URI/URL. To refer to a specific leg, you have only the index, which can be a number, or a dictionary key. If you have sorting issues, you can define two lists: one with the canonical ordering for reference purposes, and another with the ordering, mapping order position and canonical index.

As for the reason why the value objects in Evans' example have ids, I think it's for serialization purposes.

Of course, you can also opt for a Itinerary/Leg with identity.

Stefano Borini