Answer the question
In order to leave comments, you need to log in
Why split the project into a bunch of files and how to learn to understand them?
Hello!
Sometimes I look through the sources on github, and I see BILLION .h and .cpp files.
I'm just confused, I don't understand where the functions come from. Much easier when everything is in one main.cpp.
Explain to me - why do this, and who is already a guru - how did you learn to understand all this? It's not convenient to search for all these features
Answer the question
In order to leave comments, you need to log in
When the project is large, it is simply convenient to decompose separate parts that are little related to each other into different files.
Large projects can have millions of lines of code, it will be a lot even in megabytes. Not every text editor will be able to simply open such a document, and saving will lead to a noticeable delay every time.
In addition, often not only files are laid out, but also separate folders are created, if the parts are not dependent at all.
You do not write the entire project at once, and you do not need 99% of the existing code right now. At the current moment in time, you are working on a specific piece of code and functionality. It is convenient when all the code is at hand. Yes, when the code is divided into files, often working on one functionality, you have to keep several files open, but their number is limited and their size is not large enough.
If you have just started to study a large project, then at the beginning it will be difficult to navigate, but after a few days of studying the code, this will not be a big problem for you. A good IDE also helps in this case.
You can use parts of the project placed in separate files directly in another project as is, without copy-paste and maintaining the same code in different projects, simply by copying the files to another project or including a submodule in the git.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question