As a vendor, we need to ship applications to many clients, and sometimes we need to customize the application for a specific client, for example by enabling or disabling certain features, or setting appropriate defaults for that client.
I've seen that in some open-source projects this is done with this pattern:
#define ENABLE_FEATURE_XYZ 0
#if ENABLE_FEATURE_XYZ
void featureXyzImpl()
{
...
}
#endif
void main()
{
#if ENABLE_FEATURE_XYZ
featureXyzImpl();
#endif
}
Here you turn the feature on or off by defining ENABLE_FEATURE_XYZ to 0 or 1. The benefit is that code that is not needed is not there.
But some colleagues believe that in the real-world, you need to perform customization at run-time by looking at config-file or registry settings, using this pattern instead:
void featureXyzImpl()
{
...
}
void main()
{
if (configFileValue("Enable Feature XYZ") == true) {
featureXyzImpl();
}
}
Their reasoning is that it makes it easier to maintain and test the software, because you don't need recompile to enable or disable a feature, you don't need to keep multiple versions of a library or an executable, and you can send only one version to the testers, who can then enable or disable features at run-time.
Is there a guide, or methodology for deciding which one of those methods is better for a given situation? Or should we just choose between them with a coin toss, or out of personal preference?