Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DoDefault and inheritance
Message
De
21/02/2008 10:05:14
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01294645
Message ID:
01294746
Vues:
22
>>Following proper OOPS techniques, Thomas Ganes suggestion is the correct one. Create a second method in A and override it in B. When the Init calls the method, it will call the local version. If you need the B of the local method to call the parent version, then use DODEFAULT().
>>
>>
>Thomas and Marcia suggested this technique. We're also using hook methods.
>
>So, line 10 will become a separate method in the Base class and the derived class would only need to overwrite one method. Hopefully line 10 can be easily created as a separate method.
>
>Otherwise I would use Borislav's idea of invoking this line conditionally based on some property.
>
>In either case, this assumes that we would need to change class A.

In line with this thread, if using a conditional method, then the sub-classing to class B is unnecessary. Calling a second method and overriding it in subclasses allows for more granular coding. By rule, each method has one duty to do. Parent method defines the order and procedure they are called. Then, in the future, if a request is made for a third version of the class, only the second method is updated, and the parent class is never touched. The other sub-classes of A are at low risk of becoming buggy.

(Recently I have studying methods of refactoring code).
Greg Reichert
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform