HN: Push ‘if’ up and ‘for’ down

,

https://matklad.github.io/2023/11/15/push-ifs-up-and-fors-down.html

Note: I rewrote a horrendous scheduler implementation a few months ago. It was an absolute mess of logic branches hidden deep down in small OOP methods. Turned it into a series of function calls in a single ‘main’ while loop using the pattern above (although I didn’t have a snazzy name for it at the time).

Moral of this story: Start with functional. You can switch to OOP later by turning things into methods. Switching back from OOP to functional will probably mean a rewrite because objects will probably have been implemented in a way that doesn’t conform to isolation/SRP/other “clean” code things properly etc.