I work on an application which, in part, calculates tax bill amounts. A tax bill is comprised of many calculable fields (sheriff fees, clerk fees, penalties, interest, flat rates, etc.) whose mode of calculation is usually static, but may change due to legislation or special bill properties. Whole categories of calculations may also be removed or added over time.
To push the clutter of branching logic away from the client, I wrote a factory for each calculation category that will apply the proper calculation given the bill's information, like so (CalcType is an enum):
var bill = new Bill(){year = 2013};
bill.AdvertisingFee = CalculationFactory.GetFee(CalcType.AdvFee, bill);
That much is simple, but I'm troubled by the way some of my concrete classes will be implemented. Here is the calculation interface:
public interface ITaxCalculation{
decimal Calculate();
}
A typical implementation will have some sort of calculation or data access, but certain years/bill properties yield no advertising fee, like so:
public class FinanceCabinetAdvertisingFee : ITaxCalculation
{
public decimal Calculate()
{
return 0.00M;
}
}
This sort of stub class will be present for many, but not all calculation categories, for various reasons (the calculation didn't exist for the tax year, the state bought the bill, etc.)
My question: Are logic-free classes like this considered a code smell, or just an ugly fact of modeling certain unstable, real-world systems? I like the idea of having these cases firmly documented in a class rather than as the default return value of some control structure, but I'm open to the idea that I'm applying the wrong sort of pattern to this style of problem. Any additional thoughts are welcome.