Hacker News new | ask | show | jobs
by jfarmer 2403 days ago
I'd say the author is helping students develop their capacity for abductive reasoning (https://en.wikipedia.org/wiki/Abductive_reasoning). The goal is to get students to build accurate models for what the computer/code is doing, not just form rules that happen to match what they've observed.

For example, here's a 100% true story. I once showed a student code like this (in Ruby)

    my_name = "Jesse"
    my_age = 32

    puts("My name is #{my_name} and I am #{my_age} years old.")
They asked a great question: "Are the names my_age and my_name special? Do we have to use those names?"

I explained that, no, so long as you use the same name everywhere, it will always refer to the same value. The names of the variable aren't special. I changed the code:

    my_giraffe = "Jesse"
    my_waffles = 32

    puts("My name is #{my_giraffe} and I am #{my_waffles} years old.")
I use names like "giraffe" and "waffle" so students still recognize them as nouns but are less likely to bring some prior, inappropriate context into their reasoning.

"Oh, I see!" they said. "You can use any variable names so long as they start with my_."

The fact that they articulated their rule clearly to both themselves and me right at that moment puts them in the like 95th percentile of beginning students. Induction is natural but dangerous for beginners, who are so desperate to make sense of what they see that they'll adopt the first model that accounts for what they see without any consideration of the alternatives.

If they were thinking in terms of _predictions_, though, they'd naturally test their model by removing my_ and seeing what happened.

2 comments

Of course the issue with that code is "why use variables at all?" Why not just say

     puts("My name is Jesse and I am 32 years old.")
The whole thing is clearly an exercise in describing use of variables and (perhaps) string interpolation.

Amusingly, your comment is a fun example of short abductive reasoning just like the student in the other guy's story.

it's interesting that for non-english populations, this part of programming does not really require explanation if the course uses local language words for names, and english vs local language is clearly keywords vs chosen names.