My product owner has asked me to make some comparision logic configurable so the process engineers can change things without making code changes. Currently the code is a SELECT CASE
statement with various IF THEN
statements that are fairly standard. The problem I can't seem to find a way around is that he wants through configuration to AND/OR
a variable number of comparisons in the IF THEN
statements. His idea is the that the configuration would work like a limited query builder for the process engineers. The only solution I've come up with is to build a function in a string and use the VBCodeProvider to compile it at runtime. Is there a better way to approach this?
views:
70answers:
2
+1
A:
One way to do it is just store the booleans in your configuration file, load them up at run time, and use them in your code like any other boolean.
A better way would be to have the configuration as close to his problem domain as possible, then code up the proper booleans from those to use in your code.
John at CashCommons
2010-09-15 20:19:20
LOL at myself. I knew I was over complicating it, and I've done it right dozens of times. Thanks
Loscas
2010-09-15 20:34:39
You're welcome. I've found it's easier to see the problem when you're not in the middle of it yourself. ;)
John at CashCommons
2010-09-15 20:52:48
+1
A:
You could use expressions to accomplish this. With this you would be able to build up an IfExpression and build up its conditions. You would be able to compile this and run it all at runtime.
PhilB
2010-09-15 20:33:53