Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Basic question on OOP
Message
 
 
À
23/10/2008 12:30:56
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01356615
Message ID:
01356646
Vues:
25
>>Hi,
>>
>>I know I should know the answer to this question after using VFP for 10 years but let me ask just to be sure.
>>
>>I have a form class (child class) based on another form class (parent class). In the LOAD method of the child class I have a bunch of code and then I always have DODEFAULT(). The parent class has Nothing in the LOAD method. I believe that I really don't need this DODEFAULT() in the child class LOAD method and therefore can remove/comment this line. Am I correct?
>
>If you have absolutely no code, the parent method is run. I really see no reason to have that single line - but if you later add code - in your example, to Form.Load() - don't forget to include a DoDefault().
>
>If you DO include DoDefault(), for any reason, additional considerations may apply. The following explanation is not specific to the Load() Method, but to inheritance in general.
>
>1. Any value returned by the parent method may have to be passed up to the next level. Say you have a method SaveRecord(), and this returns .T. if the save was successful. You have at least three methods involved: SaveRecord() for the form you are editing, SaveRecord() for the parent class, and some method that invoked SaveRecord() and wants to know whether the record was saved successfully. Here is an example.
>
>
>local llSuccess
>llSuccess = DoDefault()
>* Additional code goes here
>return llSuccess
>
>
>2. Additional parameters, received by the child form/class, may also have to be passed to the parent class. Expanding the above example:
>
>
>lparameters tcSomeOption
>local llSuccess
>llSuccess = DoDefault(tcSomeOption)
>* Additional code goes here
>return llSuccess
>
>
>
>So, having the un-needed DoDefault() may have pros and cons.
>
>Pro: You already have the DoDefault() there, and won't forget it later.
>
>Cons: A line that really isn't needed; also, there may be the additional complications I mentioned, depending on the method.

Hilmar,

Thank you very much for the detailed input.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform