Niclas Hedhman wrote: > On Mon, Jan 12, 2009 at 4:25 PM, Stuart McCulloch <[email protected]> wrote: > >> yep, so City and Country aren't necessarily entities either - it all depends >> on the model > > Yes indeed. That makes library models even more intriguing.... > > But, interestingly then, City could often be seen as an enumeration, > BUT with a twist... New cities should be able to be added through the > lifetime of an application, there are so many of them that sometimes I > should be able to search them... So, is it entities or just > enumerations/values? Do we need a explicit concept of persisted > enumerations? Does it makes sense?
It all depends on what you want to model. A City could be an int (if you just want to count cities), a Value (if you don't care about identity), or an Entity. It all depends on what you want to accomplish. I think the reasoning with whether it should be this or that has less of an impact on the current question. The important aspects are: what does it mean from a principal point of view, and does it work from a practical point of view? From a both practical and principal point of view, if Entity A has a Value B with a reference to Entity C, then if A is aggregated then B *may or may not* be a valid value, if you take aggregate logic into account (i.e. are A and C part of the same Aggregate or not, or is C an aggregate root). To have a value be ok or not depening on who is referencing it is wrong. For this simple reason I would say that Values cannot have references to Entities. There is also another practical difference between Values and Entities. If B is a Value, then if you want to change the reference from C to D then you have to create a new copy of the old B, set the ref to D, and then set A's reference to the new B value. This is a lot of work. Comparatively, if B is an Entity, then you just set the reference to D, and you're done. This makes a huge practical difference in UI's and similar. I think that the referenced post has some good points, but I am also wondering if maybe one of the core reasons object systems have had trouble is because they have not had enough aggregate roots, and therefore too much spaghetti referencing between entities. /Rickard _______________________________________________ qi4j-dev mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/qi4j-dev

