cs205: engineering software? |
(none) 05 April 2010 |
The exam will cover all material in the class up to and including Wednesday's lecture (Class 39), assigned reading, problem sets 1-5, and your projects. It will emphasize material covered since the midterm exam, but may include questions on any course material. You should not be surprised if it has questions about subtyping, concurrency, design, type safety, Java byte codes and verification, and GUI programming. You should also not be surprised to find questions that cover material from the first half of the class also: writing good specifications, reasoning about data abstractions and design.
The exam will also include teammate assessment questions for the project (this replaces the previously mentioned "Teammate Assessment Form").
If your team does an outstanding presentation and demo on Monday, you will not need to submit a formal project report. An outstanding presentation must include a good story of why your project is useful and a demonstration showing the software you built functioning well. You will be notified shortly after class Monday if this is the case.
Otherwise, you need to turn in a paper project report containing:
P { code } QPartial correctness: If P is true before executing code, then Q is true after.
Total correctness: Partial correctness and code is guaranteed to terminate.
P[x / E] { x := E } P
Replace all free oocurances of x with E.What does this rule assume about E and assignments?
Sequencing
P { S } Q, Q { T }
R
Þ
{P } S; T { R }
Conditional Rule
B and P { S }
Q, !B and P { T } Q
Þ
P { if (B) S else T } Q
While Rule
{ Inv and B } S { Inv }
Þ
{ Inv } while (B) S {
!B Ù Inv }
Inv is the "loop invariant". Similar to a rep invariant, a loop invariant is a predicate that is true before entering the loop, and if it is true at the beginning of a loop iteration it is also true at the end of the loop iteration.Code from PS2:What more would we need to show total correctness?
public static int [] histogram (int [] a) { int maxval = 0; for (int i = 0; i < a.length; i++) { if (a[i] > maxval) { maxval = a[i]; } } int histo [] = new int [maxval + 1]; for (int i = 0; i < a.length; i++) { histo[a[i]]++; } return histo; }Simplified first loop:
while (i < a.length) { if (a[i] > maxval) { maxval = a[i]; } i++; }