object in collection who's validity depends on the parent object containing the collection

object in collection who's validity depends on the parent object containing the collection

Old forum URL: forums.lhotka.net/forums/t/395.aspx


skagen00 posted on Friday, June 16, 2006

Parent - Collection - Child

So a validity of the children depend on a state of the parent that has the ability to change.

Currently, what I do is I have a stateful property on the collection object (stateful so that any NEW objects in the collection can get the appropriate information) that also cascades the information down to the child objects.

In some similar respects, this behavior is done with the _editLevel - when new items are added to the collection, they get their _editLevelAdded assigned upon insertion.

My concrete case is within a query engine of sorts - I have a parent (not a root, but irrelevant) that represents a piece of data. Based on translations that may occur, the "effective data type" can change. For instance, a string data element - take its length, and you end up with an integer. One can apply any number of crtieria (criterion is my child object). While StringBegins makes sense for a string, it certainly has no meaning for an integer. My "operators" are essentially an enumeration, since there is specific logic that is coded for each one, etc.

When something causes the "effective data type" to change, I tell the collection what the new effective data type is and the collection tells the children. The children have validation rules that look at this effective data type to determine their validity.

Is this kosher?

dean replied on Saturday, June 17, 2006

see this earlier discussion - it may apply:

http://forums.lhotka.net/forums/thread/944.aspx

Dean

Copyright (c) Marimer LLC