Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I want Polymorphic enums
Message
De
01/03/2006 13:05:14
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
I want Polymorphic enums
Divers
Thread ID:
01100503
Message ID:
01100503
Vues:
79
This is an issue that has annoyed me for a while, but after reading Bill Caton's message #1098525, I was inspired to weigh in.

I want the possibility to declare abstract or virtual enums.

A simple example would be a class called Purebred with an abstract enum called Breed. I would subclass Cat and Dog classes. For dog, the breed enum would countain AfghanHound, Beagle, Collie, etc. and for cat it would be Abyssinian, Birman, CornishRex, etc. For a specific instance, a property would expose the value of a specific instance.

An even more practical example might be an abstract enum called color, where each subclass would implement it to define the subset of all possible colors that it was allowed to be.

Referring to Perry Forman's quote,

"If you are finding you need to do something like this, the design of your program is clearly all wrong. Enums are there for hard coded groups of items that will never change during runtime. If for example you want people to add groups (e.g. add a username), you should use an alternative datasource (e.g. database, file)."

Does this apply to what I would like to do?

I could declare an abstract int object which Cat and Dog implemented that tied to some kind of DataTable that I pulled from a DataBase that associated ints with strings, or something equally awkward, but it isn't as clean.

If someone can suggest a way to accomplish the same kind of pattern, I would appreciate it.
David S. Alexander
Kettley Publishing
20271 SW Birch Street, 2nd Floor
Newport Beach, CA 92660-1752
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform