Decision Tables

I really like decision tables but they’ve fallen out of common knowledge. Let’s fix that.

A decision table is a means of concisely representing branching and conditional computations. In the most basic form, you have some columns that represent the “inputs” as booleans and some columns that represent outputs and effects. It looks like this:

A
B
C
f(A, B, C)
T
T
T
1
T
T
F
3
T
F
T
7
T
F
F
“cucumber”
F


NullError
– means that it doesn’t matter what the value is. If you’re feeling saucy you can add enumeration inputs, too, as long as the enumerations cover all the possible values for that input. For a decision table to be “consistent”, all possible inputs must map to exactly one row. There can’t be any inputs that aren’t covered, and a two rows can’t overlap in what inputs they cover. Two rows may, however, map to the same output.

As an example, here’s fizzbuzz:

n % 3
n % 5
f(n)
T
T
“FizzBuzz”
T
F
“Fizz”
F
T
“Buzz”
F
F
n
That’s all there is to decision tables. That’s what I like


Original URL: http://feedproxy.google.com/~r/feedsapi/BwPx/~3/o1Fc4kOTuMY/

Original article

Comments are closed.

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

%d bloggers like this: