How do you teach others how to program?

Cogman

Lifer
Sep 19, 2000
10,286
145
106
I consider myself a fairly decent programmer, I could navigate several languages, I understand many nuances, heck, I even know a fair bit of assembly. But when it comes to teaching others how to program, I'm lost. These things always came naturally to me, so it is hard to isolate and eliminate confusion.

I have a friend that I'm helping, I've tried everything, mapping out what the program should look like, giving him selections to read from his text, even giving him examples (IE current problem he is having, but a bit different.) And nothing seems to sink in. I'm at a loss, these are really basic things that he seems to know no better then after spending multiple hours going over, and over, the concept with him.

For example, I don't think he understands what the difference between a string, bool, int, char, and char* is in C++. He doesn't seem to know what it means when you say "int variableName;", I've tried explaining it to him 100 different ways, and nothing seems to sink in.

Heck, when I have him explain what his program supposed to do, he'll say things like "If the function returns true, then I need to do this." And has no clue how to code that up, he wants me to write it for him (which I refuse to do.)

I don't know if any of you struggled, or know people that struggled, but it would really help me if you had suggestions on what I could do to give my friend a hand. I've gone so far as writing a decent chunk of code (that doesn't plug directly into his program) that does essentially what he needs, commenting every single line in excruciating detail, and he still has no clue.

In a couple of minutes, I'm going over for another 3 hour session. I've been thinking of having him write testbed code (not required by his teacher) to the functions that he has already mapped out for this latest assignment. If that doesn't work, I don't know what next. Anything helpful would be appreciated.
 

Snapster

Diamond Member
Oct 14, 2001
3,916
0
0
To me it seems some people cannot program no matter how you teach them, you either have an ability to tackle a problem logically and build an appropriate solution. You might find pair programming a useful way to teach them as a mentor as you can explain what you are doing as you are doing it, comment before you code and confer between each-other as to why choose this method. Of course it has a high overhead in your time but it's a good way of transferring skill.

If someone cannot even break down a problem in psudocode then there is not much hope, sadly.
 
May 11, 2008
22,565
1,472
126
I consider myself a fairly decent programmer, I could navigate several languages, I understand many nuances, heck, I even know a fair bit of assembly. But when it comes to teaching others how to program, I'm lost. These things always came naturally to me, so it is hard to isolate and eliminate confusion.

I have a friend that I'm helping, I've tried everything, mapping out what the program should look like, giving him selections to read from his text, even giving him examples (IE current problem he is having, but a bit different.) And nothing seems to sink in. I'm at a loss, these are really basic things that he seems to know no better then after spending multiple hours going over, and over, the concept with him.

For example, I don't think he understands what the difference between a string, bool, int, char, and char* is in C++. He doesn't seem to know what it means when you say "int variableName;", I've tried explaining it to him 100 different ways, and nothing seems to sink in.

Heck, when I have him explain what his program supposed to do, he'll say things like "If the function returns true, then I need to do this." And has no clue how to code that up, he wants me to write it for him (which I refuse to do.)

I don't know if any of you struggled, or know people that struggled, but it would really help me if you had suggestions on what I could do to give my friend a hand. I've gone so far as writing a decent chunk of code (that doesn't plug directly into his program) that does essentially what he needs, commenting every single line in excruciating detail, and he still has no clue.

In a couple of minutes, I'm going over for another 3 hour session. I've been thinking of having him write testbed code (not required by his teacher) to the functions that he has already mapped out for this latest assignment. If that doesn't work, I don't know what next. Anything helpful would be appreciated.

Let me see if i understand your issue, when reading your post, it comes to my mind that your padawan does not link the subjects you mention with something he can relate too. The problem is the balance to give someone enough information that he/she has that "eureka" moment but not that much information that the person feels lost and hopeless and on the verge of depression. The latter because it is just so much information that he/she locks up.


For example, I don't think he understands what the difference between a string, bool, int, char, and char* is in C++. He doesn't seem to know what it means when you say "int variableName;", I've tried explaining it to him 100 different ways, and nothing seems to sink in.

In my opinion the main problem is that programming gets to abstract. There is nothing wrong with a healthy amount of understanding what the software does with the hardware. I think you must teach him that a cpu only understands machine instructions. He does not need to know how to write assembly. Just that he is aware of it's existance. Then introduce him to the assembler. What does it do. Introduce him to the compiler and the linker. Nothing to fancy, he does not need to be an expert, just that when he writes a programming some part of his mind is aware of the fact that he is writing a program(software) that is executed by hardware. Add in some trivial history and i guess this will work. Show some examples with some animated colour leds and animated pushbuttons.

EDIT:
Explain about memory size and bus width and register width. What makes an int an int, a bool a bool.
I know this a nono in the c- world but you must let him know what bits and bytes are. Then it is easier to explain why an unsigned integer variable that can store a maximum number of 65536 - 1 does not fit in a byte or bool or char. Explain about ascii, why are ascii chars 8 bits ?. Throw in a little bit of history. I recently learned our brains work with content addressable memory. This means you need to feed information that is associative for your friend. Sometimes you need to delay the course a little to create a solid fundament. Convert the examples to real life situations. How much pencils can you hold in one hand ? and how much in 2 hands ?


I think a good idea would be an embedded processor. I think the best way is to do some basic teaching of the hardware. For example what happens when you declare a global variable, where is it stored. What is it that the compiler does with this information. When you declare a variable inside a function, where is it stored. Is it a memory addres in ram , is it a register, or is it just some part of an abstract calculation only used by the compiler and later on changed to nice machine instructions ? Share enough information about this that he understands it but do not go to deep into it. Because then it will be to much information and to much sidetracking.


Heck, when I have him explain what his program supposed to do, he'll say things like "If the function returns true, then I need to do this." And has no clue how to code that up, he wants me to write it for him (which I refuse to do.)

The bold part is part of the reason why i write what i write. He must understand that it is not him who is doing the work. It is the hardware the program will run on.

I hope i can help you with this post...

P.S.

Try to place yourself in his position. Forget what you know and he does not. Then it will be a lot easier to see where he goes wrong. If there is one thing i have learned, is that there are no real dumb people. Some just do not have the desire to learn and cannot be helped, and that is a conscience decision. But most people are eager to learn but did not have the same education, and as such one cannot expect someone without prior knowledge to understand everything right away. Show them the path, the rest they must do on their own... :)
 
Last edited:

Net

Golden Member
Aug 30, 2003
1,592
3
81
I came across similar situations when I was a teaching assistant. There's a few things that I found helped out for those who struggled.

Keep it simple. Avoid too much detail as this will bring up more questions that get into tangents. And then follow up with a good real world example and some example code.

So when your teaching about variables you tell him that it is a place holder. Like a cup holds water or just like in math were x can hold 5 or 6 or 7 etc...

If you want to hold a number you use an "int", if you want to hold a word or sentence you use a "string", if you want to hold only one letter you use "char".

At this point you don't want to bring up shorts, longs, booleans, etc... Avoid technical words too, you can bring this up after he understands it. So when you teach him how to declare a variable use the word create and later when he's more advanced you can tell him we say declare instead of create in the programming world.

Write some example code:

int x;

"Here I created the variable x. Its an int. What can int's hold?" Then pause for him to answer.

If he gets it right and say's they can hold numbers, ask him to pick a number. If he says 4.5 don't talk about doubles just say they can't be fractions. You can get into the technical details later. So he says 5. Then you say, thats right and this is how I make x hold 5.

x = 5;

Now x holds 5. Use the same words consistantly such as hold, it will help him follow along. Later, when he advances more you can use words like assign, declare, instantiate.

Then get out a piece of paper and ask him to create a variable that is an int and make it hold 200.
 

Cogman

Lifer
Sep 19, 2000
10,286
145
106
So here's what I did with him, and it actually worked pretty well (he seemed to really start getting it.)

Sadly, our school doesn't really teach unit testing, at all. However, I thought it would be a good idea for him, something to solidify what functions and variables are. So for his project, I wrote the unit test, he wrote the function (and copied the unit test that I wrote) We got about 4 functions knocked out this way. The first function was a bit shaky, but after the 4th one, he was writing the prototypes perfectly and most of the functions without much prompting from me.

I think just seeing how someone thinks when they write code really sort of helped him get into the groove. It was also rewarding for him to see "functionX is Correct!". While he didn't understand the process of saying "This is expected output, this is expected input." Once he saw the unit tests, he did a pretty good job of doing the functions on his own. Worked better then I thought it would.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
I taught C++ and OOAD for a couple of years back in the 90's. In every class I would be happy to find one or two people who really got it, and would get the most benefit from the class. The rest were there to put a line item on their resumes.
 

Red Squirrel

No Lifer
May 24, 2003
70,618
13,818
126
www.anyf.ca
I find some people simply can't grasp the concepts. I remember in my college programming class, lot of people would just learn the code by heart without understanding what it did. The worse part is the teacher kept putting problems on the tests that we had already seen in class, so people just memorized the ones they were pretty sure would be on the test. People wondered how I passed every test without studying. The only studying there was to do is syntax, like if there was something that was new to me. But most of the class covered stuff I already knew like how to write classes, derivation etc...
 

Modelworks

Lifer
Feb 22, 2007
16,240
7
76
Some people are not wired to be programmers. They will never get it, sometimes that has to do with focus. Has someone ever been talking to you about something and you zone out hearing the words but not really listening ? Psychologist say the same thing happens to people in school when taking subjects that they are not really wired mentally to learn.

I remember back in I think 6th grade a teacher was trying to explain to me the concept of negative numbers. I had the hardest time understanding that concept despite her spending almost an hour tutoring me on the subject. I couldn't grasp that a number could be negative. I mean zero is nothing and now you are telling me a number can be less than nothing ?
 
May 11, 2008
22,565
1,472
126
Some people are not wired to be programmers. They will never get it, sometimes that has to do with focus. Has someone ever been talking to you about something and you zone out hearing the words but not really listening ? Psychologist say the same thing happens to people in school when taking subjects that they are not really wired mentally to learn.

I remember back in I think 6th grade a teacher was trying to explain to me the concept of negative numbers. I had the hardest time understanding that concept despite her spending almost an hour tutoring me on the subject. I couldn't grasp that a number could be negative. I mean zero is nothing and now you are telling me a number can be less than nothing ?

I know exactly what you mean. When i was at school as a little boy i would get math lessons. y=ax*b for example . Very simple. The teacher unfortunately for me was not very good at explaining. I took the equation literally. Therefore i could not solve it because this where not numbers. And i only had to learn to calculate with numbers. Later on when another student told me that these where just containers for numbers and i had to use numbers in a range, i visualized it and it was easy.
Later on i had the same problem with advanced math. If i cannot use it for a task but just to practice math itself, i cannot understand it. I always wonder if other people have that though, when i can see it, i can rev up the complexity up to the point my brain starts to hurt and i start to forget things like the telephone. :D


I agree that some people are indeed not wired for a certain task. But the brain is flexible, if you really want to you can achieve a lot. Even if that means you will never be as good as someone who has some evolutionary advantage over you. But then again people are not good at everything. In situation A person A is smarter, in situation B person B is smarter. Or just more equipped for a certain task. Together this means more flexible problem solving then on a separate level.

I once have seen a documentary over an autistic idiot savant. He could calculate out of his head with 10 numbers behind the comma within 3 seconds. But he was totally not social and locked in his own mind. Later on when he got more social he got a job. His social skills improved dramatically over the years he went to work (in the library, if i remember correctly). However he lost the ability to calculate. He started to make errors and was not good at flawless counting matches anymore. But he was a lot more social and loving person. If this is not a case on it's own but a general feature of the brain, this means we all have it. But i think with severe autistic people they just keep on calculating in their head non stop like a compulsion. Not able to let go of that one task.

Why i say this, i noticed it with people around me, it is very rare to find extreme smart people with a so called high IQ and a high EQ.
Being creative on all accounts is not that easy.
 

KIAman

Diamond Member
Mar 7, 2001
3,342
23
81
So far, the easiest way to teach programming has been a top-down approach. I usually teach through an example project, something simple but enough to teach several different concepts.

I find I have to use the English language A LOT in explaining the concepts. A project is broken down into several sub-projects with the understanding that the coupling produces what we want. This part should be easy where you continue to break up each individual piece until you get something so basic, it is futile to break it down any further. At that point, pseudo-code that simple piece using English as the root of logic (although English is pretty illogical). First I let them describe in detail what this tiny stub will do. Then I take out the nouns and place them as objects/primitives/variables and take out the verbs as the operands/operations/transforms. Then, continuing to use English, we use a syntax reference from whatever language we are using and build the simple unit utilizing the pseudo-code. Typically, the stub is bloated and incomplete. You can ask leading questions to help them complete the stub. Even individual function names should support the higher level pseudo-code

The excitement comes when the stub is tested and it functions exactly as expected. When the read their code, sometimes it clicks for them because using familiar words for their variables almost makes a sentence out of their implemented code. You can teach each programming concept from different stubs. Once they understand the concepts, the language doesn't even matter. A handy syntax reference is all that's needed and if they really want to delve into it, they can read up on their language nuances, compile optimizations, list of common dlls, framework, etc. They might understand the "hows" but need to research for the all "whys." The "whys" are always hard to teach because a lot of them are subjective. I often use the words "best practice" because in the end, the explanations are too involved.

Eventually all the stubs are coupled to their individual sub-projects and all the sub-projects are coupled for the final project. Once the project is running, you should see a sense of satisfaction else they were most likely never interested in the first place.

A lot of programming references uses English words to code but they often neglect on explaining how they came to use those words, instead assuming the reader understands simply from reading. Many novice programmers simply think the particular words were chosen just for entertainment.

Let them choose the next project and simply point them in the right direction, something interesting to them. I had one guy choose how to script a "bot" for a popular MMO. Although his project was successful, he was shortly banned thereafter.
 

chusteczka

Diamond Member
Apr 12, 2006
3,399
3
71
I teach a subject by explaining the thought processes I used to understand the topic. Other people ask for help because they have not yet connected the concepts to understand the problem. Connect the concepts for them in the way it helped you and they will gain understanding while developing respect and admiration for your ability to teach them.

Basically, teach the steps it took you to learn the problem.

Teach slowly, softly, with no pressure, at their speed.

Emphasize the key steps.

You will enjoy watching them learn.
 

rchiu

Diamond Member
Jun 8, 2002
3,846
0
0
I agree with the most posts. Some people are just not build to think like a programmer. To make things worse, most of us programmers are not build to think like a teacher too. :)
 

Modelworks

Lifer
Feb 22, 2007
16,240
7
76
Something else to try is physical aids. Things like legos can be used to describe memory functions and having the student assemble and remove the blocks as data is stored removed and manipulated can really help people understand the process. Especially things like bits and words and bytes.
 

Kirby

Lifer
Apr 10, 2006
12,028
2
0
What age is the person you're teaching? My programming teacher in high school also taught math. She would explain things like functions exactly like math functions machines: input -> do something -> output. Data types were like boxes or containers that only hold a certain type of data. Drawing pictures always helps me.

But still, as good as I (and a few others) thought she was, there was still a few smart people who just couldn't "get it".
 

tatteredpotato

Diamond Member
Jul 23, 2006
3,934
0
76
My problem is I often run into people who tell me "I know C++" or "I know Java". So I start to teach them things using this as a point of reference and I notice they aren't quite getting it. So I start asking questions like "do you know what a class is" or "do you know what 'static' means" to which I get blank stares. Now I wouldn't go using these concepts if I was properly aware of their skill set at the onset, however I consistently get people who seem to have a different definition of "knowing" a language than I do. Last night I thought the guys I were teaching were familiar with classes, so I asked them to write a simple class to store some values in memory. 20 or 30 minutes later I look at what they're doing and they just made a new java "class" file and put a main function. These are the times when you realize you have to back it up and start from the beginning.

For the record I'm an EE student and typically am teaching other EE students, but not many of them no much about programming besides basic variables and functions.
 

Kirby

Lifer
Apr 10, 2006
12,028
2
0
I've known several people who think because they can write a hello world program in c++ that they "know c++".
 

Cogman

Lifer
Sep 19, 2000
10,286
145
106
My problem is I often run into people who tell me "I know C++" or "I know Java". So I start to teach them things using this as a point of reference and I notice they aren't quite getting it. So I start asking questions like "do you know what a class is" or "do you know what 'static' means" to which I get blank stares. Now I wouldn't go using these concepts if I was properly aware of their skill set at the onset, however I consistently get people who seem to have a different definition of "knowing" a language than I do. Last night I thought the guys I were teaching were familiar with classes, so I asked them to write a simple class to store some values in memory. 20 or 30 minutes later I look at what they're doing and they just made a new java "class" file and put a main function. These are the times when you realize you have to back it up and start from the beginning.

For the record I'm an EE student and typically am teaching other EE students, but not many of them no much about programming besides basic variables and functions.

Well, he has never boasted to "know" programming. Part of the problem seems to be one of abstraction, he thinks of the entire problem, all the time. You just can't do that while programming, you have to break big problems into tiny problems and tackle those one at a time.

Couple that with the frustration of every time we declare a variable or call a function and going through the "Is it an int? string? double? char?" he defaults to int and works his way up until I nod at him. :( IDK, I'm starting to think this isn't for him.
 

KIAman

Diamond Member
Mar 7, 2001
3,342
23
81
Well, he has never boasted to "know" programming. Part of the problem seems to be one of abstraction, he thinks of the entire problem, all the time. You just can't do that while programming, you have to break big problems into tiny problems and tackle those one at a time.

Couple that with the frustration of every time we declare a variable or call a function and going through the "Is it an int? string? double? char?" he defaults to int and works his way up until I nod at him. :( IDK, I'm starting to think this isn't for him.

Hmm, this might be a little out of the box but maybe he needs some lessons in analysis and design. Some of the best developers I've come across also have been excellent analyzers (and documenters...). Those who can conceptually abstract real life requirements into an implementable design.

A lot of new programmers ask me "how do you start from nowhere?" It seems many don't understand where/how to start developing from scratch from a set of problem statements/requirements. This tells me they lack the ability to analyze a problem and visualize (and document) their proposed solution.

Those who refuse to do this are simply code monkeys. You give them pseudo-code and they pound it out and give you back a box. When it comes down to it, coding, itself, is pretty easy. Just a glorified typer. Producing good, clean, performing, lean, legible and efficient code that takes advantage of compiler optimizations require good analysis and design skills.
 
Last edited:

PhatoseAlpha

Platinum Member
Apr 10, 2005
2,131
21
81
Right, because certain people pop out of the womb and immediately start writing C++ programs.

:rolleyes:

As MarkBNJ noted, this is not just elitism. No one pops out knowing C++ syntax, but lets be blunt here - knowledge of the details is largely irrelevant. That's why a good coder can switch between languages without much trouble.

The ability to abstract problems, to atomicize them, to maintain precise, internally consistent representations of those abstractions - those are the 'born in' abilities that have the most effect on development ability.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
As MarkBNJ noted, this is not just elitism. No one pops out knowing C++ syntax, but lets be blunt here - knowledge of the details is largely irrelevant. That's why a good coder can switch between languages without much trouble.

The ability to abstract problems, to atomicize them, to maintain precise, internally consistent representations of those abstractions - those are the 'born in' abilities that have the most effect on development ability.

Yep. Someone said once, might have been Dijkstra, that the average person can keep 3-5 things in mind at one time, and that the difference between a good programmer and a great programmer is that the great programmer was born being able to keep 5-7 things in mind at one time.

Kiaman, I generally agree with you, but when you say that basic programming skills are just "glorified typ[ing]" I strongly disagree. Bad programmer is to good programmer as bad watchmaker is to good watchmaker. What distinguishes either kind from the general public is that they can build a working watch. That's the base prerequisite for calling yourself a watchmaker. If you're so bad that you can't build a working watch, then the best you can do is "aspiring watchmaker."

I know lots of aspiring programmers I might describe as glorified typists, but I do not know any actual programmers who fall into that category.
 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
scratch.mit.edu

Have him start there. It's visual, it's easy to learn, and it's designed for 10 year olds. You can build complex object oriented programs with it, and it's fun.

If he can't learn to program with scratch, he simply is not built to program.