[ACCEPTED]-Should Enum class filenames be suffixed with 'Enum'?-filenames

Accepted answer
Score: 10

The file name in my opinion should be the 5 same as the name of the Enum, which - according 4 to the Enum Naming guidelines should not have an Enum suffix. Also 3 the guideline suggests your enum should 2 be singular so taking both into account it should 1 be Color.cs

Score: 7

First off, this is a complete personal/team 7 preference thing.

That being said:

I personally 6 would name it Colors.cs. This keeps the filename 5 corresponding to the type name. When I'm 4 working on the API, if "Colors" are a fixed 3 set of things represented by an enum, I'd 2 probably know that, and there would be no 1 confusion.

Score: 3

What about creating a folder called Enums 1 and naming the file Colors.cs?

Score: 1

Creating a folder called Enumerations, Enums 12 or something descriptive should be enough. Also 11 you can follow the C# naming standards that 10 said:

"Names of Enumerations Do not 9 use a prefix on enumeration value names. For 8 example, do not use a prefix such as ad 7 for ADO enumerations, or rtf for rich text 6 enumerations, and so on.

This also implies 5 that you should not include the enumeration 4 type name in the enumeration value names. The 3 following code example demonstrates incorrectly 2 naming an enumeration's values.

C# code as 1 follows

public  enum Teams

References: Names of Classes, Structs, and Interfaces

Score: 0

This is a perfect example of how namespacing 9 and folder structure can make your directory 8 more readable. My company sticks enum types 7 in an _enumeration file but leaves them in the same 6 namespace as the classes that are primarily 5 using those enums. It's a matter of preference, you 4 should do whatever is most readble to you 3 and your teammates. I would not use any 2 sort of Hungarian-esque notation in your 1 folder structure.

More Related questions