a basic OO concept
e.g. in a first step this allows the separation of data and functionality from a class, a second step could impose another functionality. this is not far away from being called strategy pattern.
c-style; doing and data in same Object:
public void solveProblem( int how ) {
switch (how) {
case QUICKANDDIRTY: doItQuickAndDirty(); break;
case SECURED: doTransactionalProcessed(); break;
}
}
OO approach using delegation (strategy):
public void solveProblem( iHowToBeProcessed processor ) {
processor.doItYourWay( this );
}
iHowToBeProcessed is an Interface; implementations are realizing e.g. quick-and-dirty or secured processings. This allows to introduce additional processings without affecting the
class to be modified on which processing has to be done.
