Naming Advice Required

  • Thread starter Thread starter C# Learner
  • Start date Start date
C

C# Learner

In a class containing only constant data, should the class name be
pluralized?

e.g.:

class SecretCodes
{
public const string Alpha = "asfasfdfsadf";
public const string Beta = "sadfsfdsasfdasfad";
}

Should this be called "SecretCodes" or "SecretCode"? I instinctively
think that the plural is suitable, but then, when declaring enumerations
we use the singular. Then again, enumerations are different in that
they can be instantiated.

So which is the correct way?
 
In my opinion,

I think that it should be SecretCode.

As when you are going to create a new instance of the clas

e.g. SecretCode m_objSecret = new SecretCode(); would make more sense to me than SecretCodes m_objSecrets = new ScretCodes()

However it would also depend on the context and use of the class

Hope this helps in some way
Regards
Jonathan Rucker
 
In a class containing only constant data, should the class name be
pluralized?

I wouldn't make the fact it contains constant data the deciding
factor. In general, classes describing a single entity (e.g. a
"Person", or "Customer") should be singular, while collections holding
a whole list of those entities should be plural ("Customers" as a
Collection or ArrayList or whatever).

Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
C# Learner wrote:

<snip>

I guess I missed out something from my post -- the class will *not* be
instantiated or subclassed. It is merely a container of constant values.

Should the name be pluralised in this case?
 
C# Learner said:
C# Learner wrote:

<snip>

I guess I missed out something from my post -- the class will *not* be
instantiated or subclassed. It is merely a container of constant values.

Should the name be pluralised in this case?

I tend to think so, however current practice in the framework doesn't help.
I could think of two classes that follow this pattern offhand, Color and
OpCodes. One plural, one not...

Use what you think you(and your team if there is one) will prefer.
 
Daniel said:
C# Learner wrote:

Should the name be pluralised in this case?

I tend to think so, however current practice in the framework doesn't help.
I could think of two classes that follow this pattern offhand, Color and
OpCodes. One plural, one not...

[...]

Good point. I've checked the source to OpCodes -
http://www.123aspx.com/rotor/rotorsrc.aspx?rot=41451 - and it's just
using readonly values, which is similar to what I'm doing. However, in
the source you'll notice that the members are instances of 'OpCode', so
I'm now wondering whether they only pluralize the name in this case
because 'OpCode' already exists.

Thanks for the post; I'm going to look further into this, but I'll stick
with using the pluralised form at current.
 
Back
Top