Source

Branch

1/ @ndwork

@rfleury

A function explicitly limits the variables that its code depends on.

For many functions, they can be independently tested. When possible, that also seems useful. If there’s a bug, it’s highly likely not to be inside the function.

These things make functions extremely useful.

2/ @rfleury

No. By adding entry points which are independently tested (e.g. in a vacuum, removed from context), you are combinatorially increasing the number of possible test cases. It’s vastly easier to exercise one single codepath than several thousands.

Second of all, sub-scopes also allow limiting exposed variables to other scopes. If a scope fairly far into a function depends on the entire set of exposed variables that came before, functions do not stop that, because you’d simply need to pass them all. There is way less boilerplate and way less complexity in the single codepath version.

3/ @ndwork

@rfleury

I’m taking the fact that you didn’t tell me to delete my account as a huge mark of success. :)

All the best Ryan.