is this a design pattern?
- by Michel
Hi all,
i have to build some financial data report, and for making the calculation, there are a lot of 'if then' situations: if it's a large client, subtract 10%, if it's postal code equals '10101', add 10%, if the day is on a saturday, make a difficult calculation etc.
so i once read about this kind of example, and what they did was (hope i remember well) create a class with some base info and make it possible to add all kinds of calculationobjects to it.
So to put what i remembered in pseudo code
Basecalc bc = new baseCalc();
//put the info in the bc so other objects can do their if
bc.Add(new Largecustomercalc());
bc.Add(new PostalcodeCalc());
bc.add(new WeekdayCalc());
the the bc would run the Calc() methods of all of the added Calc objects.
As i type this i think all the Calc objects must be able to see the Basecalc properties to correctly perform their calculation logic.
So all the if's are in the different Calc objects and not ALL in the Basecalc.
does this make sense?
I was wondering if this is some kind of design pattern?