I am working on an application that, in particular, calculates the amount of tax charges. A tax account consists of many calculated fields (duties for the sheriff, commission clerks, fines, interest, fixed rates, etc.), the calculation method of which is usually static, but may vary due to legislation or special properties of the account. Entire categories of calculations can also be deleted or added over time.
In order to push away the clutter of the branching logic from the client, I wrote a factory for each costing category that will apply the correct calculation, given the account data, for example (CalcType is an enumeration):
var bill = new Bill(){year = 2013};
bill.AdvertisingFee = CalculationFactory.GetFee(CalcType.AdvFee, bill);
It is very simple, but I am concerned about how some of my specific classes will be implemented. Here is the calculation interface:
public interface ITaxCalculation{
decimal Calculate();
}
A typical implementation will have some kind of calculation or data access, but certain years / properties of the account do not give any advertising fees, for example:
public class FinanceCabinetAdvertisingFee : ITaxCalculation
{
public decimal Calculate()
{
return 0.00M;
}
}
This class of stubs will be present for many, but not all categories of costing, for various reasons (the calculation did not exist for the tax year, the state bought an account, etc.)
: ? , , , , . .