Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where to place dodefault()
Message
 
 
À
14/11/2018 17:02:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
01663345
Message ID:
01663385
Vues:
39
>>Hi,
>>
>>What is a good practice when a form is based on another form, as far as where to place the dodefault() in the child form?
>>
>>My feeling is that it should be at the top of the child form method. For example.
>>
>>Say a base form is mybaseform (in MyBaseForms.vcx). And it in the INIT method of this form there is a code.
>>
>>Then you create a new form MyChildForm based on the MyBaseForm. And it has some code in the INIT() method too. I think that in the child form INIT method the sequence should be as follows:
>>
>>
>>*-- Init method of child form
>>dodefault()  && call the code in the parent INIT method
>>*-- put the code specific to the child form INIT method
>>
>>
>>Does the above make sense or there is/are issue(s)?
>
>Yes, that's the right idea. Some comments:
>
>1. You're avoiding the rookie/too little coffee mistake of forgetting to call DODEFAULT() at all, when you actually need the parent class code ;)
>
>2. If your method takes parameters, remember to pass them in DODEFAULT()
>
>3. Exactly where you place DODEFAULT() depends entirely on your code requirements. In some frameworks you see code like this:
>
>
>* Child form .Init()
>
>LPARAMETERS tuParm1, tuParm2, ...
>
>=This.BeforeInit( tuParm1, tuParm2, ... )
>
>=DODEFAULT( tuParm1, tuParm2, ... )
>
>=This.AfterInit( tuParm1, tuParm2, ... )
>
>This gives a place to put code you'd like to run before or after a given method's default code, without having to override parent code or worry about exactly where to place DODEFAULT().

Thank you for your input. It all makes sense.
"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