Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternatives to Conditionals

I was reflecting on Rich Hickey's talk, Simple Made Easy, when I got to the "What's in your Toolkit?" slide. There is a list of contrasts between complexity and simplicity, this one piqued my interest:

Complexity: Conditionals, Simplicity: Rules

Does anyone have any insight into what sorts of things Rich was proposing here?

like image 669
Chris Avatar asked Apr 20 '12 14:04

Chris


People also ask

Can we use if without conditionals?

We can also make conditional clauses without if. Study the examples given below. If I had known his real motive, I wouldn't have supported him.

What is another word you can use instead of if in zero conditional?

In zero conditional sentences, you can replace "if" with "when", because both express general truths. The meaning will be unchanged.


1 Answers

I guess he is reffering on Conditionals as boolean expressions in programming languages. If you have many conditional Statements like loops and switches it will get complex very fast. The simpler way is to define Rules. Rules are in a more natural language, you can handle them in a more abstract way to describe your conditions.

Look at the Windows access Management where you can assign rules to users about the rights they have. Like changing the desktop wallpaper. The rules are easy to understand and it's an simple boolean decisions if an rule is applied or not. But if your extract all the conditionals behind the rules it will get very complex. Because you have to care about each and every thing that could affect the wallpaper in this case.

In the end both are methods to describe a Condition, but the one is simpler that the other.

like image 155
Tarion Avatar answered Sep 21 '22 02:09

Tarion