odiseh
odiseh

Reputation: 26517

C#: How do you manage symbolic constants in your projects? Where do you declare solution scope constants?

How do you manage symbolic constants in your projects? Where do you declare solution scope constants ?

Upvotes: 2

Views: 993

Answers (2)

kemiller2002
kemiller2002

Reputation: 115440

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.

Upvotes: 4

Marc Gravell
Marc Gravell

Reputation: 1062600

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.

Upvotes: 4

Related Questions