12,451,896 members (70,192 online)

74.3K views
116 bookmarked
Posted

# Who cares about Domain Rules?

, 20 Nov 2006 MIT
With this article, I am evolving a domain problem towards the best possible solution.
 BusinessRules 0 - Procedural_Way 0 - Procedural_Way.smp ProceduralWay.cd Tests 1 - Evolution One 1 - Evolution One.smp EvolutionOne.cd Tests 2 - Evolution Two 2 - Evolution Two.smp EvolutionTwo.cd Tests 3 - Evolution Three 3 - Evolution Three.smp EvolutionThree.cd IncomeTaxEngine.cd Tests 4 - Evolution Four 4 - Evolution Four.smp EvolutionFour.cd Tests 5 - Evolution Five 5 - Evolution Five.smp EvolutionFive.cd TaxBandGenerator.cd Tests bin Debug BusinessRules.dll BusinessRules.dll.lastcodeanalysissucceeded NMock2.dll BusinessRules.csproj.user obj Debug BusinessRules.dll TempPE Properties Tools NMock2.dll nunit.framework.dll ```namespace BusinessRules.Evolution_Four { /// /// New Zealand Tax Engine Domain object specific to New Zealand tax rules. /// internal class NewZealandIncomeTaxEngine : IncomeTaxEngine { #region Methods /// /// Calculates the tax rate. /// /// /// Returns a double representing the tax liability for the investor. /// public override Calculation CalculateTaxRate() { return delegate(Investor investor) { double income = investor.Income; if (income >= 0.0 && income <= 19500.99) return 0.195; else if (income >= 19501.00 && income <= 60000.99) return 0.33; else return 0.39; }; } /// /// Calculates the tax liability. /// /// /// Returns a double representing the tax rate for the investor. /// public override Calculation CalculateTaxLiability() { return delegate(Investor investor) { double taxLiability = 0.0; double income = investor.Income; if (income > 19500.99) { taxLiability += 19500.99 * 0.195; } if (income <= 19500.99) { taxLiability += income * 0.195; } if (income > 60000.99) { taxLiability += (60000.99 - 19501.00) * 0.33; } if (income >= 19501.00 && income <= 60000.99) { taxLiability += (income - 19501.00) * 0.33; } if (income > 60000.99) { taxLiability += (income - 60000.99) * 0.39; } return taxLiability; }; } #endregion } }```

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.