10 ms·
Eventually a single file won't scale. Maybe not in the lifetime of your project, but you never know. If a day comes and you have a 500,000+ line file that must
by magpi3 5y ago
Eventually a single file won't scale. Maybe not in the lifetime of your project, but you never know. If a day comes and you have a 500,000+ line file that must be split into separate files, that could be a nightmare. Why not just follow best practices from the beginning and separate your programming logic into different logical/related units?
Similarly having the discipline to separate your programming logic into different files will force you to think about the architecture(or lack thereof) of your program. This is a good thing. The Java "one file for one class" model is overkill IMO, but it does force programmers to discipline themselves by thinking in terms of namespaces/classes when they write code, which for beginners at least is not a terrible thing.
Obviously version control is another reason. Hard to get work done if everyone is working on the same file.
It also will make it easier for someone else to grok your program. When I git clone someone else's large project, I start trying to understand the project by writing down what each folder and file is designed to do before I go any further. I suppose if everything was in one file I would just have to do the same for functions, but what if there were thousands of them? Imagine if a large program like WordPress, Doom, the Linux Kernel etc was a single file?
TLDR: For small one person projects, no big deal. Otherwise, it's just a bad/unscalable practice.