I was so excited when folding appeared in IDEA,
but disappointed when I discovered that it works
only for whole methods, javadoc and imports.
Folding helps a great deal in large, complex methods.
Just select some lines and press Ctrl+ to hide them.
For example, I'd like to hide
- some 100 lines between the loop's head and tail
- everything but the lines that control the flow of
execution (loops, if/else, and some computations)
- everything but the lines that deal with some subset
of methods, variables etc. (Ctrl-Shift-F7)
Some say well-designed programs have only small methods,
and one could always extract smaller methods.
But some algorithms are less coherent and understandable
when scattered across many distinct entry points whose
mutual usage is not instantly visible.
Others are hot spots and perform much better without
leaving one method scope, even in the latest hotspot vm.