Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a good idea to keep all the enums in one place?

Tags:

c#

.net

When I'm building a class library I usually create a file Enums.cs to hold all the enums used in the assembly. Here is an example:

namespace MyNamespace
{
    public enum Colors
    {
        Red,
        Green,
        Blue
    }
    public enum Shapes
    {
        Circle,
        Square,
        Triangle
    }
}

This makes all my enums easy to find, well organized and easy to access in code.

I'm wondering if there is any reason why this would not be such a good idea?

like image 787
Dean Kuga Avatar asked Apr 06 '10 17:04

Dean Kuga


1 Answers

It's generally better to arrange definitions by modularity, rather than by kind.

like image 191
Barry Kelly Avatar answered Oct 13 '22 20:10

Barry Kelly