Tabs are objectively better than spaces - gomakethings.com

Mac@programming.dev to Programming@programming.dev – 162 points –
Tabs are objectively better than spaces
gomakethings.com
169

You are viewing a single comment

Abstraction.

The solution for all levels of nesting.

Be specific. Which exact part would you abstract away and how?

There a many ways to implement abstractions, but it’s highly dependent on the language in question. You could simply refactor each level of nesting into its own function, with all dependents provided as parameters instead of scoped variables. You could then flatMap to avoid a bunch of nested looping, favoring a linear approach that’s often easier to reason about. You could go all out and refactor all your conditional statements away, in favor of the Either monad. You’d then have a number of functions, each doing one thing (including no nesting), and a main function gluing it all together, linearly. That is a pattern you can always apply; there’s nothing controversial about it, and on a similar note there’s nothing particularly challenging about Gaussian elimination.