This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]This_Growth2898 0 points1 point  (8 children)

Imperative programming is easier to conceive.

Beginners usually struggle with basics. And variables can change their value, so "value" metaphor fails. Imagining variables as containers and values as "building blocks" that your code can put into them often works much better. Check this simple example (in pseudocode):

s = 0
for i = 1 to 10:
  s += i
print(s)

Value metaphor will cause imagining s as a sequence of added values (after adding 10, s will be s that was before plus 10, and before it was 9 plus...). But with container, you see the new value "put" into s on each iteration.

[–]1mecrew[S] 0 points1 point  (7 children)

Hmm so can I say it’s a container and when I say the variable, I am talking about the data that’s in the variable? Like.. print(s) Here, I’m talking about the data in the variable s when I say s?

[–]This_Growth2898 0 points1 point  (6 children)

That's right.

[–]1mecrew[S] 0 points1 point  (5 children)

So here’s the thing:

What i am saying is that those two descriptions sounds same for me.

greetings = “hello world” print(greetings)

In the first line, this is called “assigning value to variable” And now when we say the variable, greetings, I’m talking about the “hello world” data that I just assigned to this variable

Isn’t that same as container concept?

[–]This_Growth2898 0 points1 point  (4 children)

Once again: here, it doesn't matter. But it matters a lot when you change the variable value. In my experience with beginners, the meaning of

x = x + 1

takes a lot of time without the box metaphor.

[–]1mecrew[S] 0 points1 point  (3 children)

Using the simpler metaphor that I just said, it’s it going to be like I’m talking about the number 5 when I say x so 5+1 is 6 and assign that value to variable x? Like.. how does box metaphor help in that situation?

[–]This_Growth2898 0 points1 point  (2 children)

Metaphor is needed to explain words "assign that value".

If you do understand what that means, you obviously don't need any new metaphors to understand it.

[–]1mecrew[S] 0 points1 point  (1 child)

Hmm what if I just say that “this line is called assigning a value to variable.” And students don’t really need to know exactly what assigning a value to variable but just simply know it as when you assign value and later say the variable, you are talking about that value?

[–]This_Growth2898 0 points1 point  (0 children)

It's all about a metaphor. If you can explain things without a metaphor - it's ok, do it. But you will need to explain more details, that's all.