Logic-grid conditional

From Wiki @ Karl Jones dot com
Jump to: navigation, search

A logic-grid conditional is a conditional (computer programming) which uses arrays and bitwise operations.

Description

Narendra Venkataraman writes:

Deeply nested if-else and giant switch statements are a common sight in any complex logic implementation. Maintaining such a messy chunk of code is really a nightmare.

This technique comes in very handy in implementing rule engines and finite state machines (FSM).

Typically, any logic has a set of boolean predicates that are evaluated to obtain a result or to perform an action.

In the logic-grid approach, the results are stored in an array and the index of the array is calculated from a bitwise combination of boolean predicates.

The key to this approach is that the logic is embedded into data instead of sequence of logic statements. Thinking beyond the bits and bytes, the approach draws parallel with the way people make decisions. We evaluate all the inputs available at a moment and make the best possible decision.

See also

External links