• Advertisement
Sign in to follow this  

Source File Naming

This topic is 4587 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is not exactly a programming question. Feel free to move it elsewhere if it doesn't fit. I normally have one *.h file and one *.cpp file with the same name to represent a single module for a class or small set of classes. Such as.. Character_AI.h Character_AI.cpp But I have some classes that have quite a lot of code running under their hood, and the cpp files end up becoming too large to maintain. It's rare, but I have a few of them. In these situations, I end up creating several source files that accompany the single header file. Is this common, or is it a bad sign? My main question is regarding the naming of the *.cpp files to prevent confusion. Is there any particular convention for this situation? This is my first guess.. Character_AI.h Character_AI_Engine.cpp Character_AI_Tasks.cpp The names could end up getting pretty long. In the example, the _Engine.cpp file would hold the main updating routines for AI, where the _Tasks.cpp would include small tasks that AI can use in that main updater. Both of them would contain CharacterAI:: type functions, IE, from the exact same class. For example, CharacterAI::Update() might be in _Engine.cpp where CharacterAI::CheckForCliffs() might be in _Tasks.cpp. This is just an example, but this is the general situation that I'm concerned about. It's not a big deal, but I thought I would ask. Any opinions are welcome. Thanks :)

Share this post


Link to post
Share on other sites
Advertisement
It's just a suggestion but, if your code become too big in a class, isn't possible to split the class in two (or more) classes ?

It depends on the class itself. I personnaly have sometimes two source files for one header file. For exemple, for an OpenGL renderer, I need Windows-specific code and also Linux-specific code (I'm not using glut). So I put all my Linux code in RendererGL_Linux.cpp and all my Windows code in RendererGL_Win32.cpp (the code is related to the creation of the rendering window).

Hope it helps.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement