102 votes

What are good examples that actually motivate the study of recursion?

I find a very easy to understand example for recursion is the folder structure on a computer. Look through all folders (within a certain location) and... list all .doc files, for example. First, you ...
Syndic's user avatar
  • 981
98 votes
Accepted

How to explain the concept of a variable to a 9-year old?

Buffy's lovely answer shows well how two variables can refer to the same thing, but since we are in early cognitive development and working with Scratch, in which you can't pass parameters, and can't ...
Ben I.'s user avatar
  • 32.8k
47 votes

Real life examples of 0-indexing

You can get at this concept very intuitively in strings before you ever get to arrays. Take a string like "hello world" and ask them a subtle-sounding point: does the string begin here: ...
Ben I.'s user avatar
  • 32.8k
44 votes

Real life examples of 0-indexing

Ages in the United States (it's not the same around the world). For the first year of life, children are 0 years old. Only after completion of a year is the age changed to 1. By this logic, a child ...
Peter's user avatar
  • 9,082
44 votes
Accepted

Interesting Programming Exercises to Teach Inheritance?

I'm not as familiar with Python as I am with other languages, but I'm sure your students have played Minecraft. If you haven't, I suggest taking a few minutes to find some introductory "Lets Play" ...
Draco18s no longer trusts SE's user avatar
42 votes

How to explain the concept of a variable to a 9-year old?

My usual explanation is related to names; specifically names of people. People have names. The names are not the people, but can be used to refer to the people. Some people don't have any names at ...
Buffy's user avatar
  • 35.8k
37 votes

Real life examples of 0-indexing

An analogy that will work well in Europe, but not in North America: Image licensed under the CC BY-SA 3.0 by Bidgee of Wikimedia Commons. Floors (in European countries) are typically numbered with 0 ...
Aurora0001's user avatar
  • 3,506
37 votes
Accepted

Demonstrating the possible dangers of SQL injection

The best way to show your students that their work is vulnerable to SQL injection is to demonstrate it. I'd suggest that you challenge the students to "hack" each others projects using SQL injection. ...
thesecretmaster's user avatar
  • 4,785
33 votes

How to teach Stack Overflow more efficiently?

I don't think the core issue is that some students are bad at using Stack Overflow -- I view that more as a symptom of a deeper root problem. When somebody doesn't seem to be able to productively ask ...
Michael0x2a's user avatar
  • 4,005
26 votes

What are good examples that actually motivate the study of recursion?

One good example is to make permutations of all of the letters in a word of arbitrary length. It's quite tricky to do iteratively, since you essentially have to recreate the program stack to get it ...
Ben I.'s user avatar
  • 32.8k
26 votes

How to explain the concept of a variable to a 9-year old?

What about You have alot of values that you need to remember, so you put a label on each one (a little piece of paper to remind you what this value means) so you can find the value easily when you ...
DPDP's user avatar
  • 369
24 votes

Real life examples of 0-indexing

The clock (24 hours system) If we look at the clock, we have two examples of counting hours. The 24 hour system starts at 0. The 12 hour system is interesting, neither starting at 0 or 1. The 12-hour ...
ctrl-alt-delor's user avatar
24 votes

How do you teach Big O to high schoolers with varying degrees of math exposure?

One good overall educational strategy is to teach the same thing to students repeatedly, using a Spiral approach, in which each turn of the spiral teaches at a deeper level. Don't expect the students ...
Buffy's user avatar
  • 35.8k
22 votes

How to teach the value of the command line in high school?

I can't speak to cloud9 but I've always taught on Linux and am a CLI wonk. One thing I do is differentiate between user friendly and learner friendly. GUI interfaces are learner friendly - they're ...
Mike Zamansky's user avatar
21 votes

What are good examples that actually motivate the study of recursion?

Writing recursive code to output the Snowflake Curve (Koch snowflake) was something that definitely pushed my buttons early on. It's formed as follows: The Koch snowflake can be constructed by ...
bruised reed's user avatar
20 votes
Accepted

How to respond when students ask "is recursion good practice"?

Quite honestly, I would be upfront with them about the debate. Send them to a couple other SE threads: Efficiency: recursion vs loop “Necessary” Uses of Recursion in Imperative Languages Are ...
Peter's user avatar
  • 9,082
20 votes

What are good examples that actually motivate the study of recursion?

Other than the obvious merge sort, I really like the minimax algorithm, especially when applied to creating a computer player of a simple game. Start with something simple like tic-tac-toe. When it's ...
Kevin Workman's user avatar
19 votes

How to teach the value of the command line in high school?

One way to show them the value of the command line would be to juxtapose doing a task with a GUI and with the command line. You could do something like the following: Create a directory with mixed ...
DaniG2k's user avatar
  • 191
19 votes

Non-native English speakers struggle to come up with decent variable names and function names

The point of good variable/function/class naming is to express problem semantics to readers, including the programmers. If your readers are primarily French speakers, use good French naming for ...
Buffy's user avatar
  • 35.8k
18 votes

Demonstrating the possible dangers of SQL injection

A couple suggestions - The classic xkcd comic about Bobby Tables: Shown, complete with the explain xkcd article can provide a nice, humorous introduction that will get them to start paying to ...
Auden Young's user avatar
  • 4,674
17 votes

Explaining why styling should not be done directly in HTML

I like the idea of producing a few style sheets, and having the pupils apply them to their HTML. They can then see the power of having separate style sheets. Start with a style sheet that you made. ...
ctrl-alt-delor's user avatar
16 votes

Interesting Programming Exercises to Teach Inheritance?

Too many examples that you find are (IMO) fatally flawed. The Animal->Dog is especially flawed, though widely used. The problem is that these sorts of examples almost require that the superclass has a ...
Buffy's user avatar
  • 35.8k
15 votes

How to respond when students ask "is recursion good practice"?

When I teach recursion, even if I am not at a point in the curriculum where it is possible to introduce trees in coding problems, I always at least provide a high level discussion of trees, and the ...
Phill Conrad's user avatar
15 votes
Accepted

How to teach the value of the command line in high school?

You can't teach the value of the command line. You can, however, sell it. Students have at least one of two primary goals in any class: Get good grades (pass the class) Learn something they like ...
Gypsy Spellweaver's user avatar
15 votes

How to explain the concept of a variable to a 9-year old?

The variable that children are most familiar with is score: whether in computer games, sports or board games, a child will almost certainly understand that a score is a value that is clearly not ...
pbeentje's user avatar
  • 251
13 votes

What are good examples that actually motivate the study of recursion?

I'm going to focus on student's understanding recursion at a fairly deep level, rather than coding. First, to really understand recursion you need a sense of its parts. There is the base case, of ...
Buffy's user avatar
  • 35.8k
12 votes

How to teach the value of the command line in high school?

Not a demonstration, but maybe a nice thought to tell your students. I read a nice analogy a few months ago, linked from a question somewhere on stackexchange: Using a computer only with a GUI is ...
kratenko's user avatar
  • 221
12 votes
Accepted

How to stress the importance of testing code?

Introduce test-driven development. TDD and agile methods of development are very popular at the minute, and for good reason — you know, ahead of time, exactly what each part of the program must ...
Aurora0001's user avatar
  • 3,506
11 votes

How can I convey the idea of a programming language vs. a markup language?

I also have this problem frequently. I use the example of Microsoft Word, and I would say something like this: "Word allows you to give a document the appearance that you'd like. You can bold, you ...
Ben I.'s user avatar
  • 32.8k
11 votes

Lesson Idea: Arrays, Pointers, and Syntactic Sugar

You overestimate the complexity of 0-based indexing a lot. There is nothing complex in 0-based indexing. On the other side, the topic of the pointers is relatively complex. I don't think it has any ...
Sasha's user avatar
  • 320

Only top scored, non community-wiki answers of a minimum length are eligible