Which of the following is better? Defining an enum type inside a class
as a nested type, or in the the namespace?
An example of nested type enumerated type would be:
public Class Product
Public Enum Status
psNormal
psCharged
End Enum
.....'other stuff in class
'Use the enumerated type within the class like this:
Dim enuPS as Status
End Class
So in the rest of the class I would have to declare a new instance of
the enumerated type as such:
Dim enuPS as Product.Status
The regular approach (defining in the namespace would) would be as such:
public class Product
.....
end class
Public Enum ProductStatus
psNormal
psCharged
End Enum
Notice that the name of the enumerator would change depending depending
whether it's nested to the object or not.
The framework engineers clearly seem to think that the namespace
definition of enumerators is better, but I still care about the
community opinion. I think there are pros and cons to both approaches.
The biggest advantage that i see of nesting the enum definition is that
it's tightly coupled with a class that it makes most sense with. On the
con side you have to use the . which makes it look like a member of a
class instead of a type definition, and the autocompletion in the IDE
won't work when declaring new instances of the type.
So what does everyone think about that? Which way is better?
Thanks.
Alex
*** Sent via Developersdex http://www.developersdex.com ***