Reputation: 53
I was recently told by my supervisor that ALL of the constants need to go in the Resources of our MVC application and I am to either put them there or into the database. I cannot find anywhere on Microsoft's website where this is stated. And secondly, there will eventually be dozens if not hundreds of constants in here.
The problem is we can't use them in switch statements and if I right click to go to definition it doesn't take me there. Which means if I want to change one I have to go search through the mess in Resources.
I always thought what went into the resources.resx were application specific.
I am used to putting constants that were specific to a certain controller in that controller. Global constants I would put into the Base class. Or create a constants class that holds all of the constants. I prefer the first
Can someone answer this question for me or point me to the location where it is stated that this is the new best practices?
Upvotes: 1
Views: 225
Reputation: 5629
Resources are mainly for strings that needs to be localized and for additional data, such as icons, other images, or even textual data - but not for code just because that code happens to be a constant. In fact... the resource editing framework might very well auto-generate a constant in a code file to help you identify the resource. So you would essentially replace one constant with another.
I suspect your supervisor is either confused, or there have been a misunderstanding.
Upvotes: 6