CSE 331: Software Design and Implementation, Autumn 2026
Working means meeting the specification, on every run.
Ten weeks to learn software design and implementation.
Our motto:
Your job is to deliver code that you know works.
Zach Tatlock
PLSE: compilers, e-graphs, numerics, fabrication
Helps organize and lead Race Condition Running
Listens to Elder, watches Blondihacks machining
Reads Greg Egan novels, practices mindfulness
James Wilcox
Languages, verification, distributed systems
Likes puzzles, especially: is this code correct?
Running and singing, but not at the same time
Good coffee, small planes; no cars of any size
Our goal is to help you become great computer scientists.
Our TAs make this course run! They:
You'll meet your TAs in section on Tuesday
Learn more about them on the staff page
Your job is to deliver code that you know works.
Your job: can a tool do it for you?
Deliver: to whom?
Know: how?
Works: meaning what?
5public class Sum {
6 public static void main(String[] args) {
7 Scanner in = new Scanner(System.in);
8 System.out.println("Enter some numbers.");
9 List<Integer> list = new ArrayList<>();
10 while (in.hasNextInt()) {
11 list.add(in.nextInt());
12 }
13 // (1)
14 System.out.println("Got " + list);
15 int sum = 0;
16 for (int i = 0; i < list.size(); i++) {
17 sum += list.get(i);
18 }
19 // (2)
20 System.out.println("The sum of your list was: " + sum);
21 }
22}$ javac Sum.java $ java Sum Enter some numbers. 3 4 5 Got [3, 4, 5] The sum of your list was: 12
End the input with Control-D; on Windows, Control-Z, then Enter.
Enter some numbers. 1 2 three 4 Got [1, 2] The sum of your list was: 3
Wrong about this run, or silent?
Enter some numbers. Got [] The sum of your list was: 0
Type nothing; end the input at once.
The sentence is true of this run, if an empty list has a sum.
Enter some numbers. 2147483647 1 Got [2147483647, 1] The sum of your list was: -2147483648
A Java int holds only \(-2^{31}\) to \(2^{31} - 1\),
that is, -2147483648 to 2147483647.
The sentence promised the sum.
3 4 5 is one, 1 2 3 another, nothing at all a third1 2 three 4: reads 1 and 2, ignores the rest
Nothing typed: Got [] and a sum of 0
2147483647 1: the sum wraps to -2147483648
2147483648 alone: too big for an int, so nothing is read
One run where it is false refutes it
It never mentions list, sum, or line 15
The code meets it or fails it
10while (in.hasNextInt()) {
11 list.add(in.nextInt());
12}
13// (1)
{{ ? }}
14System.out.println("Got " + list);
15int sum = 0;
16for (int i = 0; i < list.size(); i++) {
17 sum += list.get(i);
18}
19// (2)
{{ ? }}
20System.out.println("The sum of your list was: " + sum);Half sheet, question 2: one claim at each point, true on every run.
assert, a print, or a test10while (in.hasNextInt()) {
11 list.add(in.nextInt());
12}
13// (1)
{{ list holds, in order, every number the user typed before
the input ended or something that was not an int appeared }}
14System.out.println("Got " + list);
15int sum = 0;
16for (int i = 0; i < list.size(); i++) {
17 sum += list.get(i);
18}
19// (2)
{{ sum is the sum of the elements of list, wrapped into the
int range if the true sum falls outside it }}
{{ list still holds, in order, every number the user typed
before the input ended or something that was not an int
appeared }}
20System.out.println("The sum of your list was: " + sum);{{ P }}
some code
{{ Q }}P holdsP state to a Q stateQ holdsP: whatever came before is summarized by PIf line 10 used hasNext instead of hasNextInt:
Enter some numbers. 3 4 hello Exception in thread "main" java.util.InputMismatchException at java.base/java.util.Scanner.throwFor(Scanner.java:977) at java.base/java.util.Scanner.next(Scanner.java:1632) at java.base/java.util.Scanner.nextInt(Scanner.java:2297) at java.base/java.util.Scanner.nextInt(Scanner.java:2251) at Sum.main(Sum.java:11)
A message meant for someone else
3 4 5, a word, nothing, the top of the rangeYour job is to deliver code that you know works.
Your job: not the compiler's, a teammate's, or a tool's
Deliver: to people who type things you did not imagine
Know: reasons, from tests, from tools, and from arguments
Works: meets its specification, on every run
Sum, split into methods