imperative, OO / Java
Representation
Collected by Matthias Hauswirth — Own practice
A large fraction of code consists of expressions. Students already know about expressions from school arithmetic. This notional machine makes the structure of such simple expressions explicit, and provides a way to explain their bottom-up step-by-step evaluation.
PL | NM |
---|---|
expression | tree of nodes linked together |
operator | green node |
operand | hole in a node where a child node can be attached |
subexpression inside expression | subtree connected to a node's hole |
type of subexpression | blue tag above subexpressions's root node |
numerical literal | tree node labeled with the number |
variable | tree node labeled with name of variable of a numeric type |
unary arithmetic operator (+, -) | tree node with operator in front of a hole |
binary arithmetic operator (+, -, *, /, %) | tree node with operator between two holes |
The structure, typing, and evaluation of arithmetic expressions students still know from school.
To reason about the structure and semantics of simple arithmetic expressions.
Small, can be done on paper or with a tool like Expression Tutor.
The following videos and activities come from ExpressionTutor.org, where you can find a much more comprehensive set of resources and tools. Expression Tutor supports many different programming languages, but the material discussed here is specific to Java.
The Crash Course: Expressions in Java provides a learning experience that corresponds to this notional machine sequence.
The following video comes from section Arithmetic of the Crash Course.
Here is an example “Expression Tutor” activity. Can you solve it?
Do you have feedback on this notional machine? Did you find a mistake, or do you have a request for improvement? You can create an Issue on GitHub, where the description is hosted. This way we can see your feedback and address it.
For this, you need a GitHub account. Then follow this link to see the source file of this page. In there, click the ... left of the highlighted line, then pick "Reference in a new issue".