2 ms·
I've been thinking about this a lot recently. For most of my career I've been a Java programmer and for the majority of projects, each class is put in its own f
by dmux 5y ago
I've been thinking about this a lot recently. For most of my career I've been a Java programmer and for the majority of projects, each class is put in its own file. The amount of jumping (between files / following method calls) can get really tedious when you're trying to grok a code base. I've been working on Typescript projects recently where the standard has been to have slightly larger files -- possibly containing a class definition, but more often it's an entire module -- and it's actually been kind of nice to just read the entire thing top to bottom in one go. I've looked for studies on "locality" of source code, but haven't really found anything.
- GordonS 5y agoYes, it can be really jarring to have to constantly move between several small files. I mostly use C#, and a while back I settled on a middle ground, where closely-related classes and interfaces are grouped together in a single file. When I'm working on web apps/APIs, I usually follow the "feature folder" concept too, where all the most central parts are together in the same file.