Please see the code below:
public class TaxBands
{
decimal Limit;
int Percentage;
public TaxBands(decimal limit, int percentage)
{
Limit = limit;
Percentage = percentage;
}
public TaxBands()
{
}
public IEnumerable<TaxBands> TaxBandBySalary(decimal salary)
{
if (salary > 11000)
{
yield return new TaxBands(11000, 0);
if (salary > 45000)
{
yield return new TaxBands(45000, 20);
if (salary > 45000)
{
yield return new TaxBands(45000, 40);
if (salary > 150000)
yield return new TaxBands(150000, 45);
}
}
}
}
Notice that the IEnumerable yields instances of the same class (TaxBand). Is this bad practice from an Domain Driven Development point of view? It works well, but I have never seen anything like this before.
Aucun commentaire:
Enregistrer un commentaire