Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Decision table's are really good at representing complex rules, in a language with pattern matching u can convert a nested if else block to a decision table that is much more readable, as an example see https://github.com/finos/morphir-examples/blob/master/src/Mo...


That’s a _really_ nice example! Might suggest this in code reviews as I come across quite a few complex nested if/elif blocks


You can also use sth like Map<List<Boolean>, Result> in languages with no pattern matching. Sadly map literals aren't pretty in some of these languages, but it's still better than a bunch of nested if-then-elses or switches.


Good point! I don’t see why languages don’t adopt pattern matching (unless the grammar really breaks it for whatever reason)


indeed! really nice.

In the past I have just worked some hairy logic on a spreadsheet and just manually migrate it to code / nested conditionals.

This other article [1] shows some really cool ways to writes decision tables using structured editing UI. I wish structured editors where more commonplace!

1: https://medium.com/@markusvoelter/the-evolution-of-decision-...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: