3 ms·
I think the article probably used a bad example. I think the intent was to pick an example that is easy to understand even for non-programmers - the rules behin
by tunesmith 3y ago
I think the article probably used a bad example. I think the intent was to pick an example that is easy to understand even for non-programmers - the rules behind serving cocktails on flights - rather than imply that this technique is intended for social rules that humans should follow.
If instead imagined to apply toward some of the complicated logic we regularly come across in actual computer programming, it starts to feel more useful. As programmers we've all come across cases of snarly boolean logic that nests multiple levels deep. In those cases, I've found decision trees very useful. I've taken it to the point of literally listing out every combination of conditions, rather than just the ones that seem to apply. Through that you can sometimes discover corner cases that need to be accounted for. Other times, you realize that you can collapse parts of the state so that your end-result conditional logic becomes much simpler. If you've ever had that case where you realized that your third-level internal condition could be moved to the outermost condition, thereby simplifying the code significantly, then that's what the exercise helps with.