3 ms·
> If you treat 7 +/- 2 as the size of your brain's L1 cache, then what you see in front of you is an L2 cache. Constantly swapping things between L1 and L2 is
by esperent 6y ago
> If you treat 7 +/- 2 as the size of your brain's L1 cache, then what you see in front of you is an L2 cache. Constantly swapping things between L1 and L2 is expensive, but nowhere near as expensive as between L1 and RAM (all the other files in your project you aren't looking at this very second).
As soon as file grows beyond a hundred lines or so, most of it is off-screen so it's not that different to putting it into another file (it's no longer in L2 cache to use your analogy).
It's a choice between jumping around in a single big file, or jumping around between several smaller files organized in a folder tree structure. I have the folder tree open to the side of the editor while I work on the current document so that's also in my L2 vision cache.
Personally I prefer that to one big file that I have to keep scrolling/jumping around in. Of course, for a large file I can open an outline view instead to help me jump around in the file. But I prefer files that are short enough so I don't need that.
- TeMPOraL 6y agoA file growing too big is indeed a problem, but it's partially mitigated by the fact that things in a single file are all directly related to each other (if they aren't, it's refactoring time). An outline view or even code folding also helps. On top of that, I can scroll within a single file quickly using single keystroke. Still, if you can keep a tree of all your source files entirely visible on screen, then your codebase is rather small. The kind of codebases I'm talking about, the tree doesn't fit. You have to actively search it to find the files you need. And each time someone decides a class isn't "small" anymore, the tree gains 2 or more extra files.