Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where to place dodefault()
Message
From
16/11/2018 12:40:27
 
 
To
14/11/2018 17:02:05
Al Doman (Online)
M3 Enterprises Inc.
North Vancouver, British Columbia, Canada
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
01663345
Message ID:
01663464
Views:
49
>>
>>*-- 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().

Basic template/hook pattern is one of the easiest and (IMO) sadly underused patterns.
But if you encode it like your example, it can create warts as well.
The template pattern has to be coded in the uppermost class / best right where it is defined.
Each method overriding the pure method HAS to call dodefault first, otherwise all code(s) in before-hook might be not be called before some lines of actual method ;-)

For that reason I prefer as standard template
xxxAction_Before()
xxxAction_Execute()
xxxAction_Finish()
so that each template step can be overridden with dodefault put where it fits best.
Still, it is best to agree on "normal practices" for before ban finish hook to have "expected" behaviour, be defining default/standard dodefault() locations for those particular methods, so you can expect outer>>inner or inner>>outer call sequence as "normal"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform