CS201J: Engineering Software, Fall 2002
|
Notes: Tuesday 3 September 2002
Assignments Due
- Now: Problem Set 1, Pledge
- 5 September: Read Liskov, Ch 3
- 10 September: Problem Set 2
For Problem Set 2, you will need to read Chapter 5-5.2, Chapter 6-6.3 and Chapter 10-10.2 and 10.7-10.11.Notes and Questions
How can we increase our confidence that a program works as intended?
For what kinds of programs is exhaustive testing possible?
What is a successful test case?
What is the difference between testing and analysis?
What are the advantages and disadvantages of spending time on analysis instead of testing?
Java Semantics
Excerpts from Java API documentation:
java.lang.String
The
String
class represents character strings. All string literals in Java programs, such as"abc"
, are implemented as instances of this class.Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. For example:
String str = "abc";is equivalent to:
char data[] = {'a', 'b', 'c'}; String str = new String(data);public boolean equals(Object anObject)
Compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.public class Strings { public static void main (String [] args) { String s = new String ("hello"); String t = new String ("hello"); StringBuffer sb = new StringBuffer ("he"); StringBuffer tb = sb; String s1 = "hello"; String t1 = "hello"; sb.append ("llo"); tb.append (" goodbye!"); s.concat (" goodbye!"); t = s.concat (" goodbye!"); // What are the values of s, t, sb and tb now? // Which of these are true: // a) s == t // b) s1 == t1 // c) s == s1 // d) s.equals (t) // e) sb == tb // f) t.equals (tb) } }Testing can establish the presence of errors, but never their abscence.Edsger Dijkstra
Is this always true?
University of Virginia Department of Computer Science CS 201J: Engineering Software |
Sponsored by the National Science Foundation |
cs201j-staff@cs.virginia.edu |