News for hackers. Stuff that matters.
Re:Avoid Indirection in Code by usrusr on Monday June 24, 2019 @05:33AM (#20261788)
In my mind I contrast "keep it simple" with "make it simple". Successful "make it simple" is better than "keep it simple", which in turn is much better than failed "make it simple". Every attempt at "make it simple" is a wager.

Regarding the one-caller method, beloved by followers of maximum method length ideology, scorned by enemies of excessive indirection, I think we lost a very useful tool when the "structured programming" of Pascal, which prominently featured nested functions as an organisation principle disappeared. It got steamrolled by OOP name scoping (which tends to be too big for this use case) from the top while the archaic "if it exists, it is accessible" of C firmly held the lower levels. The current trend of retrofitting functional features is technically getting us back what we lost, but the use of nested functions as a simple organisational tool is still far from idiomatic. E.g. in Java>=8, when you see a lambda assigned inside a method you expect something clever functional to follow, not a simple "I put this block of code in a box to give it a name, but it won't be meaningful outside this method".

Re:Avoid Indirection in Code by JamesBarney on Monday June 24, 2019 @12:08PM (#20264995)
C# has local functions which I've been making a lot of use for this exact purpose.
Re:Avoid Indirection in Code by guitarbill on Monday June 24, 2019 @04:46PM (#20268294)
agree, like you said it's probably a teaching thing. in e.g. python, javascript, and others, nested functions are available and first-class citizens. (okay, those languages have other issues)

really, there isn't a substitute for experience, but we can try. and again, the devs who do this mean well, they just don't know better yet. that's still better than apathy

Re:Avoid Indirection in Code by blt on Monday June 24, 2019 @12:31PM (#20265320)
I really like this pattern, but unfortunately some people consider it confusing when the closure capture is not explicit. C++ lambdas are nice in that regard.