Archived

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

pointguard1

Programming Style and Proper Structure

Recommended Posts

Is it OK(proper coding technique) to have 1 .cpp file in my project that contains all the main routines and main functions like Init(), DrawScreen() and Shutdown() and put everything else like class defs and DX wrappers in my header files?

Share this post


Link to post
Share on other sites
No. Each .cpp file is a module. If your project grows to even a modest size, you''ll doubtless have parts of code that change where other parts are the same. If those parts are separated into different modules, you''ll only need to recompile modules that have changed and re-link. If you only have one .cpp file with all the code in headers, the entire program must be recompiled for every change.

I find you can''t go wrong with following a two-file-per-module scheme: each .cpp file has code for the module (however you want to define the parts of your program), and a single associated .h file that _only_ includes information that other modules need about that module.

Share this post


Link to post
Share on other sites