Opinions wanted on using MarkOld with EditableChild objects

Opinions wanted on using MarkOld with EditableChild objects

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


hurcane posted on Friday, October 13, 2006

Per the book, IsValid and IsDirty should be overridden when an object contains child objects. Typically, this is done as follows:

Public Overrides ReadOnly Property IsDirty() As Boolean
  Get
    Return MyBase.IsDirty OrElse mChild1.IsDirty OrElse mChild2.IsDirty
  End Get
End Property

This patten makes a lot of sense to me. If you have grandchild objects, everything casades down automatically. It also makes it easy to create a checklist for developers when adding an editable child object. The checklist incudes items to override IsDirty and IsValid.

What about MarkOld? In 2.x, MarkOld is automatically called by the data portal when fetching and updating a root object. The examples in the book and the templates all include MarkOld calls inside of the Friend-scoped data methods (Insert, Update, etc.).

Would it make sense to override MarkOld in the parent object and make calls to MarkOld on the child objects, following the same pattern as IsDirty and IsValid?

hurcane replied on Friday, October 13, 2006

Well, I found a technical problem already. MarkOld is protected, so a parent business object can't call it directly. I still think this pattern makes sense, so I'm trying to come up with a way to implement it.

Copyright (c) Marimer LLC