> if you need more than 3 levels of indentation, you’re screwed anyway, and should fix your program.
I hope some JS programmers read this
I hope some JS programmers read this
The kernel guideline doesn't mention this due to being C specific. C++ can exhibit similar issues.
Anonymous callback:
Foo.foo(() -> bar());
Named callback: private final class MyFooDelegate implements FooDelegate {
@Override
public void doFoo() {
bar();
}
}
...
Foo.foo(new MyFooDelegate())It was good advice.
There's reasons to keep the block inline too--like if you're working in a more resource constrained environment, or if the block isn't really isolated/self-contained enough to cleanly abstract away, or if the block in question isn't really doing anything substantial. But I wouldn't say that you should only abstract away code into functions to save yourself from literally copy/pasting the lines in multiple places.