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

rxelizondo posted on Saturday, December 12, 2009


Well, I have to tell you, this IFieldData.MarkClean() method is just driving me nuts. I mean, I am sure I am not getting something here but to me, the IFieldData.MarkClean() method looks like a method that its tightly coupled to the default implementation of the way the CSLA keeps track of the IsDirty state of the object.

I mean, let’s think about this for a moment, does this method make sense if someone was to code an IFieldData{T} implementation that determined if the BusinessObject property was dirty based on doing a comparison between the original and current values? Probably not right? I mean, I could imagine the implementation of IsDirty property in that case being something like:

return object.Equal(oldVal, newVal);

There would be absolutely no need for an _isDirty field that keept track of the object state right? And if we don’t’ need an _isDirty field then there is really no need for a MarkClean() method correct?

So what are you guys thoughts?


RockfordLhotka replied on Saturday, December 12, 2009

There's a semantic meaning to "mark clean", which is that the object should consider itself to be no longer dirty/changed when that call occurs. If an object doesn't provide an implementation following that semantic behavior, then other parts of CSLA will appear to work incorrectly - though the bug lies in the object that doesn the wrong thing.

So even a custom FieldData object must follow that semantic behavior, or it will appear to break other parts of CSLA (most notably dependent properties like IsSavable, and some aspects of data binding).

rxelizondo replied on Sunday, December 13, 2009

Yeah, I should have taken more time to analyze this before posting.

So basically, in the case of my example, one of the jobs of the IFieldData.MarkClean() implementation would be to set the old value to be the current value.

So if the value was originally “abc” and then the value is changed to “xyz”, the moment the framework calls the IFieldData.MarkClean(), the “xyz” value must become the new original value (basically replacing the “abc” value).

There are probably be other things that should happen when IFieldData.MarkClean() but that is one that sticks out in my head as one of the most obvious one.

Thanks Rocky.

Copyright (c) Marimer LLC