I really have a doubt in existence, and as I go on it makes me more noisy and I really do not know if I'm doing things right. I have my own software, which I developed a few months ago ... it goes quite well in its purpose, but it turns out that I have asked for another one that has the functionality of the previous one but adds additional functionalities ... I mean, the first is based on the second. What happened to me, is about the font game, defining a constant at the project level and adding preprocessor sentences ... in principle it occurred to me that it was the best ... that way I would only change in key places only when I need new classes of the new functionality ... BUT as I go forward I see that it gets complicated and the code becomes in-maintainable. I show parts so they can see what's happening to me.
#include "enginegraph.h"
#include "trackfarmgraph.h"
#ifdef __CORTE_SECCION__
#include "multiworkerdpathgraph.h"
#else
#include "workedpathgraph.h"
#endif
#include "pointsfarmgraph.h"
.... in other parts of the project ...
pointsGraph = NULL;
#ifndef __CORTE_SECCION__
worker = NULL;
#else
multiWorker = NULL;
#endif
engine = NULL;
dlg = NULL;
.... in other parts of the project ...
#ifndef __CORTE_SECCION__
if (worker)
{
disconnect(worker);
delete worker;
worker = NULL;
}
#else
if (multiWorker)
{
disconnect(multiWorker);
delete multiWorker;
multiWorker = NULL;
}
#endif
if (track)
{
disconnect(track);
delete track;
track = NULL;
}
With this I am noticing that the code becomes illegible and with time it will be more. The advantage I find is that if there are bugs in the common part, they are corrected and both software are OK ... but the cost of illegibility and maintenance I think grows exponentially. How else can this be done? THANK YOU