I'm talking about something like layers in photoshop, except they apply directly to the source code. For example, in pseudo-code... inventing what some project might look like - say a computational fluid dynamics program:
[base layer]
cfdTime runTime(0);
fieldVariable U;
fieldVariable p;
U.initialize();
p.initialize();
while (runTime.run())
{
U.solve();
p.solve()
runTime++;
}
[turbulence layer]
turbulenceModel turbulence;
scalar nu(readScalar(turbulence.dictionary("nu"));
while (runTime.run())
{
turbulence.update();
}
[base layer + turbulence layer]
cfdTime runTime(0);
fieldVariable U;
fieldVariable p;
U.initialize();
p.initialize();
turbulenceModel turbulence;
scalar nu(readScalar(turbulence.dictionary("nu"));
while (runTime.run())
{
U.solve();
p.solve()
turbulence.update();
runTime++;
}
You get the idea. Obviously a lot of things would need to be worked out.
I'm all over object-oriented programming (OOP). This idea strikes me as an awkward alternative to OOP... and I don't think it's worth much... but I thought I'd toss it to the community... there just might be something useful in it that I'm not quite seeing.
It may be useful from a GUI-only perspective - creating layers in the GUI for complex functional programming... while the underlying code is always the same. Or it may be useful for code optimisation, perhaps an alternative to #ifdef that developers won't run screaming from. Or, it may be an entire alternative to OOP.
Your thoughts?
