royvanrijn: JDK7.B won't fix modularity, won't fix the dependency mess and won't add anything new to the language (except minor Coin stuff)

Quine – McCluskey

December 4th, 2009

About a week ago I had a discussion with a fellow programmer about some boolean logic. We had three parameters, something like:

  1. personHasInsurence (A)
  2. personNeedsInsurence (B)
  3. personIsKnownAtThisAgency (C)

We also had two particulair cases for an insurance page:

Case 1:
Person has insurence and isn’t yet known at this agency

Case 2:
Person doesn’t have insurence, needs insurence and is known at this agency

Case 3:
Person doesn’t have insurence, doesn’t need insurence and is known at this agency

So the view-logic was a bit complex:

if( (A && !C) || (!A && B && C) || (!A && !B && C ) ) {
    showPage();
}

Then I remebered something I learned at school some time ago. So called karnaugh maps. I’ve completely forgotten how to use them, but I knew it was possible to calculate the shortest form to comply to the logic rules. When looking further I found the so called “Quine McCluskey“-algorithm, and I decided to implement it (just to learn how it works).

Quine – McCluskey algorithm

First of, lets go through a couple of terms.

Continue reading »