How do you manage symbolic constants in your projects? Where do you declare solut开发者_StackOverflow社区ion scope constants ?
It is pretty rare (for me at least) that there isn't an obvious relationship between such constants and some pre-existing class at the heart of the domain model - I'd just add them there. Then the constants are tightly scoped to the appropriate part of the model, rather than just being in a "Constants" class.
Of course, I also find it pretty rare to find true "constants"; many interesting "constants" are described better through configuration options.
We have a constants class where we put all the constants in. We declare it static and then make the constants static public, since there is no need to instantiate it.
精彩评论