3 ms·
I worked on Word for years. Office has thousands of files over 10,000 lines with, uh, various degrees of test coverage and comprehensibility. After some time an
by briantkelley 5y ago
I worked on Word for years. Office has thousands of files over 10,000 lines with, uh, various degrees of test coverage and comprehensibility. After some time and experience, your mental model of the architecture ends up being way more important than simple metrics on source code organization.
IMO, organizing source code in files seems archaic. E.g. tracing the history of a function moved across files can be tedious even with the best tools. I’d like to see more discussion around different types of source storage abstraction.
There are benefits of large source files... When compiling hundreds of thousands of files (like Office), the overhead of spawning a compiler process, re-parsing or deserializing headers, and orchestrating the build is non-trivial. Splitting large files into smaller ones could add hours of just overhead to the full build time.
- rc_mob 5y agoI love how much this questions the status quo.
- woah 5y agoWhat's an alternative to files that doesn't just have all the same attributes of files anyway? If it involves breaking code into multiple chunks of related functions, and possibly having these chunks act as namespaces, that sounds like what a file does.
- squeaky-clean 5y agoMaybe it's the editors that need updating. It would be pretty neat to have the chunks of functions / namespaces model as lots of tiny separate files on the disk, but a sort of view-layer so that you can view all the related ones in one virtual file. You could even then have multiple virtual files that include the same raw files. For example in a video game your player, monsters, health potions, and attacks could all have the code for HealthComponent as a part of their virtual file. And updating the HealthComponent would affect the raw file so the virtual files would have the updates automatically. Yeah you can open dozens of editor tabs or always use jump-to-definition, but just being able to scroll around or ctrl+f within a restricted set of limited files would be nice.
- Jtsummers 5y agoLook up "class browser", in particular "smalltalk class browser" to see examples, current and historic, of editors supporting that kind of approach to navigating codebases.
- nukst 5y agoSomething like this https://tibleiz.net/code-browser/ https://tibleiz.net/code-browser/ maybe?
- squeaky-clean 5y agoMaybe I'm looking up the wrong thing but these basically list the classes and method names and hotlink to the code? I mean something that would dump them all into, one contiguous "file" from the editor's perspective. Included components (I don't want to say classes because it could work in a functional language or maybe you just don't include full classes but certain methods) wouldn't have to be coupled to the main class you're editing. Like if you have a decoupled event system you could pull in just the events relevant to the idea you're working on. You could have different views depending on what idea you're working on and save them as their own file. To use the gamedev analogy again you could have MonsterCombat.view MonsterAI.view MonsterAnimations.view which would all expose different subsets of the Monster class and various related methods from other classes/modules.
- jamesfinlayson 5y agoI might be remembering wrong but I thought Visual C++ 6 might have had a class browser as an alternative to a file browser. Maybe modern Visual Studio has it too?
- squeaky-clean 5y agoI don't really mean a class browser but something that completely abstracts the underlying code organization and let's you create a sort of meta-file that includes all the related code for various ideas. Like you could have all of the code from class A except the debug related methods, a few methods from class B, just a few functions from a static MathUtils class, so on. Maybe your ClassAUnitTest meta-file could include some of the ugliest methods from the class you're testing but not the entire class.
- bbkane 5y agoGive https://www.unison-lang.org/learn/tour/ https://www.unison-lang.org/learn/tour/ a read. The Unison language stores code as hashed syntax trees.