Skip to main content

CSE 331: Welcome! Whole program assertions

In this lecture, we will read a short Java program and ask what it does. The user of a program is interested in its externally visible behavior, which is usually described in a user manual or specification. Programmers working on the internals of a program are also interested in claims about the state of the program (its variables, memory, ...). An assertion is a true/false claim about the state of a program at a particular point in the program. An assertion holds if it is true at that program point on all executions that reach that point. Knowing that code works involves several techniques, including testing, tools (such as typecheckers), and reasoning.