Radically Simple DecisionTables in Google Sheets

Coding complicated logic in an application can be a challenging task for many programmers. This is mostly due to the limited number of options you have when dealing with decisions in software engineering. Most programming languages are equipped with just your typical if-then-else and switch statements. And that's it.

Imagine for example a personal loan application with all that heavy evaluate-if-this-guy-matches-our-qualifying-criteria logic. You'll end up with tons of if-then-else statements all over the place, like:

if (applicantAge > 18) { if ( applicantAge < 30 ) { if ( borrowingAmount > 1000 && borrowingAmount < 5000 ) { if ( creditRating > 0 ) { return 1; } } else { if ( rating <= 0 ) { return -1; } } } else if ( applicantAge > 30 ) { if ( borrowingAmount > 1000 && borrowingAmount < 5000 ) { if ( creditRating > 0 ) { return 1; } } else { if ( rating <= 0 ) { return -1; } } } } else { return 0; }

Using this typical branching technique can lead to a number of issues from reduced scalability and readability to performance penalties for your software.

If you're looking for a strong alternative to the good old but somewhat outdated if-then-else and switch code, you should consider using decision tables.

What are decision tables?

A decision table provides a framework for accurate statement of decision logic, represented in a tabular format. With it, you can define complex cause-and-effect rules in Google Sheets. The tabular representation of a decision table is its biggest advantage, as all the work related to decision logic is done in an easy-to-comprehend spreadsheet.

Using a decision table will enable you to abstract away all the complicated logic of your app and also significantly reduce your code base. Most importantly it will free you from hardcoding your decision logic. Let's take a quick look at the main benefits of switching (pun intended) to Harmony Decision Tables.

Simplify your logic with Harmony Decision Tables

With Harmony Decision Tables you won't need to code your logic with complex nested condition statements, nor will you have to deal with 100+ lines of switch statements anymore. All the heavy decision-making logic of your application will be migrated to a Google Spreadsheet, where you can safely define the logic in an easy-to-use and debug fashion. Here's an example of a decision table:

Harmony Decision Tables

With this type of condition-result syntax you can define every logical relation for your application.

Easy to understand by everyone

Implementing a decision table in your application can streamline your development process by improving the communication between your programmers, testers and analysts and other non-technical personnel. This is due to the fact that everyone can understand the logic in a decision table thanks to its compact, tabular format.

Easy conversion to code

Direct conversion of the logic defined in the Sheet is radically simple with Harmony Decision Tables. Our decision tables service comes with a RESTful API which allows you to get the result of complex logical expression with a single line of code, in cURL for example:

curl --data “applicant.age=20&applicant.gender=male&ccode-redit.score=3&ccode-redit.history_ranking=5&borrowing.amount=5000&lending.type=unsecucode-red”http://decisiontabl.es/api/NIniu2s9fs

The result comes in a nice JSON format like:

{ "case_id":"5El", "facts":[ { "concept":"dialog", "attrib":"approve order", "value":"n_a", "queue":"managers", "because":[ { "concept":"total", "attrib":"order", "op":"g_than", "value":100 } ] }, { "concept":"order", "attrib":"discount", "value":20, "queue":"undefined", "because":[ { "concept":"total", "attrib":"order", "op":"le_than", "value":2000 }, { "concept":"total", "attrib":"order", "op":"ge_than", "value":1001 }, { "concept":"customer", "attrib":"level", "op":"eq", "value":"gold" } ], "is_ref":false } ] }

Are you dealing with complex logical I/O relations and prominent if-then-else logic? Do cause-and-effect relations keep you awake at night? Get a Harmony Decision Tables licence today!