This article demonstrates a pattern to avoid brittle if-then statements. Instead of very long conditional branches, one encapsulates evaluation logic in a table of data. Each data item is a function containing an arbitrary piece of logic — code which runs after being passed to the main algorithm. To add new rules you add a new item to the table — no code changes to your core algorithm. The algorithm delegates decision-making to functions outside of its own scope.
myfunction is verbs — a set of instructions. myfunction() is a noun — the outcome of those instructions. Both can be passed around equivalently.
The simple syntax really helped me make this breakthrough. C#’s delegate syntax — which is logically equivalent to the above, but more strongly typed — left me confused.
Professionally, I grew up on static typing — unambiguous definitions and compile-time checking. And for my core business logic, I still insist on it. (Silent-but-deadly errors are very frightening.)
In the case of delegation, however, the syntax required by strong typing was a hindrance to learning. Interesting trade-off.