“I have a string of onions, a pouch of salt, and a sack of dried beans,” you think, “so I reckon it’s soup for dinner again. If I had a side of beef, things would be different.” Conditional logic, the bread and butter of programming. Those provisions are your data, and logic is how you deal with them.
1 2 3 4 5 6 7 8
Most times, you hammer out an
if statement and that’s an end on it. But
if statements don’t go away. You ever type some checks like
1 2 3 4 5 6 7 8 9 10 11
You ever type those kinds of checks over and over? They love to worm their way into UI setup code, interrupt straight-line logic, and sometimes they even ooze into your templates. One or two is fine, but then you see a string of else-ifs that gives you the heebie-jeebies, and a deadline is coming, and there’s nothing for it but to add another one. But there’s a torch that will send those checks skittering back to the shadows: the knowledge that logic is data.