one problem with the example of functions A() B() C() Called in sequence is that they smell of imperative code. A recipe of some kind, of steps performed in sequence. That kind of code, when it occurs, should probably just be performed in a single function. That is - until either A, B or C can be re-used by other code without creating an unnatural abstraction. If the steps as separate functions can be tested separate…
There are several advantages you are disregarding. Functions have names and you get to name the code in a way that shouldn't expire the way comments can. In most languages separate functions create separate scopes. This prevent incidental use of temporaries from one section into another. Having a smaller scope to look at means that refactoring or changes to new business requirements can have a smaller place for side…
Sure that's a benefit, but often times I think the scrolling is a downside that is underrated. The code being right in front of you has huge value.
> In most languages separate functions create separate scopes. This prevent incidental use of temporaries from one section into anothe
Right. Thought I mentioned that. That's why I think local functions are good. Gives the best of both worlds. It's a proper name instead of a comment, and gives the right scope.
> but if it becomes part of the public API
Yes obviously API design is a separate (and MUCH) harder question than refactoring for breaking logic apart I think.