Skip to main content
gamedev.net
🔒 Locked

Programming Style and Proper Structure

Started by pointguard1 Nov 14, 2001 at 4:30 PM 1 replies 350+ views
Original Post
pointguard1
pointguard1
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?
------------------------------------KaBeeM Web
<><
Stoffel
Stoffel
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.