Be assured that you will write model programs and program the tools in
ordinary C#.
This chapter has described the effects of a trivial defect in the code, a mere
typographical error.We also have analysis methods that can detect the deeper errors
that arise during specification or design, as we shall see in the next chapter.
2.13 Exercises
1. (Libraries, applications). Write new server and client programs, Probe and
Sampler, that use our Server and Client classes, respectively. In this protocol,
the server starts first, and waits for a connection from a client. The server
responds by immediately sending back the temperature, then closing the connection.
The client reads the temperature, and exits. The server may wait for
another client to connect, or it may also exit.
2. (Libraries). Consider the choice of the double type for the datum parameter of
Server.Send and the return type of Client.Receive. Did this choice contribute
to the failures (Section 2.9)? What alternatives might have been chosen? Discuss
the implications of library design for unit testing.
3. (Alternatives to unit testing). The defect discussed in this chapterwas not exposed
by the unit tests, but evidence of failures appeared in the application program
output (Section 2.9). Could you write software to detect such failures automatically?
Discuss the advantages and disadvantages of unit testing, compared to
analyzing log files, for detecting defects.
Pages:
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67