Typesafe Enum Pattern appropriate here?

From: Arthur (webfoot86_at_yahoo.com)
Date: 12/23/04


Date: 23 Dec 2004 08:57:57 -0800

A logical data model contains groups of items.... a GroupCollection of
ItemCollection.

What is the best design for navigating to a group?
1) Data.Group("A")
2) Data.Group(GroupEnumClass.A) <--typesafe enum pattern

It is probable that groups will be added. I have a colleague that
insists no.1 is the best approach. My concern is that this will lead
to runtime errors and a loss of clarity. Am I being too anal?

The application is written in VB.Net. Multiple applications are based
upon the same core, and so the core must know the interface of the
specific enum class if there is a base GroupEnumClass that is extended
by Application1GroupEnumClass, Application2GroupEnumclass, etc.

I'm thinking that generics, new in VS.Net 2005, and reflection may come
into play here.

Any thoughts or links that I can pursue? Thanks.



Relevant Pages

  • Re: Access awake after 7 years?
    ... The implication that simple applications don't have problems ... > programming problems in Access VBA. ... Yes, and ENUM is an easy way to do that, but it can be ... But that's a case where the inadequacies of the IDE have trained us ...
    (comp.databases.ms-access)
  • Re: Anonymous Struct Members / Struct Constants
    ... bitposition could be defined in an enum which will improve your ... readability. ... I presume you're talking about 8 bit core with a dedicated operation ...
    (comp.lang.verilog)
  • Re: One Enum per File?
    ... This could make for a whole lot of files for some applications. ... One file per enum usually works out best. ... you can make it a top level non-nested class with package visibility ... Dale King ...
    (comp.lang.java.programmer)