Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is Method Overloading a good or bad thing?
Message
De
01/07/2004 21:39:16
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
01/07/2004 19:01:40
Anthony Testi
Fabtrol Systems Inc.
Eugene, Oregon, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00919869
Message ID:
00919959
Vues:
7
>What about the situation where 90% of the code in the 2+ methods are the same? Now we have code duplication. A solution may be for each of the overloaded methods to 'translate' the parameters into some common form and then all of them call the common code method.
>
>Anthony

Templates, as Bill points out, are one way. Another is, indeed, to have one method invoke another one. For instance, you can have a version of a constructor with one parameter, and another version with two. In other words, the second parameter is optional. You can consider any of the two versions as your main constructor; and have the other one call your "main constructor".
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform