Arrays, the first of today's topics, came to Java from C and C++. It turns out rather than using arrays themselves, most needs for an array in Java are satisfied by using a class called
ArrayList, which is an expansion on the array we learned today. We will be studying
ArrayList as the basis for implementation of the various "collection classes" that we'll soon encounter.
Properties of good organization that you've learned in earlier program activity apply to JUnit as well. Here are some examples:
- test small cases before larger ones and simple before difficult cases;
- if you can, test all possible values;
- test boundary values;
- include tests that will fail as well as tests that will pass;
- use helper methods to make your code more understandable.
We think test-driven development is a big win, and we will be encouraging you to use it when building your programs. At the very least, you have to like the frequent green bars!
For programming homework, as noted earlier, you are to complete the following:
- a thorough JUnit test suite for the
Measurement class; and
- the code for the
Submit the Java files
MeasurementTest.java in the directory
For next lab, check out the reading assignment:
If you're not feeling rock solid on the stuff we've done so far, check out CodingBat
to get some extra practice writing Java programs.