Best practice w/ naming of enums?

  • Thread starter Thread starter Michael A. Covington
  • Start date Start date
M

Michael A. Covington

I have a class A which contains an arraylist of another class, B, which is
rarely used separately. So I nested B within A.

I also have an enum of the values of one of the items within B. Call it C.

Right now C is also nested directly within A.

So A.C is the type and A.B.C is a variable of that type.

I fear this will provoke confusion. What is a better way to handle the
naming? I have something parallel going on in another class I need to
define.

Should C be right out on top, not nested in anything, and named something
like ABC? Then ABC would be the type and A.B.C would be the variable.
 
Michael,
If you have something parallel going on in another class then it makes sense
to define the enum directly off the namespace, rather than inside one of the
classes.
In this manner, either class can refer to the enum as: namespace.enumName
Peter
 
Peter Bromberg said:
Michael,
If you have something parallel going on in another class then it makes
sense
to define the enum directly off the namespace, rather than inside one of
the
classes.
In this manner, either class can refer to the enum as: namespace.enumName
Peter

Something parallel -- not the same thing.

I ended up using names that end in Enum for the enums, e.g.
Blah.Blither.GraphEnum for the type and Blah.Blither.Graph for the variable.
Some people say not to end the names in Enum, but in this case it made sense
to do so.
 
OK,
we appear to be tuned to different stations here. What I meant was to
declare the enum as if it were another class, so that you could type
NamespaceName.EnumName.
Regarding using Enum in the name, not expected good coding practice. Better
to use a descriptive term such as MyNamespace.GraphType
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 
Back
Top