Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
OTHER >>  THE DIFFERENCE BETWEEN NODEFAULT AND DODEFAULT()

  Marcia Akins
  Where is Marcia Akins?
 Akorn
 Ohio - United States
 Marcia Akins



How VFP implements inheritance

Visual FoxPro implements inheritance in a bottom upward fashion. When an event occurs which requires that an object takes some action, Visual FoxPro begins by executing any code that has been defined in the method associated with that event in the object (such code is, therefore, referred to as "Instance Level" and it will override any inherited code unless an explicit 'DODEFAULT()' function call is included at some point).

If there is no code in the object (or a DoDefault() has been specified), VFP continues by executing any code defined in the same method in the class identified in the object's ParentClass property. This process continues up the hierarchy defined by successive ParentClass references until either a method containing code without an explicit DoDefault() or a class where the ParentClass property points directly to a Visual FoxPro base class, is found. Either condition identifies the 'Top' of the class hierarchy for that object and no further references are searched for.

On completion of any instance level code, and any inherited code, Visual FoxPro finally runs any code that is defined in the relevant native base class method. (Any such code will always be executed unless you include an explicit NODEFAULT command somewhere in the inheritance chain.) Unfortunately there is no documentation to tell you which base class methods actually contain executable code, although some are obvious. KeyPress, GotFocus and LostFocus are all examples of events which require native behavior and which, therefore, have code in the baseclasses. Conversely there are events that obviously do not have any native behavior – Click, When and Valid are all examples of base class methods which simply return the default value (a logical .T.).

The basic rule of thumb here is that the use of DoDefault() is a good thing. It means that behavior is being augmented in the sub-classes. Frequent over-riding of parent class behavior (i.e. method code in the sub-class that does not contain DoDefault()) is a sure sign that there are fundamental problems with the design of a class and generally means that functionality has been placed too high in the hierarchy.

FEEDBACK

naten baptista @ 10/13/2010 6:04:30 AM
thanks
that solved one of the problems that I would have faced.
Always wanted to know what the DODEFAULT() meant, but somehow got roped up in some other piece of code.

Luis Daniel Franco Perez @ 6/28/2012 4:30:10 PM
Hola Marcia me gusto tu comentario es bueno, soy Luis Daniel de Venezuela Programador Professional desde hace ya 25 años, me gustaria compartir conocimientos contigo de VFP, actualmente programo con la version 9 sp2 con n capas, bueno saludos y espero estes bien mi correo es luisdfrancop@hotmail.com

PEDRO J GONZALEZ foxtice:BESTLAW@AOLCOM @ 1/15/2015 12:30:32 AM
hi whatys up call 3472473996



Your Name: 
Your Feedback: 

Spam Protection:
Enter the code shown: