As I recall it's not a good thing to use Switchable objects .. but here is my use case:
Root Object is Location ....
Location has child collection of Venues and Venues are unique to Location
Venues have child collection of Items which have a 1 to 1 relatioship w/Venue (an item only belongs to one Venue)
Items have child collection of ItemIngredients ... and 1 ingredient can be associated with many Items
I want to be able to show:
I'm stuck now with my initial design ... where Location is EditableRoot and has a list of EditableChild ... Venue Objects as children .... Now I'm trying to figure out how to add the Items to a Venue which is forcing me to look at making Venue switchable -- both EditableRoot and EditableChild
Is the best practice to have Location and Venue both as Editable Roots ... and create LocationVenueAssignment as the editable child of Location even tho a Venue can only belong to one Location ?? ---
Obviously .. unlike ProjectTracker .... there does not need to be an associative table in the DB for LocationVenueAssignment, since the Location is a property of the Venue
Or should I re-think the Parent-Child relationship between Venue and Location and just make LocationID a property of a Venue Editable Root and use another approach to implement the "show all venues in a location" use case ??
... Clearly there is a containment relationship between Location and Venue and I've always believed that with containment the pattern is to make the contained object an Editable Child. But in this case the Editable Child (Venue) is also the Root of the Venue's Items ... and -- like Location and Venue -- an item can only belong to one Venue.
Strange that it has taken me this long to stumble upon this design issue ..... it can't be so uncommon ... please share your solutions with me for handling this scenario.
Thanks,
Steve
From page 394 of C# 2005 book ....
Note that the parent object here might be a root object, or it might be a child itself—child objects can be
nested, if that’s what the business object model requires. In other words, this concept supports not only root-child,
but also child-grandchild and grandchild-to-great-grandchild relationships.
An EditableChild can have it's own collection of Editable Children ???
Is that all I need to know ??
Thx,
Steve
Copyright (c) Marimer LLC