I have a static string variable which i need to change possibly depending on the HTTP protocol.
Is it bad practice to change the static string variable>
static string QuoteWebServiceUrl = CommonFunctions.ReadAppSetting("QuoteWebServiceUrl");
if(url == "https")
{
QuoteWebServiceUrl = CommonFunctions.ReadAppSetting("QuoteWebServiceUrlSecure");
}
else
{
QuoteWebServiceUrl = CommonFunctions.ReadAppSetting("QuoteWebServiceUrl");
}
Thanks
No. Of course you can change the value of a static string variable. Why do you think it's a bad pratice?
I mean, modifying a static variable is a non-issue. It's a variable. It can vary. So why would varying (i.e., modifying it) be a bad practice? Yes, there are situations where you shouldn't or have to be careful if you do, but in general, it's not.
The big issue here is reading application settings deep in the guts of your application. It kills maintainability and testability. It is a horrifically bad practice and I encourage you to stop immediately.
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