imperative / Python
Representation
Collected by Andreas Mühling — Own practice
Expandable 'offline' model of program execution. In its ultimate stage (V4) it covers everything of V1, V2 and V3 plus classes, objects and methods.
PL | NM |
---|---|
... | ... |
method | entry in the table of sub-routines |
object | entry in object table with address and value(s) |
Methods and classes.
Introducing object orientation (in an objects later way).
Time consuming to prepare. Easy to follow for learners, as it grows in complexity. Can be used for exercises (fill out sheets of the computer).
The idea is to offer an "offline" (in the sense of not automated) visualization of program execution. The necessary model of the computer executing the program gets increasingly more complex, as more programming constructs are introduced. Similar ways of stepping through code can be found in the typical visualization (or debugging) tools and this connection between "offline" and "online" is intentional.
In its basic form, the executor can "run" a script sequentially and jump in the script based on the evaluation of a conditional. Variables of "primitive" types (i.e. str, int, float, bool) are stored in a memory table that consists of identifier and current value. A template for all stages can be found here An example for the execution of a simple script in German can be found here ("Speicher" = "Memory", Bezeichner = Identifier, Wert = Value, Bedingung = Condition, Nächste Zeile = Next Line).
It also shows the big drawback of having it as slides only: It becomes cumbersome for more than very simple scripts to create and once finished, modifications to a program are time consuming. The advantage is that, once introduced, it is not necessary to always step through a program from the beginning, a slide can also jump right into the middle of an execution to highlight interesting phenomena. As it is manual and on slides, it is also easy to add boxes or other elements to guide students' attention to some aspect. Also, the template can be used in exercises and assessments and students can fill in various aspects of the NM (e.g. the memory after a program has been run).
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".