Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where to place dodefault()
Message
 
 
To
15/11/2018 01:48:07
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
01663345
Message ID:
01663439
Views:
42
>>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)?
>>
>>TIA
>
>One additional thing you may need to take into account is, that in certain circumstances the superclass code may return a value. For instance in the form, the original init method may return .F. to prevent the form from instantiating for several reasons (user access level, data cannot be loaded, licensed functionality etc.)
>
>If you expect the init to be able to return .F. you need to validate the result. If you create a subclass, you want as much as possible keep the same interface signature, because code that uses those classes depend on the specific behavior of the original class. Otherwise you get an italian dish instead of clean code.
>
>See also Liskov Substitution Principle for more complex situations:
>
>"Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it."
>
>
>LOCAL llRetVal
>llRetVal = DODEFAULT()
>
>IF m.llRetVal
>   * Your Code
>ENDIF
>
>* Important: Return the same value as original class was supposed to do:
>RETURN m.llRetVal
>
Thank you for your 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
Previous
Reply
Map
View

Click here to load this message in the networking platform