I need to define enums in several classes to represent available actions for each class. . Now I wonder what is the best way to deal with this?
1) Create separate enums
public enum Foo {Insert, Update, Delete , Select };
public enum Bar {Insert, Select };
2) or use a general enum for all of them
public enum FooBar {Insert, Update, Delete , Select};
Edit : I want to use this enums in class methods parameters
public void MethodOne(Foo action){ ...}
The answer should come from your domain – ubiquitous language
However, I think that you are going to get into troubles if you implement a new enumeration for each class, this approach is going to be error-prone and it’s going to confuse your developers. Now imagine the poor guys that will have to maintain your code in the future…
If you insist in using enumerations, I think it would be better to create s single enumeration named:
Actionsand use it consistently across your applicationIf you want a more elegant solution, I would recommend you to consider the State pattern