Class 1: Engineering Software?
What are the differences between small, fun programs and large, important programs?
What is engineering?
How is constructing software similar to constructing bridges?
How is constructing software different from constructing bridges?
Is testing software easier or harder than testing bridges? (Why?)
What tools can we use to manage complexity?
Tony Hoare
Class 2: Introducing Java
What is a more important property of a programming language: (a) what it can say; or (b) what it cannot say?
How do different languages you know trade off expressiveness and truthiness? (If Java is the only programming language you know, try to answer this question for English)
High |
|
|
Expressiveness |
|
| x Java
Low |
|______________________________
Low High
Truthiness
What is an object?
How does strict type checking impact the expressiveness and safety of a language?
How do classes help programmers manage complexity?
How do visibility modifiers (like private) help programmers manage complexity?
Class 3: Java Semantics
What are the two possible meanings of an assignment statement (e.g., a = b) in Java?
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)
}
}
Class 4: Specifications
What kinds of documentation do we need to allow modular development?
How does a specification constrain a client?
Our procedural specifications will use three clauses:
- REQUIRES — what the client must satisfy before calling the procedure (the precondition)
- MODIFIES — what state may be modified by the procedure (any state not listed in a modifies clause, may not be modified)
- EFFECTS — what the procedure guarantees will be true after the procedure returns (the postcondition), so long as the client satisfied the precondition in the REQUIRES clause
An implementation of a procedural specification is satisfactory if: if the client satisfies the precondition before the call, the postcondition is always satisfied after the call returns.
requires → (effects & everything that is not listed in modifies is unchanged)
What is the point of having a MODIFIES clause?
What are the advantages and disadvantages of formal (instead of informal) specifications?
If a procedure’s specification has no REQUIRES clause, what is the precondition?
If a procedure’s specification has no MODIFIES clause, what can it modify?
What does it mean when a procedure has no EFFECTS clause?
Then you should say what you mean, the March Hare went on.
I do, Alice hastily replied; at least–at least I mean what I say–that’s the same thing, you know.
Not the same thing a bit! said the Hatter. You might just as well say that "I see what I eat" is the same thing as "I eat what I see"!
You might just as well say, added the March Hare, that "I like what I get" is the same thing as "I get what I like"!
You might just as well say, added the Dormouse, who seemed to be talking in his sleep,
that "I breathe when I sleep" is the same thing as "I sleep when I breathe"!
It IS the same thing with you, said the Hatter, and here the conversation dropped,
and the party sat silent for a minute, while Alice thought over all she could remember about ravens and writing-desks, which wasn’t much.