## Exercises

If you have the energy, try these before moving on to the next section. These exercises focus on test-first programming, meaning that they focus on writing correct behavior and on writing the fewest design elements that solve the problem.

## Ideas for Features

Add more behavior to your fractions library: multiply fractions, then subtract them, then divide them. How will you handle dividing by zero?

Add more items to the mathematics library: arithmetic with complex numbers, arithmetic with polynomial expressions of one variable (such as 2x^3 + 3x^2 + 7x + 9, which you could represent as [9, 7, 3, 2], so that the number at index n is the coefficient of x^n.

Do you find any common behavior to extract from among fractions, complex numbers, and polynomials? Extract it. What name do you give to it?

## Constraints and Guidelines

• Start with a test list! Don't let yourself write the first test until you get your ideas out of your head.
• At every step, look for code that you can delete, then delete it. Did you write the smallest failing test? Did you write the smallest passing code?
• It's OK to have implementation/production design ideas up front, but try hard not to introduce them! Try to take smaller steps so that you don't build what you have in mind until you have no choice. Try harder. You can almost always take a smaller step.
• Commit on every green bar. Write your commit comments carefully. Do not skip this part. If it takes 10 minutes to answer the question, "Why did I make this tiny change?" then that's OK: that's what practice is for.