I was asked this question in interview, but could not find answer anywhere:Lets say a application has feature which will unlock to different feature to diff customer lets say addition, deletion, edit allowed only for user1 user2 and user3, so I have already written code for all features and created exe, but when some customer pay extra I activate out of addition edit for example feature like happens in games, I found is impossible to do by config file ? I suggested writing switch case in code and change userlevel in config file. But I am not sure. Is there any way to do above problem using OOPS and config file.
Disable or Enable feature in C# application
c#;object oriented;wpf
There are many solutions to the general problem you present. I will not get into disadvantages or advantages, just enumerate a few ways for you to explore further, and in no way I expect to be exhaustiveInput options (to define which options to enable/disable):a) Config file a.1 - add toggle variables (many feature variables, each true/false)a.2 - add feature string list (e.g. features=feature1,feature2,feature4 implies feature 3 is disabled)b) Database tableb.1 - single table with a row per featureb.2 - single row with a list of featuresb.3 - multiple tables, for example relating users vs. featuresc) Registry (generally similar to config solutions, but can be used as a database through subkeys)d) Proprietary file (similar to config but you define a specific file structure)e) Web service (program connects to a service to get configuration, then similar to config file). Particularly common for mobile appse.1 - receives JSONe.2 - receives XMLe.3 - proprietary formatProcessing options (to define how to execute the enabled/disabled ):a) Set boolean variables, use if on specific code pathsb) Switch statement (your solution)c) Strategy patternd) Apply IoC pattern where you load a specific processor depending on the configuration