<story><title>Decision Tables</title><url>https://www.hillelwayne.com/post/decision-tables/</url></story><parent_chain></parent_chain><comment><author>pron</author><text>What I find most remarkable about the comments here is how quickly programmers try to jump to code (I&amp;#x27;m not passing judgment, just making an observation). The goal of this post is to present a simple yet useful &lt;i&gt;specification&lt;/i&gt; tool. Sure, a decision table implemented in Clojure would likely be more readable than one implemented in assembly, but figuring out &lt;i&gt;what&lt;/i&gt; the decisions should be would be far, far more costly and significant (in all interesting cases) than implementing, or reading, either. Sometimes a specification is not even implemented in a single program, but in some distributed system, with no direct representation in code, and sometimes a specification specifies the environment the system interacts with, and is not even implemented by a computer at all. Coding is important, but specifying is usually much more so, as it is both more costly and has a higher impact. Developers should learn how to think about specification and use various aids -- like decision tables -- without thinking at the code level, which is often a distraction.</text></comment>
<story><title>Decision Tables</title><url>https://www.hillelwayne.com/post/decision-tables/</url></story><parent_chain></parent_chain><comment><author>TheAsprngHacker</author><text>Programming languages that support pattern matching support decision tables. This is an OCaml port of the FizzBuzz example (fixing a mistake where the result of the modulo is compared with T and F):&lt;p&gt;&lt;pre&gt;&lt;code&gt;    match n mod 3 = 0, n mod 5 = 0 with
    | true, true -&amp;gt; &amp;quot;FizzBuzz&amp;quot;
    | true, false -&amp;gt; &amp;quot;Fizz&amp;quot;
    | false, true -&amp;gt; &amp;quot;Buzz&amp;quot;
    | false, false -&amp;gt; string_of_int n
&lt;/code&gt;&lt;/pre&gt;
This a &amp;quot;cleaner&amp;quot; version that takes advantage of wildcards (which appear in the article, but not in the FizzBuzz):&lt;p&gt;&lt;pre&gt;&lt;code&gt;    match n mod 3, n mod 5 with
    | 0, 0 -&amp;gt; &amp;quot;FizzBuzz&amp;quot;
    | 0, _ -&amp;gt; &amp;quot;Fizz&amp;quot;
    | _, 0 -&amp;gt; &amp;quot;Buzz&amp;quot;
    | _, _ -&amp;gt; string_of_int n
&lt;/code&gt;&lt;/pre&gt;
Note that the article states, &amp;quot;two rows can’t overlap in what inputs they cover,&amp;quot; but in case analyses expressions of PLs with pattern matching, two rows can share a non-empty set of common matches and the higher row will take precedence.</text></comment>