2022 Developer Survey is open! Take survey.
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 ...
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 ...
user avatar
  • 31.2k
46 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: ...
user avatar
  • 31.2k
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" ...
user avatar
41 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 ...
user avatar
  • 34.7k
40 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 ...
user avatar
  • 8,992
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. ...
user avatar
  • 4,754
35 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 ...
user avatar
  • 3,465
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 ...
user avatar
  • 3,995
27 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 ...
user avatar
  • 379
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 ...
user avatar
  • 31.2k
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 ...
user avatar
  • 34.7k
23 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 ...
user avatar
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 ...
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 ...
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 ...
user avatar
  • 8,992
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 ...
user avatar
18 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 ...
user avatar
  • 181
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 ...
user avatar
  • 4,684
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. ...
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 ...
user avatar
  • 34.7k
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 ...
user avatar
14 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 ...
user avatar
14 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 ...
user avatar
  • 241
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 ...
user avatar
  • 34.7k
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 ...
user avatar
  • 3,465
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 ...
user avatar
  • 31.2k
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 ...
user avatar
  • 320
11 votes

Real life examples of 0-indexing

I don't see anything confusing in 0-based indexing. In fact, it seems that 0-based indexing is not less natural for humans than 1-based indexing. Humans use 1-based indexing just because of following ...
user avatar
  • 320
11 votes

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

The value of the command line can clearly be demonstrated by looking at a simple gui configuration task, which might take 5 or 10 screenshots, and still be ambiguous in comparison to 'open a shell and ...
user avatar

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