I need to make a decision based on a rather large set of 8 co-dependent conditions.
| A | B | C | D | E | F | G | H
-----------+---+---+---+---+---+---+---+---
Decision01 | 0 | 1 | - | 1 | 0 | 1 | - | 1
Decision02 | 1 | 0 | - | 0 | 0 | - | 1 | -
...
Decision11 | 1 | 0 | 1 | 1 | 1 | - | 1 | 1
Each of the conditions from A to H can be true (1), false (0) or non-relevant (-) for the decision.
So with a given input of
A B C D E F G H
1 0 1 0 0 1 1 1
it should evaluate to Decision02.
The decisions are unambiguous so from any given set of input conditions it's clear which decision has to be made (and in a case that isn't covered by the decision matrix, an exception shall be thrown).
The developer who worked before me on this project tried to implement this as a 500 line long nested-if behemoth which of course is buggy as hell and isn't maintainable.
So I searched for the best way to implement such a piece of logic and I've come upon decision tables/lookup tables/control tables.
I've found a lot of decision table generators, but not a single piece of code on how to implement the decision making process :(
I can make the decision table in the underlying MSSQL database, or in code, or xml, or whatever it takes. I just need some pointers on how to implement this at all.
What's the best practice to implement this logic? Dictionary? Multidimensional array? Something completely different?