You do understand that there are other possibilities than the two
extremes?
It *is* possible to group small, very closely related classes in a
logical way into files.
yeah, and also everyone seems to think I am advocating huge files or
something (rather than advocating instead trying to keep file sizes
within a certain range of "ideals").
I have looked around some, and thus far have not found any projects
which strictly adhere to 1-class-per-file.
LLVM mostly does, but has a few exception cases (several small classes
lumped together), but they are rare.
Mozilla sort of does, where (in C++ portions) it follows this rule for
the majority, but also violates it a fair amount as well (seems to
depend a lot on where in Mozilla one is looking, I have observed some
amount of inconsistency).
Doom3 rarely does, much more often lumping things together, but one
still does find it being followed on occasion. this seems to also vary
with region, being more typical in "game" (server-side monster/NPC
behaviors, weapons handling, physics, ...) than in the renderer (the
Doom3 renderer generally follows a more C-like style), for example.
my code does it less so still (of what little C++ code there is), but I
don't really usually bother, being mostly a C programmer (C code is the
majority of the code, at this point mostly due to technical
reasons/concerns, mostly with some of my tools being not entirely
friendly to C++).
it is also my tradition to put nearly all headers into separate
"include" directories, which again alters things (since the source code
and headers end up being in different locations).
in terms of lines-of-code, it seems to be more of a 20% header/source
relation. I have observed that many other codebases tend to have closer
to a 10% header/code relation, but I tend towards more numerous and
smaller functions (meaning more space is needed by headers for
prototypes and similar).
typically, also, headers are "per-library", so one includes the header
for the library to get everything in the library. typically, the library
contents will be spread over any number of individual header files
internally. sometimes there is also a split between "internal" and
"public" header contents (internal contents are only visible within the
library, whereas public contents are visible to other code which uses
the header).
so, yes, maybe different traditions and different styles.
typically project organization:
project_root:
subprojects*
libraries*
misc*
Makefiles
shared "include", headers shared between libs
shared "docs", documentation related to project
built binaries
subproject:
basically the same layout as project_root.
library (typical):
source-directories:
"base", default source directory
others, may exist per component.
"include", all headers go here.
"docs", library-specific documentation goes here.
Makefiles