4 ms·
I'll never understand why people want code folding.
by clircle 5y ago
I'll never understand why people want code folding.
- memling 5y ago> I'll never understand why people want code folding. Sometimes cognitive load is correlated with visual load. Perhaps most people don't suffer from this problem? But I do. Other times code works as an outline, and folding branches (for example) is useful to visualize the logical outline without immersing in implementation details. Occasionally I need a refresher on a bit of code, not something super in depth, and folding is good for giving me a mental prompt. Folding allows me to keep context in an API (if it's logically laid out in the file) for reference without having additional clutter in my editor. (This is a personal thing that's also probably not terribly applicable for many people who might prefer a collapsible tree in their IDE.) If I'm stuck in configuration file hell, especially XML ones (here's looking at you finicky Eclipse stuff I've had to deal with in the recent past), having folding is super helpful for skipping past completely irrelevant content. I mean, I could go on, but I've found it useful.
- kjeetgill 5y agoI don't use it most of the time, but it's really useful in Intellij+Java (but also reasonably decent for vim with go or C). When you fold everything, you get a nice overview of all functions that you can jump to. Great for warming up on unfamiliar code when you want to know, what's exists, not just where something specific is.
- ayushnix 5y agoMust be fun working without code folding on a file with thousands of lines of code and dozens of functions. Also, the act of dismissing a feature as useless that you don't personally use is apparently one of the hallmarks of FOSS community.
- e12e 5y agoI mostly feel the need for (but rarely actually use) code folding in legacy projects with long functions/methods and long files - it can be helpful getting fixes in, when there's no tine/resources for a proper refactor. Ed: but I mostly prefer clean code, short functions and concise files...
- ayushnix 5y agoEven in cases when there are just 500 or 1k LOC with about 4-6 functions, code folding is immensely helpful in focusing on where you want and removing other distractions. Navigating between functions also becomes easier. I guess it's pointless to talk about this because the utility of code folding is subjective for some people and in my anecdotal experience so far, any feature that doesn't work in their favorite $EDITOR is branded as useless.
- jussij 5y agoFolding is great when you want to hide some code you are not interested in, letting you then focus on the section that is of interested. You just fold the uninteresting code away. Folding is also great for cutting or copying large blocks of code. For example image a block of code spanning several pages. It can be difficult to know where that block starts and ends, making it hard to mark the region for that cut/copy action. But with folding it is easy to condense the block into a single line and then copy the entire block by just copying the single folded line.