DirtyList and ValidList for collections with editable children

DirtyList and ValidList for collections with editable children

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


dshafer posted on Friday, January 05, 2007

I searched around for a while and could not find any references to this issue.  Currently in the BusinessListBase class there is a list that keeps track of deleted child items from a collection.  I got around to thinking yesterday and wondered why there isn't a similar list for dirty and invalid children.  It seems to me that this would be much more efficient than looping through the entire collection to determine if any children are dirty or invalid.  For instance, if you had a DirtyList, you could determine if any child objects were dirty simply by checking if DirtyList.Count > 0.  The same could be done for determining if any children are invalid.  This would also help in the save, as you could just loop through the DirtyList and attempt to update only those instead of looping through all of the children, even if they weren't dirty.  Has anyone every considered doing this?  Does this make any sense?

Dustin

ajj3085 replied on Friday, January 05, 2007

I think its not done because it would be too complex.  Dirty items shouldn't appear in the list, so moving them to a dirty list makes sense beacuse we still need to keep them around. 

Having invalid and valid would make things complicated; the list would still have to show as one list so you'd always need some kind of view to make it seem as a single list.  Sorting and filtering becomes more complicated too.

In the end, you don't really gain a whole lot either from that approach.  Your list code is harder to maintain and its probably more of a performance hit because you're moving objects from one list to another.. its likely faster just to loop through everything.

dshafer replied on Friday, January 05, 2007

I'm not sure, but I think your misuderstanding my suggestion.  What i was meaning was to have a list/hastable/dictionary... on the collection that could store either the child objects that were dirty/invalid or their respective ids.  This would not affect the ui at all and there would still only be one "main list" of objects as far as binding and whatnot goes.

Dustin

ajj3085 replied on Friday, January 05, 2007

Ahh, I did misunderstand that.

Copyright (c) Marimer LLC