Enum vs config file
we want to implement business logic based on records in the table. We have two options.
One way is to create an enumeration in code for each record in the table, and in the code, compare the enumeration with the read record to decide which logic comes next. The disadvantage of this system is that if the key changes in the table (for example, in the autorun fields), the application needs to be recompiled to reflect the changes.
The second way to do this is to store the variables in a config file for each record in the table, and in the code compare the config variable with the read record to decide which logic comes next. The interaction with this system is that the configuration file can be processed and the application will stop working.
What is the best programming pattern for this question?
a source to share
Enumerations must be static and immutable. If you have a solution that requires a change to enumerate, then enums are the wrong solution.
Front-end configuration really suffers from the problems you mentioned, so it is not always a good choice. To help with this, you can encrypt it so that it is not easily modified.
Another alternative would be to create a DLL resource that has a config file as a resource, so it cannot be easily modified. When you need to make changes, you only need to compile the DLLs and deploy only that, not the whole application.
Scott Langham mentioned using a config table in your database. This is also a good idea. Is this possible with your setup?
a source to share
This sounds like something like a state template. I assume you have a table that stores the states (ID, name) and logic associated with each in your application. Given the state id, given the logic you have to follow. You need to decide how to create the correct state, if you are using an ORM you can use a discriminator (state id in this case).
a source to share