Ask HN: how do/would you teach programming?
We see a lot on HN about teaching yourself to program. What about teaching others? I'm TAing an introductory computational biology couse at my University, and tomorrow I'll be teaching a group of students, many of whom have never programmed before, the basics (MATLAB specifically). Its been a few years since I was in their shoes and its difficult to put yourself in the mindset of the very beginner. I'm sure others here encounter this problem, even if its just trying to explain basic programming concepts to coworkers, family, or friends. So HN, what advice do you have for teaching / explaining programming to complete neophytes?
10 comments
[ 3.3 ms ] story [ 32.9 ms ] threadThe secret is simple: Incremental Project-based training.
Create a set of 5-10 projects which all: 1/ put in direct action a theory point. 2/ take advantage of previous acquired knowledge. 3/ leave the student learn on his/her own.
GL.
I'm not sure about MATLAB but I do know there are some very basic and easy tutorials on how to make a Sudoku for example.
The best way to teach others anything is to get them excited about the subject, when they are, people tend to naturally invest more time and effort into learning more about it.
Hope it helps and good luck teaching!
I would suggest the same as the others wrote before - teach some theory, create a few simple stuff with them, and let them learn :-)
Tomorrow you'll be introducing how to get Matlab installed, and basically how to get running. No one did this before hand except for 2-3 kids. You'll do hello world, then make a helloworld.m file and half the class will be confused. If you can add 2 numbers, make a variable, and concatenate a string I think you'll be in good shape.
Remembering back to my intro engineering class, loops and specifically arrays are the hardest things to get in an intro programming class. It's "omg hard" level for them right now, even though Matlab does a bunch of the heavy lifting for you. While loops, for loops that increment by more than 1,and do-while loops are where they might struggle.
One of the most fun things we had to do for a project was using Matlab to manipulate audio files. Speed up, slow down, or make the tracks louder or softer. You can also do mixes using it. It's all array operations and then they can save the result to a file. I still have my quadruple speed mp3 on my computer from a 7 years ago.
That's what would work for me. People who are smart are going to pick up on what you're doing and get ahead. People who aren't so smart won't get too lost.
The last thing I would say, is not to assume audience knows anything. For example, I would stay away from writing a checkers game - there are different ways to play it, people will argue, some maybe never even played it. Chess would turn off some people right away. Keep problems simple.
Hi. I volunteer at my local college as a Computer science Tutor.
Your teaching applied programming, so I would, unless it's a requirement, avoid most discussions of how things work, beyond the fact that the programming language is a way to write instructions that get the computer to do something.
I'd emphasize that loops, if/else, comparisons, boolean logic, arrays etc, are all composable, and you can build really complex things with them by combining them, just as you can build really complex equations by combining simple mathematical functions.
Then get them writing functions. I'd introduce them to a function the first day, and explain that code is broken up into functions, because they are composable, testable, reusable, and allow the writer to focus on getting a specific task correct.
Get them printing stuff the first day, and reading input in from a file, not just a keyboard. These are essential for any scientific work. I'd provide ways to read in files of different formats... I'm not sure what computational biology generally uses, but you might want a csv and a plain text file.
I'd then do if/else which lets you talk about boolean logic.
Teach them about nested if statements.
Then I'd move on to loops and arrays.
Teach loops tied to arrays. They are almost always used together anyway. Teach multi dimensional arrays as arrays of arrays, generally gone through with nested loops.
Post useful code for them to download and read, with comments on what each line does. Challenge them to modify it to do something different but related. Talk about how to debug code.
Talk about binary searches... I'd mention them first as a way to debug code, then introduce them later.
Show how to write function to find a minimum value in an array. Matlab probably has this, but show them it, because the fact that you initalize the comparison to first element and start comparing with the second, and not just initialize to 0 or something isn't obvious. I often see people have this issue.
show how to write a function to exchange values, if that requires a temporary variable in matlab.
show them how you can put those functions together and make a simple sort.
The truth is that for most actual things they will do while working, until they understand MatLab well enough to write their own stuff, they will be googling code and modifying it, so get them in the habit of reading code to understand what is going on, and modifying it.
Teach them to comment their code. Teach them to try to think about the steps involved before they code too much... try to get them writing down what they are going to do, and implementing it.
Oh and finally, have them write code, and then review it, or (easier for you) peer review it. Getting comments on code helps more then merely copying other's styles, because then they learn why you would do something.
They will procrastinate, often unintentionally. Of course you can warn them, and give them lab time in class, but that may not be enough, so plan for what you will do about late assignments.
I know one teacher who always gave specific deadlines, and then moved them on the due date, just to get people to start working earlier. Even that wasn't entirely successful.
I've taken a fair amount of inspiration from the SICP lectures by Sussman and Abelson. If you are planning on teaching people to program, they are worth a watch.