SWE 437 In Class Exercise # 8
Legacy TDD


Instructions: Work with your neighbors in groups.

This is a legacy TDD exercise.

Suppose we wanted to change the way iterators worked in Java collections - particularly in Java lists. That would mean changing the source code for the AbstractList class. Let's assume (incorrectly, one hopes) that there is no test harness for AbstractList.

  1. This exercise would not be a good idea in practice. Why not?

  2. Notice how concurrent modifications are handled inconsistently across the three methods: next(), hasNext(), and remove(). How many of you agree with the inconsistent implementation?

  3. Koskela would require a local test harness before any code was changed. Design an appropriate test for CME in the appropriate method. How should the test for CME behave initially?

  4. What should change first, the test, or the implementation of hasNext()?

  5. How would hasNext() change?