Dealing with Faulty Logic
October 19, 2011 Ted Holt
Supposedly computer programming is a logical science. One would think, then, that computer programmers would be logical thinkers. It is not so. Let me provide a few examples of illogical thinking taken from real production programs. Then I will show a simple, low-tech way to deal with logical expressions so that they don’t end up illogical. Let’s start with this example taken from fixed-format RPG specs. I suggest you find the bad logic yourself before reading my comments. TYPE IFNE 'A' TYPE IFEQ 'S' XCODE CABNE 'S' CONTIN ENDIF TYPE IFEQ *BLANK XCODE CABEQ 'S' CONTIN ENDIF ENDIF This code |