Comment by zahlman

2 hours ago

> You could break it up into 5 separate functions that document their intent semantically, thus blowing up the LOC by 5x

I do this all the time and the "blowup" is not anywhere near that bad.

> or you could write a short comment explaining the intent in natural language.

You really can't. Or rather, you aren't going to convey the information that the new function signatures convey, shorter than the signatures themselves.

> What's more effective?

In my literal dozens of years of experience, the function refactoring. You also get the benefits of less deeply nested code, and more things the compiler can check automatically.

> I'd argue it's always going to be using all the tools at your disposal when and where it makes sense to use them, whether that is comments or self-documenting code.

Sure. Comments allow you, for example, to explain the external pressures and motivations for the semantics of those smaller functions.