DinkydauSet / ExploreFractals

A tool for testing the effect of Mandelbrot set Julia morphings
GNU General Public License v3.0
5 stars 1 forks source link

improve compile time by separating declarations and implementations #45

Open DinkydauSet opened 2 years ago

DinkydauSet commented 2 years ago

It's common practice to separate declarations and implementations. I have not done that with my program because I saw no benefits. It's less work to only write an implementation file and include that everywhere it's needed.

Now I do see a benefit. Compilers generally can only compile whole files, so if you change 1 little thing in a file, the whole file needs to be recompiled. Using many small files can improve compiler time after a small change because the unchanged files don't have to be compiled again. Working with separately compiled files requires header files with declarations for other files to use.

Requirement: I want it to be possible to compile the program as a whole too (an amalgamation) because that allows for better optimization. That can be done by including all the cpp-files in an otherwise empty file like this, and compiling that file:

#include "common.cpp"
#include "FractalParameters.cpp"
#include "FractalCanvas.cpp"
#include "Render.cpp"
...

Maybe special care is needed to make that possible.