Ask coding questions

← Back to all posts
Folder Structure
JustinWu (7)

So I've decided to try putting all of the files in this project into folders. They all fall into one of these categories (besides .cpp and .h files):
Factory methods
Objects which dynamically allocate and delete the data
Namespaces which contain objects which will be used in the game
Namespaces which contain functions handling movement.

How should I organize them? By categories(all factory methods in one file, all wrappers in another, etc...), or by their function (wrappers, data, and factory constructors for movingObject are put in one folder, etc...).

Coder100 (16915)

Here's how i do it:



MocaCDeveloper (560)

Depends on what each file does. usually the file name tells you what the content within that file will do.

First off, you'd probably want to start with creating a 'src' folder to store all, and any, other file besides the main file.
So, lets say, as you have stated, you create a folder 'Data'(within the src folder), you would then put the corresponding files in it. Such as, 'overworldObjectData.cpp'.

But, lets say you had a folder 'server' and you put the file 'client.cpp' in it, that would make no sense whatsoever.
The file structure is usually this:
The corresponding files that have a relation with the folder name, or at least a comparable contrast with the folder name.

Another words, your folder should hold files(or other folders) that correspond with what the folder name is. Hence, the folder name 'src' will hold all source files of the program, as well as all source folders of the program.