Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Abstract classes useful?
Message
De
02/06/2008 10:55:32
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
02/06/2008 10:46:20
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01320973
Message ID:
01320992
Vues:
18
>>>What exactly is the purpose of abstract classes in VFP?
>>
>>Declaring a class as abstract in OTHER languages makes sure that the class won't be instantiated directly. The idea is that the class is somehow incomplete, and that some details have to be filled in at a lower level.
>
>That's one idea that came to mind: Build in code that generates an 'error' when such an 'abstract' class is used in a concrete case. But it would probably be a ridiculous construction.
>
>>This can't be enforced in Visual FoxPro, but I suppose it still makes sense to use inheritance in such a way that the superclass isn't useful by itself. But again, there is no way to enforce it.
>
>Is there a good reason of are we just brainwashed to think that there is sense to use it?!

Well, I think all this is very related to the concept of inheritance itself. It makes sense to define PEMs at different levels of an inheritance chain, and doing this, you might have "incomplete" classes at the upper levels of the hierarchy, and declaring them as "abstract" (say, in Java) would enforce that - avoid the programmer accidentally inheriting the wrong class.

According to the Wikipedia, many dynamically-typed languages do NOT have abstract classes.

This, I think, has a certain similarity to being able to strictly declare a variable type. Being able to enforce this can avoid the programmer assigning the wrong type to a variable, through carelesness. Not having this feature you can also program, but you must be more careful, or simply put up with runtime errors that wouldn't appear in the other case.
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform