Hi, Daniel,

Well I've been thinking about this for quite some time now and I must say, it's interesting :)

I guess for many people the question now is - what exactly are you trying to accomplish with this structure? I suppose you are not trying to use CC instances to keep an audit trail of BB instances, are you? ;)
Perhaps with a clear idea of what is being accomplished a better model can emerge.


In any event, I can't think of a clear way to model this, or better put to mimize the amount of effort needed. Consider:

* Classes in the CC role have the same properties as classes in the BB role, plus some properties

* Properties in the CC role have as default value their namesake in BB, but may be overriden

Now, I initially thought cloning could help here. You would create class CC with property Parent as BB, and on %OnNew/%OnOpen you would populate the properties of CC with their BB namesake properties, unless CC's properties already had a value (which would override BB).

The problem with this is that it leaves you with a duplicate of BB's data in CC. CC's properties can't be transient because they override the values in BB.

The only "solution" I can see to this is to also modify CC.%OnSave() (or I think as of v5 CC.%OnAddToSaveSet() is more appropriate) so that if the value of a given CC property is the same as the value of the namesake BB property, it gets nullified. Otherwise we'd have massive data duplication.

Let me try to write a pseudo-example in case the above stuff doesn't make sense...

Class BBRole [Abstract] {}

Class CCRole [Abstract] {
  Property Parent As BBRole;

  Method %OnNew(initval As %String) As %Status {
   // ForEach property in Parent
   //   If this.property == "" Then this.property = Parent.property
   // I wonder if %OnNew() can be a generator method?
  }

  Method %OnAddToSaveSet() {
    // ForEach property in this class
    //   If this.property == Parent.property Then this.property = ""
   }
}

But note that setting a property to "" may not be the same as assigning it its default value from a storage point of view...

This is the best I can come up at this point. Let's wait for the heavyweights to comment :)

Hope this (somehow) helps,

Ram�n

--
ZCacheLib - Open Source Extensions for Cach�
http://www.zcachelib.org



Reply via email to