Skip to main content
GameDev.net gamedev.net
🔒 Locked

File organization

Started by Russell Jan 27, 2003 at 12:49 AM 3 replies 150+ views
Original Post
Russell
Russell
How do you organize your C/C++ files? I have made it very hard on myself in the past by organizing in the wrong way. I''ve organized by module theme (like player.h, game.h, input.h, etc.) and I''ve done it by programming theme (data.h, defs.h, types.h, etc.) and I''ve tried things like putting all of the code in header files in case I (or the compiler) would like to inline any, and other various ways. Inevitably something doesn''t work right, some file includes another that includes another and the compiler chokes. And then one day you want to inline a function that is in a source file and you have to move a function to a header file and the compiler chokes again because you didn''t organize your files in a nice way. I''m sure most people have experienced this at some point. So how do you do it? And what advantages and disadvantages do you see to doing it your way? Maybe we can share some good practices and all be better organized.
Palidine
Palidine
i find it easiest to go with the each class gets its own .h and .cpp file. try to think about your object hierarchy before you go ahead and start writing your program. write out a dependancy tree so that you can avoid circular dependancies.

-me

[edited by - Palidine on January 27, 2003 4:15:06 PM]
Extrarius
Extrarius
I generally put each major class in its own header/source file, with all the minor classes/structs/constants/etc sharing files with the major one.
aka the module method
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

Topic Locked

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

Sign in to reply to this topic.