New answers tagged

0

A lot of it just comes down to: You want to be able to easily navigate to different logical parts of your program, and view those parts side-by-side it's easier to create an IDE/programming environment that deals with those separate parts as separate files than it is to create an IDE that keeps all the code for a program in one big file, and has to show ...


0

In my experience, if the database is only connected via a single application such as a micro service api or monolithic app with one db, it does make sense to have code and db changes lock-step to avoid incomplete deployments. If you have a database in which there is no single "owner" application, separation and manual synchronization makes sense to ensure ...


2

Another significant reason to use multiple files that somehow no one has mentioned: When you work on a software development project with a team, it is very common to use a version control system such as Git. One major hurdle faced by any VCS is merging the work of multiple authors. If you and another developer work on the same file at the same time, your ...


0

Even when we have complex code navigation tools like Jump-to-Definition, organizing your project in a tree of files and folders makes it easier to onboard new developers. It makes it easier to find which file you need to start working on a feature. As for the "faster" concern, most modern compilers support LTO, so even if you use separate compilation units (...


11

I have been told to write large applications in several different files. They say it will run faster. What makes it run faster? Also does a multifile application ACTUALLY run faster than a singlefile one In C, there is no reason to assume that a multi-source-file application will run faster, and several reasons why it might be slightly slower. Use of ...


27

The question falls into same category as why buildings are not build from one piece of rock but a bunch of bricks? Answer: easier to navigate than scroll through one huge file make recompile works only on files related to the change various parts of the program can be programmed by different people code from some files can be put into libraries for ...


-1

While the program will run at the same speed whether it's one file or one thousand the editor is quite another matter. Intelligent editors bog down when the files get large. I find it noticeable on any form with a lot of UI elements in it.


0

In general it depends on the context. In addition to the other answers in javascript, python and other languages I am probably not aware of a file imported is loaded only once. Let us say f.e. we need to import a file with 150000 words , which needs approximately 1 sec to be loaded to a variable(or data structure). And then we want to use this file to find ...


21

The other answers are fine, but something they're missing is actual technical limitations. For example, you can't actually save all of the code for my day-job application in one file - it's bigger than the file size limitations of common file systems. That sort of size also wreaks havoc with editors and compilers and linters since the syntax tree for that ...


69

There are a lot of technical reasons behind using multiple files when writing large complex systems. All of them are meaningless in the face of the best reason to use multiple files: Readability. When I write code that resides in one file I'm presenting what you need to understand to follow how this part of the system works. Every detail not in this file ...


2

Advantages of using multiple files for a program are numerous.For instance: if you write code for a class in a separate file, you can use that class in multiple programs. It increases reusability of the code. Furthermore, if you want to change anything in a class, you will only have to change it in that particularly file and the change will be ...


0

You are doing more than is prudent. Machine learning models are cool and nifty, but without data to actually train them they're of little use to most people (read: 99.999999% of humanity). And without data to train them, it's really hard to tell if this research model is meaningfully better than things that are readily available - super hard if you don't ...


Top 50 recent answers are included