12,898,569 members (57,228 online)

#### Stats

75.9K views
117 bookmarked
Posted 20 Nov 2006

# 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_Three { /// /// USA Investor Business Rule Domain object specific to states. /// internal class UsaIncomeTaxEngine : IncomeTaxEngine { #region Methods /// /// Calculates the tax rate. /// /// The investor. /// /// Returns a double representing the tax liability for the investor. /// public override double CalculateTaxRate(double income) { if (income >= 0.0 && income <= 7550.99) return 0.10; else if (income >= 7551.00 && income <= 30650.99) return 0.15; else if (income >= 30651.00 && income <= 74200.99) return 0.25; else if (income >= 74201.00 && income <= 154800.99) return 0.28; else if (income >= 154801.00 && income <= 336550.99) return 0.33; else return 0.35; } /// /// Calculates the tax liability. /// /// The investor. /// /// Returns a double representing the tax rate for the investor. /// public override double CalculateTaxLiability(double income) { double taxLiability = 0.0; if (income > 7550.99) { taxLiability += 7550.99 * 0.10; } if (income >= 0.0 && income <= 7550.99) { taxLiability += income * 0.10; } if (income > 30650.99) { taxLiability += (30650.99 - 7551.00) * 0.15; } if (income >= 7551.00 && income <= 30650.99) { taxLiability += (income - 7551.00) * 0.15; } if (income > 74200.99) { taxLiability += (74200.99 - 30651.00) * 0.25; } if (income >= 30651.00 && income <= 74200.99) { taxLiability += (income - 30651.00) * 0.25; } if (income > 154800.99) { taxLiability += (154800.99 - 74201.00) * 0.28; } if (income >= 74201.00 && income <= 154800.99) { taxLiability += (income - 74201.00) * 0.28; } if (income > 336550.99) { taxLiability += (336550.99 - 154801.00) * 0.33; } if (income >= 154801.00 && income <= 336550.99) { taxLiability += (income - 154801.00) * 0.33; } if (income > 336551.00) { taxLiability += (income - 336551.00) * 0.35; } 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.