Niclas Hedhman wrote: > On Tue, Sep 16, 2008 at 10:21 PM, Niklas Uhrberg > <[EMAIL PROTECTED]> wrote: > > >> Now, if we require that non-root entities inherit their identity from >> their root (i.e. they have a unique identity only within the scope of >> their aggregate) it follows that >> they cannot be re-assigned. Correct? >> > > Well, on my car, I definitely have a "Left Front Wheel" (local > identity), but I am not sure, nor care, whether that is the same > actual wheel (global identity) today as it was yesterday. It may now > even be on a different car as the "Spare Wheel". Let's see if we mean the same here: Example: Car has a global id Car.id and Wheel has a local id Wheel.id which just means that any value of Wheel.id is only guaranteed to be unique in the scope of it's parent Car. It the example above, it looks to me as if you intentionally assume that the wheel has a global identity.
It can be misleading to speak of "Left Front Wheel" as it focuses on the position of the Wheel as opposed to the identity, these are different things. I don't understand what you want to state with: "but I am not sure, nor care, whether that is the same actual wheel (global identity) today as it was yesterday" Is it: As long as it has exactly the same properties as the Wheel that was on left front position yesterday, I'm happy and don't care about its global id? If this is all that it required then it doesn't motivate more than value objects! I would focus more on the situation where I shift wheels between winter and summer, the local id helps me to put them back in the right position which is important. This is a requirement that would imply using entities rather than value objects. (Requirement being that any wheel should stick to the left or right from year to year) Or maybe if the requirements become more elaborate demanding us to keep track of the mileage for each Wheel, then value objects may be inconvenient and we will use entities with local id and update their "rolling distance" each day.... I would say that the question "Is this thing replaceable with any other object with the same property values" is a test question for values objects. As for an example with local id: We have a few plants at home, and some of them even have names :=) One is called Gafsan ( after one of the characters in Mumindalen ). I can ask my spouse "Did you water Gafsan this week" and she will understand! Let's make their names their local id. These plants do not have a global id in a model tracking history and development of the plants in peoples homes. The requirement is to keep a journal of the plants, when they get water e.t.c. to see which survives and the like. Here I could use a local id for the purpose of tracking the individual plant and their history. But I may also decide that they should be root entities for other reasons. The point is just that the requirements stated here only motivate local identity (where our household or similar is the parent). > So, independent of "Is Wheel a RootEntity?" question (probably "yes"), > is that "Local Identity" often makes sense. Does it make enough sense > to support this directly? I think so, but not sure. And the follow-up > would then be, is the "RootEntity" classification permanent (Class > annotation) in an application, or is it a runtime behavior (Instance > property)? > If we stick to DDD as of today the answer must be that it's a permanent classification because the domain model is "kind of static" . If this is good, I think so. Haven't tried to go through what would happen if it was per instance, this would be interesting. > >> I simply assumed that non-root entities can have global identity, but >> this may be an error on my part! >> > > Having looked a bit more, this indeed seems to be an error. But of course only with reference to the paradigm, it may be good for our purposes. I think I'm too used to having global identity for most things to see this with really clear eyes.... > I assume so too. In nature it is so (unless you get very > philosophical), even if the observer doesn't care. > Being philosophically inclined, I have to disagree. There are good examples where the common sense identity concept fails. Do you know the ancient "The Ship of Theseus" example? ( See http://faculty.washington.edu/smcohen/320/theseus.html look at the complex version ) Luckily, I believe this doesn't affect us much because our models don't have to deal with esoteric identity puzzles. > >> It's just so common to let almost everything have a global identity even >> if it's not necessary. >> > > Yes, it is practical and delaying hard questions, often ignoring them > altogether (Assign same wheel to many cars.) > > >> I'm hard pressed to come up with an example of something that should >> have global identity, be re-assignable and not being a root entity. >> A common example of things that are parts of another thing is body parts. >> But even body parts are candidates for re-assignment (transplantation), >> what should we say about this case? >> > > I am starting to think that non-roots "loose" their global identity > when assigned to an aggregate, might be the solution. > That solves your body part problem. While inside your body, it has > local identity, then upon removal, it has global identity, to regain a > local identity in a different body. > An identity that is changing is IMO a contradiction in terms because one of the defining properties if identity is that it is continuous. I would like to see the motivation for having "one object that looses its former identity and gains another identity" as opposed to creating a new object copying some or all the properties of the original one. In a model for transplantation of body parts, if we elaborate the requirements, I think it will emerge that body parts have a global identity all the time but the they can be parts of different bodies from time to time. Since it is still the same organ, the id is the same. > My conclusion now is that only root have global identity.... > > > And that only roots can be re-assigned?? > > > In fact isn't this a lot more complex? > > Preliminary, a yes and no. But I'm not through with this enough to have a solid position. The issues of being a root entity, being reassignable, and having a global identity span both the conceptual model, implementation issues and technical things like transactional semantics. At this moment I cannot overview all of it simultaneously, will have to think more.... Maybe a new thread for this particular question ("And that only roots can be re-assigned??") ? > I would like to think of myself as an Aggregate, but am I not also an > intrinsic part of "Human Race"?? And doesn't our simple abstractions > of Aggregates fall apart? Isn't it the Context that defines what are > Aggregates or not, and probably even that an Aggregate in this context > can have Parts that are Aggregates in other contexts, without those > being Aggregates here? Phew!!!! > > Oh yes, you're touching on an important aspect, but this is also a part of DDD right? It has the very name "Context" where model are allowed to differ because they have different purposes (although modeling the things in the real world). How this fits into Qi4J , I don't know... /Niklas > Cheers > Niclas > > _______________________________________________ > qi4j-dev mailing list > [email protected] > http://lists.ops4j.org/mailman/listinfo/qi4j-dev > > _______________________________________________ qi4j-dev mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/qi4j-dev

