A short question that always bother me when I develop in Java. I actually use a lot of different enums and I am never sure of where I should put them. Usually, I create a special package named enumeration which I am quite sure is not the best practice. Should I put my enums directly in the same package than the group of class it most belong to?
Also, would it be the same for another language (C# or C++)?
The best descision depends on how the enumeration is used.
E.g.
A
) more than others (e.g. the others call methods on A
that have parameters of type of the enumeration; you might want to put it in the same package/namespace as A
is in.In general, find the best package/namespace based on where its used most
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With