Lily, Klaus, taxes, and bugs

America's golden age

In 2020, Cameron Esposito wins the US presidential election, sweeping to victory on a platform of side mullets and jean jackets. President Esposito and First Human Rhea Butcher raise the country to new standards of peace, dignity, and prosperity.

Among President Esposito's many achievements is a complete overhaul of the tax system. If you pretend to have extra income to impress people, that's taxable now. The economic boost you get from being attractive, that's taxable. Lying to your mother can earn you a tax penalty. Feeling guilty about something you didn't do is recognized as a legitimate life expense.

Confused tax prep company I&S Pyramid creates an Excel workbook to help people with form 1041.6.llama, the new individual income tax return. Unfortunately, grumpy I&S programmer Ronald Dump is so angered by America's new golden age that he does a lousy job.

Lily and Klaus agree to clean up Dump's mess. Let's watch them test and debug the program.

We need to start with the new tax code. This is the thing that Lily and Klaus are trying to match.

The rerevised tax code

The new system is different. Tax deductions have been replaced with tax credits, and… well, here's a picture of the worksheet, and the new rules.

The Code, So Pay Attention

Wages: 80% of the first $50,000 is taxable, 100% of the rest is taxable.

Investment income: 100% is taxable.

Imaginary extra income (the difference between your real income and what you tell your cousins at the family reunion): 40% of the first $100,000 plus 70% of the rest is taxable.

Beauty benefit (the economic edge attractive people have): 150% is taxable, because the rest of us are jealous.

$1,000 tax credit for each human dependent, up to four. No credit for additional dependents.

$1,300 tax credit if you have one dog, $3,000 if you have two, with no credit for additional dogs.

$50 tax credit for the first cat, with no additional credit for more cats.

50% credit for educational expenses.

10% credit for jean jacket expenses.

40% credit for charitable donations. Unless you told your mother that you donated more than you did, in which case there is no credit.

Line 32 will indicate whether you owe us, or we owe you.

Taxable income is taxed according to the following table:

Taxable income

Rate

Under 20,000

0%

20,000 to 50,000

18%

50,001 to 100,000

22%

Above 100,000

28%

Lily and Klaus

Lily and Klaus get Dump's workbook, and a copy of the tax code. The program is about 140 lines, several times longer than anything we've seen so far in this course. Their job is to test the workbook, and fix any bugs.

For now, we'll assume that users don't make mistakes when they type in data. This is unrealistic, of course. We'll add input validation later.

Wages: 80% of the first $50,000 is taxable, 100% of the rest is taxable.

Vould be easy for programming mistake ven income is exactly 50 000.

They now have a testing strategy that makes sense for this program. There's a lot of data, but each piece of data is handled by a simple rule. (That's quite common in business programming.) They decide to test rule by rule. Including edge cases is a Good Thing. Klaus is right: it's easy to make programming mistakes when dealing with edge cases.

Summary

Lily and Klaus looked at the code they were working with, and chose a testing and debugging strategy suited to that program. They tested one piece of data at a time. They compared the output that should have shown with what did show. When they found an error, they used breakpoints to track down the cause.