Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

So, when adding controls to a component using the designer, or implementing events and method routines, any source code generated by the editor will refer to the component currently being edited using the generic name #COM_OWNER.

     Define_Com Class(#PRIM_LABL) Name(#Label) Parent(#COM_OWNER) 

OR

     Evtroutine Handling(#Com_Owner.Initialize)
#Com_owner.Prepare
Endroutine

As a large percentage of code typically needs to refer to the current location, the use of the generic Com_owner to mean 'here' greatly simplifies code understanding. It also means that copied code can be pasted directly in to a target without the need to update component references with specific class names.

...

Thus, when in an application that uses inheritance, we might define basic behavior in a base ancestor class but override that behavior by redefining the method in the inheriting class. At execution time the processing in the ancestor class will be ignored and the redefined method will be executed.

     Mthroutine Name(Prepare) Options(*Redefine)
* Class specific processing
Endroutine

Whilst this typical use of a redefined method is often desirable, there may also be circumstances where rather than wanting to completely change the processing, we simply need to augment it. To enable this we might write the following

     Mthroutine Name(Prepare) Options(*Redefine)     
#Com_Ancestor.Prepare
* Class specific processing
Endroutine

Here, the method is redefined but the very first line of the new method causes the ancestor version of the method to be executed. This technique is typically used when a change to the ancestor processing is the exception rather than the rule.

...

Thus in the Ancestor we might have something similar to the following.

     Mthroutine Name(Prepare)      
* Run base code then class specific code
#Com_owner.PrepareBase
#Com_Self.PrepareSelf
Endroutine
Mthroutine Name(PrepareBase) Options(*Final)
* Base class processing
* Final – This method cannot be redefined
Endroutine
Mthroutine Name(PrepareSelf)
* Redefine in inheriting classes
Endroutine

In the inheriting class we would then see:

     Mthroutine Name(PrepareSelf) Options(*Redefine) 
* Class specific processing here
Endroutine

At runtime, invoking the Prepare method would result in the PrepareBase method being executed. However, because the invocation of PrepareSelf uses Com_Self, the runtime looks further up the inheritance chain for a redefined version and executes that rather than the version of the method defined in the ancestor.

...