Reputation: 922
I just found out that some co_workers are using Enum a lot. And using Enum as some kind of data store for some lists, like status list, role list, etc.. And I am not sure if this is a good way to deal with this kind of data. I would like to put some data into DB and then read them into cache instead of putting the data into the code itself.
Upvotes: 1
Views: 1128
Reputation: 41397
The decision of enum
vs. database table depends on whether you expect additional values to be added/removed while the system is in production.
For example:
Use enum
for:
Payment method (cash, check or credit card)
Billing frequency (daily, weekly, monthly, quarterly)
Gender
Status
Use a database table for:
Carrier for delivery (FedEx, UPS, ???)
Product category (books, music, games, ???)
Airline
Upvotes: 1
Reputation: 922
To answer my own quetsion. It will be the political correct answer "It depends.....". This is 50%-50% question. For developers who like Enums, Enum can be very helpful and the code can be very clear... For developers who hate Enums, Enum is nothing but Const in another name and everytime there is a new status added, you have to add this new status to the Enum, .....
Upvotes: 0