If we have to store the available positions at a company (i.e. Manager, Team Lead, ... etc). What are the best practices for storing it? I have two opinions with comments... "sure, welcoming yours"
- Storing it as DB table with columns ID and Name, and deal with it using queries and joins.
- Storing it as Enum and forget about the DB table.
In my opinion, I will choose the first solution if I have changing items. So that I won't hard code these options as Enum.
I may choose the Enum solution, if I have no doubt that data won't change (for example, Gender: Male, Female).
NOTE: I code in English, and the UI Culture may be Arabic. If I will work with the Enum Solution, I will hard code the culture-based strings in the presentation layer, is it okay from the best practices perspective!!!!
I would like to know your opinions and if my thoughts correspond to what is most recommended "Best Practices"??
I tend to go for the database option as this enables easy querying with meaningful data (i.e. names rather than ID's).
If I am fairly confident that the values will not change then I will enumerate them in the application as wellas it makes development much easier when you do not have to remember the ID of an item and also makes the code much more readable.
This approach allows me to choose whether to include the lookup table in queries or not. For example I would include it in a report query where I want to display the lookup value but may not include it when loading data in my application if I can infer it from the enumeration instead.
Obviously if the values are subject to change or modification enumeration may not be possible.
Only you can judge the impact of UI culture, I am 100% certain of the culture of my users so do not have to worry about it too much :).