People will tell you different things. Generally:
- You should split the file into smaller files if:
- It has many dependencies.
- Too much time to compile
- He knows or does too much.
- You must organize your project:
- What parts work with which data types
- What parts work with which other parts of the project
- Things to avoid:
- Headers that only work if they are included in certain orders
- Headings that draw big drops of a project (too many dependencies)
- Preprocessor macro violation
- "util.c" or similar. From personal experience, they tend to get out of hand.
In C ++ (not C), I usually have a .h and .cpp file for each main class that I write, and sometimes I can raise some supporting classes to files with other classes, to which they are very closely related , and without which they are more or less meaningless (anecdotally, I have an average project containing classes such as Scheduler and SchedulerEvent in the same file in which the scheduler contains the SchedulerEvents collection. The project has about 180 files and is still simple to maintenance).
source share