4 ms·
Quite the opposite, I hate it when projects have dozens upon dozens of modules with 1 function. Multiple huge files are the best sweet spot. (Only crazy adn exc
by gnulinux 4y ago
Quite the opposite, I hate it when projects have dozens upon dozens of modules with 1 function. Multiple huge files are the best sweet spot. (Only crazy adn exceptional things like putting everything into a single file damages the readability imho)
- osigurdson 4y ago300 to 1000 lines per file is best IMO.
- wahern 4y agoIMO, paintings with the color blue are the best. What does number of lines have to do with anything?
- rgoulter 4y agoAt each extreme: A source code file with very few lines will mean more cognitive load is required to remember which file (or package) some functionality is, and likely more effort to maintain the code. Whereas, source code files which are very large mean more cognitive effort to remember where in the file some function is. In many languages, variables can be local to a file, which means use of such variables is riskier, etc. It may be desirable to combine smaller files into a more coherent whole, or to split up an overly complicated large file into several smaller files. Sure, without seeing code, I don't think you can come up with a concrete rule which exists in all cases. Rules of thumb can still be useful as an indication of maintenance effort.
- colordrops 4y agoFiles with one function vs files with 5000 lines are not the only two options.
- fjfbsufhdvfy 4y agoI've got it! We could use files with one function that spans 5000 lines.
- colordrops 4y agoHow about a function that spans 5000 files
- pcthrowaway 4y agoWhy even use 5000 lines when you you can often combine them all into one line.
- pmontra 4y agoThat's the job of the compiler, then we can use a disassembler to read the actual optimized source code.