n
2

Variables in coding feel like magic spells to me, and not in a good way

Teaching variables with hard examples right away is wrong. It just makes new coders feel lost (like I did). Let's start with what variables really do.
3 comments

Log in to join the discussion

Log In
3 Comments
terrym45
terrym451mo ago
Back in my first coding class, I named a variable 'x' and had no idea what it did for weeks. I kept changing its value randomly, hoping the program would work, like casting spells without a recipe. In my experience, it clicks when you see a variable as just a labeled box holding your data, nothing more. Starting with that box idea before any math examples saved me later on.
8
the_ray
the_ray1mo ago
Maybe the box idea helps some, but it feels like we overthink the teaching part. Plenty of people get the labeled box thing and still write messy code where the variable 'temp' gets used for six different jobs. The real trouble starts with loops or conditionals, not the first hello world example. Seeing a variable change inside a while loop is where the magic spell feeling actually happens, no matter how you start.
6
aaron708
aaron7081mo ago
Loops get messy without that box idea though.
2