HACKER Q&A
📣 tosh

What is a good analogy for a variable


When teaching programming analogies can help (familiarity) to convey concepts. At the same time some analogies work better than others. What are your thoughts on this?


  👤 karmakaze Accepted Answer ✓
A variable is first and perhaps foremost a name by which a value is accessed.

In some/most languages a different value can be associated with the name, and/or the value-thing can be changed/mutated.

Not an analogy, but a good start. Then have to describe different kinds of values and maybe references. Easier to do in parts than all at once as a 'variable'.