Archived

This topic is now archived and is closed to further replies.

asdasd12345

advantages of splitting up programs

Recommended Posts

after looking at some program source code ive noticed that some people have one massive file with all the functions and classes there and some people break it up a lot. for instance they would have a class class stupidclass { public: stupidclass(); int funct1(); }; and then in another file they would have stupidclass::stupidclass() { } int stupidclass::funct1() { } is there any real advantage of breaking them up or is it just as good to keep it as one massive file?

Share this post


Link to post
Share on other sites
If you were to have everything in your header file, and make one simple little change, every other file that included that header file would have to be recompiled. Splitting it up means any changes to the .cpp files will be compiled independently of the other files, and then linked again. Makes compiling life a lot easier!

That''s just one reason.

Share this post


Link to post
Share on other sites
Agreed. When I change one of my files in my engine, it takes just few seconds to compile. If I recompile all the files, it takes about two minutes

Oxyd



---
Unreadable code is code written on a piece of paper, but not the one, in which its programmer is using a space in place you don''''t.

Share this post


Link to post
Share on other sites
The main benefit is compilation speed. Other benefits are mainly organisational, such as making it easier to find things, easier to share code across apps, etc. The organising code files link in my signature may give some other insights.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites