I have seen this many time in many places. And heard many different arguments to validate the reasons for it too.
I am talking about having hard coded values or string in your code.
ItÃ¢â‚¬â„¢s not like the people who were coding it donÃ¢â‚¬â„¢t know that itÃ¢â‚¬â„¢s a bad idea, but sometimes some developers lacks the time and motivation to implement a separate way to handle this issue. Matter of fact sometimes they are just not empowered enough to implement a better solution.
Depending on how complicated your project is, you can always create a static class in your project to read from a config file or you can also create a simple Class library where you can have logically organized enums and then use you as you need.
I will give you few example here
#1 When you are going with the app.config and one static class in your project.
You might have your AppSettings.config like thisÃ¢â‚¬Â¦keeping it simple
And your static class will look like this
#2 When you want to use a Class Library
You might want to create a separate Enum class library to keep track of your values.
- Create a Procject name (example) MyEnums
- Create static class Enum
Depending on how many different segment you have you might want to seperate them logically.
For example I have one called Indicators.
Here is an example class. This is just for this blog example.
Now you can reference the project to your client project and use the value.
You can always use a hybrid model where you get the values on your class library from different appsettings and enums as needed.
You should always cater this to your specific need.