Should Enum class filenames be suffixed with 'Enum'?

Viewed 7480

When breaking out classes into files, I am wondering what the naming convention is for class files containing only enums. Should they match the enum name, like any other class, or should they be suffixed with 'Enum' so that the developer knows that the file contains only an enum?

For example:

namespace MyCompanyName.MyApplication
{
    public enum Colors
    {
        Red,
        Blue,
        Green,
        Yellow
    }
}

Would you say the file containing the above code should be named 'Colors.cs' or 'ColorsEnum.cs'? Alternatively, perhaps there is another accepted naming convention for such files?

5 Answers

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

Related