imperative / any
Analogy
Collected by Matthias Hauswirth — Own practice, Benedict DuBoulay
Makes explicit recursive calls as a form to 'delegate' parts of work, base case as a situation where delegation stops. Allows unpacking many aspects of recursive computation (pairing of call/return, passing info down through params, up through return values, tail recursion).
PL | NM |
---|---|
object | person |
method call | verbal request to next person in line |
return value | verbal response from next person in line |
base case | (action of) last person in line |
recursive case | (action of) all but last persons in line |
linked list | line of persons (e.g., waiting in amusement park, or row in classroom) |
Recursive calls and returns, base case & recursive case, tail recursion
When introducing recursion (recursive computation over recursive data structure).
Difficult for instructor to react to students' actions during role-play, and to catch (and exploit) all the teachable moments. May require prior introduction of role-play (e.g., with 'Object as Student').
This notional machine is based on a suggestion by Benedict DuBoulay at EC-TEL 2016.
Matthias Hauswirth used this to introduce recursion in an object-oriented programming course.
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".