|
Hmmm...the concept of variables/memory locations.
OK.
His best friend's phone number.
"671-1375" isn't his best friend, but it using it will get him his best friend.
Not a perfect analogy, but might get him pointed in the right direction.
|
|
|
|
|
If you want to teach variables, don't use terrible variable names. If you example wouldn't pass a code review it isn't a good teaching example.
Also with abstract concepts relate them to something concrete.
Let PricePerTooth = $0.25
Let NumberOfLostTeeth = 4
HaulFromToothFairy = PricePerTooth * NumberOfLostTeeth
|
|
|
|
|
And then... My first programming experience was with BASIC, in those days when it really was BASIC! Numeric variable names were restricted to A to Z and A0 to A9, B0 to B9 etc. up to Z0 to Z9 - 286 numeric variables, if you used them all. String variables were $A to $Z - 26 in all.
If your background is like that, statements like "Let NumberOfLostTeeth = 4" makes no sense at all. It provokes a SYNTAX ERROR message, or something of that sort.
(Sort of if you - anno 2015 - try to use non-ASCII letters or spaces in a file name on a *nix system... Yes, the underlaying file system can handle it, in principle, but nine out of ten application barf if you simply give them such a filename, plainly, with none of the seven, or is it eight, or nine, different escape/quoting alternatives, only one of which is understood by the application.)
|
|
|
|
|
You're problem is that you are thinking abstract, and your son isn't. Get some physical objects and label them. Like paper cups and marbles.
|
|
|
|
|
You're discussing a 'pointer to a memory address area" to a KID????
Good Lord....
Heck, I probably wouldn't discuss memory pointers during the first SEMESTER of a programming course. They are an unimportant implementation detail.
As others have pointed out, better to go with boxes drawn on a sheet of paper, or bags of candy. Talk of the concepts rather than the mechanics.
Truth,
James
|
|
|
|
|
Wow, having to describe what a name is to a first-grader. Glad I dodged that bullet. I'm going to assume you wanted a straight answer to this question, so ...
The Alice-in-Wonderland answer below is an awesome answer, but is probably a bit too hard for a first grader. So you could say, "A name is a short word to describe something. We call you Bob (whatever his name is), or Bobby, or sweetie-pie, because it's faster than calling you 'skinny red-headed kid with the lopsided grin and the goofy sense of humor' all the time. Your name isn't you, it's something we say that picks you out of a crowd.
Now 'a' and 'b' are names. They name little boxes in the computer that each can hold a number. There are millions of these little boxes, so we have to give them names to pick them out of the crowd.
When we say 'let a = 2' we are saying, put the number '2' into the box whose name is 'a'. When we say 'c = a + b' we are saying, take the number out of the box named 'a', take the number out of the box named 'b', add the numbers together, and put them in the box named 'c'.
I actually had the grown-up version of this problem when first learning to program. I didn't understand the difference between symbolic constants, where the name actually meant a number, from variables, where the name meant a storage location into which you could put a number. I didn't get why the assembler (yeah, they taught programming using assemblers, what were they thinking) produced an error when I tried to assign a new value to a symbolic constant.
|
|
|
|
|
rnbergren wrote: Ideas? I didn't get anywhere It sounds like you didn't manage to connect to the concrete knowledge he knows, before you tried to extend his knowledge into something abstract. Perhaps try again, using x & y as variable names. That should make the equation "x + y" look more like something he's familiar with from algebra classes. Explain it as how the computer is computing the result of the algebraic equation.
And whatever you do, keep the how-a-computer-does-stuff talk out of any explanation. None of it is relevant to beginning programmers, and just serves to confuse and demoralize them.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
Usually when it comes to variables i use this analogy. Let any variable be a room in a file cabinet. We stick on one of them the letter a, that is our variable. We stick on another the letter b, being another variable. In the first, a room, we put the number 2. In the second one, b, we put the number 3. What would result from adding the content of a and the content of b?
|
|
|
|
|
Algebra is a topic that comes later in a child's life because it is a hard concept to grasp. Then you try to tie in the mechanics of a computer that I've seen adults struggle to comprehend. No wonder you are feeling a little under water right now.
A computer program ties a process with values that are unknown until supplied. Basically, algebra coded in a computer. This is a tough sale for any newbie.
A=2
AB=10
What is B?
You have to explain AB is shorthand for A*B, he has to understand multiplication and division, he has to understand substitution, he has to understand the wonder of being able to figure out the value of B without ever being directly told what it is and the processes he followed to find out what B is without ever being directly told what it was. Then, that you could do the same thing with computers.
You start too young you may turn him off to math for good.
|
|
|
|
|
Perhaps you are expecting him to run before he can walk? Teach him the basics of algebra and then a + b = 5 should be intuitive. I know we live in an age where logic supposedly triumphs, but teaching things to young people so that they become intuitive makes life a lot easier down the line. When I started writing applications at 13/14 I didn't have any problems at all with such statements because I already had a basic understanding of algebra, hence defining and manipulating variables was already second nature. After all, the use of such variables in computer science was based on mathematics, so why not teach things in the order they happened?
|
|
|
|
|
Try this - write down the math problem in this fashion:
1. 2 + __ = 5 - What is the answer? (3)
Then:
2. __ + 3 = 5 - What is the answer? (2)
Then:
3. 2 + b = 5 - What is the answer? (b = 3)
Then:
4. a + 3 = 5 - What is the answer? (a = 2)
Then:
5. if a = 2, then a + 3 = 5, and if b = 3, then 2 + b = 5
Then:
6. if a = 2, and b = 3, and if a + b = c, then c = ? What does "c" equal?
If he doesn't get it by this point, then he just isn't ready for simple algebra, and should go back to playing with clay (nothing wrong with this, btw - he just may not be mentally ready). Keep the problem handy, and try it again in a year.
Good luck.
|
|
|
|
|
Your 'test program' makes the mistake to immediately define all inputs, and your son immediately optimized away the need for variables (good job! ) By providing the inputs, you immediately nixed the reason for writing the program, and your son understood that (clever guy! )
Maybe you've started it all wrong: you basicaly asked your son to play the role of the computer/debugger. Instead he played the role of an interpreter, that's why he doesn't understand the hassle of 'a' and 'b'.
It would be better to first confront him with an actual problem that introduces the idea to use an abstract container (a variable). E. g. evaluate football results from a list of matches. Sometimes you need to do repetitive calculations, and that is where variables come in handy...
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
|
So? Just buy 2 yachts, then you'll have a spare helicopter pad if you should need it...
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
Yes, but I always liked the Gazelle and in how many of them can you fly at once?
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
What a f***ing waste of everything.
|
|
|
|
|
Rage wrote: What a f***ing waste of everything.
Exactly.
|
|
|
|
|
At least some of the future owners money helps to employ the people who built it
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Best not sail it anywhere near Somalia...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
It's probably faster then the pirate's boats
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Probably a tad bigger as well.
|
|
|
|
|
Not necessarily - they use fast motorboats and an aluminum ladder.
They've taken some big ships in the past too - right up to an including oil tankers.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
My idea was that this yacht will probably be faster than an oil tanker But even if not, there will probably be grim looking armed guards on board and integrated defense systems like tazers, smoke generators and, of course, lasers!
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Very unlikely.
Commercial shipping (and that basically means non-military vessels) are banned worldwide from having weapons on board (governments don't want Kawasaki sailing into harbour and capturing New York )
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
okay.. then just tazers on the hull and smoke generators
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|