Actualize How To Teach Programming
Actualize How To Teach Programming
HOW TO TEACH
PROGRAMMING
THE ACTUALIZE METHOD
JAY WENGROW
PETER JANG
ACTUALIZE.CO
HOW TO TEACH PROGRAMMING
1
INTRODUCTION
2
CURRICULUM DESIGN
3
CLASSROOM INSTRUCTION
4
CONCLUSION
HOW TO TEACH PROGRAMMING
Introduction
Teaching is hard. A lot of people believe that someone who is an
expert at a subject should be highly qualified to teach that subject.
Yet, often the reverse is true - the more you know about a subject,
the less you remember what it was like to learn the subject. For
example, I am an expert at walking, having done it all my life (I
almost never bump into things by accident). However, that doesn’t
qualify me to become a physical therapist for people who have been
injured and need to relearn how to walk from scratch. My ability to
walk is so intuitive that I have no idea where to begin if I had to
teach someone. This is called the curse of knowledge.
PART ONE
CURRICULUM
DESIGN
WHAT TO TEACH AND WHAT ORDER TO TEACH IT
Beginners are
often paralyzed
by choice.
HOW TO TEACH PROGRAMMING
Choose teachable
technologies
Choosing the right technology to teach a beginner can be a daunting
challenge. Programming is a fast moving world; no one wants to
learn a language or skill today that becomes obsolete tomorrow.
One trap a lot of curriculum designers fall into is to teach the newest
tech. The problem is that the newest tech is by nature the least
stable, which can lead to a terrible learning experience. Instead of
focusing on understanding the fundamental concepts of
programming, students will spend their time fixing installation issues
and breaking changes with each new version of the technology.
CURRICULUM DESIGN
HOW TO TEACH PROGRAMMING
CURRICULUM DESIGN
HOW TO TEACH PROGRAMMING
CURRICULUM DESIGN
Programmers
spend more time
reading code than
writing code.
HOW TO TEACH PROGRAMMING
A beginner often falls into the trap of writing code they simply do not
understand. It’s bad if they write code they don't understand that
doesn’t work; it’s worse when they write code they don't understand
that does work. Without the ability to read code, the ability to write
code becomes almost meaningless.
CURRICULUM DESIGN
HOW TO TEACH PROGRAMMING
CURRICULUM DESIGN
A learner can only
focus on one
thing at a time
effectively.
HOW TO TEACH PROGRAMMING
Let’s examine what this looks like in the following simple coding
example:
CURRICULUM DESIGN
HOW TO TEACH PROGRAMMING
The “bad intro” code isn’t bad code at all for experienced web
developers! However, this shouldn't be the first example of Rails
controller code you teach to someone new to web development. In
those four lines, there are a multitude of concepts being introduced,
including RESTful naming conventions, instance variables, database
communication, and rendering a separate view. Note that this is very
difficult for experienced programmers to notice, since they are so
familiar with each concept (the “curse of knowledge” mentioned at
the beginning of this book).
The “good intro” code begins with just rendering a view. Once a
student grasps this concept, you can layer the other concepts one at
a time when appropriate. This provides a better foundation for
students to deeply understand each concept.
CURRICULUM DESIGN
A demonstration
is worth its weight
in gold.
HOW TO TEACH PROGRAMMING
One of the keys of making high quality examples is to look out for
coincidences. In math, 2 x 2 = 4 doesn't make for an ideal example to
first introduce multiplication, because, coincidentally, it is the same
result as addition (2 + 2 = 4). Instructors often don’t notice these
coincidences (due to the curse of knowledge), so it’s critical to take
extra care here.
One can argue that providing an example takes away from the
student discovering and learning on their own. We don't agree with
this perspective - if your goal is for students to discover something
on their own, then the concept you’re teaching is not a programming
concept - it’s the broader concept of problem solving. Problem
solving can be treated as an isolated concept, and an instructor can
and should provide examples and approaches to problem solving if
they truly want students to improve in that area. In the end, it’s your
job to identify the isolated concept to teach and identify high quality
examples to go with it.
CURRICULUM DESIGN
Scaffolding helps
learners reach
new heights.
HOW TO TEACH PROGRAMMING
CURRICULUM DESIGN
Good instruction
requires a
variety of
techniques.
HOW TO TEACH PROGRAMMING
There are some companies that use pair programming for 100% of
their work. While this may make sense for that company in terms of
professional work, it doesn’t make sense to pair 100% when learning
how to code. Pairing is an enormously effective strategy for certain
types of learning, but is far less effective for others. A good mix of
individual, pair, and group exercises is a key part of a well balanced
learning environment.
CURRICULUM DESIGN
Patterns only
emerge after
repetition.
HOW TO TEACH PROGRAMMING
CURRICULUM DESIGN
Choose the right
thing to focus on.
HOW TO TEACH PROGRAMMING
All three versions of the code work the same way from the
perspective of the computer. An advanced programmer may prefer
the first version, as it is terse and uses a shortcut to automatically
render the appropriate file. However, if the goal is to teach students
about writing methods to render a file, it’s too implicit. In this case the
second version is more explicit and is preferable. The third version,
however, is too explicit - it introduces more detail, but the detail is not
related to the concept being taught.
CURRICULUM DESIGN
Newer isn't
always better.
HOW TO TEACH PROGRAMMING
CURRICULUM DESIGN
HOW TO TEACH PROGRAMMING
The first version is the way most experienced developers would write
the code. It’s so familiar to them that they may not even recognize
that they’re using a shortcut with the .update method (which both
changes attributes in the object and then saves the changes to the
database). The second version makes these two steps more explicit by
separating them into two steps. It’s arguably more verbose, but by
reusing individual concepts that have been already taught, it helps
students form the correct generalizations and practice the concepts
they know.
CURRICULUM DESIGN
History provides
the foundation
of learning.
HOW TO TEACH PROGRAMMING
CURRICULUM DESIGN
HOW TO TEACH PROGRAMMING
PART TWO
CLASSROOM
INSTRUCTION
HOW TO TEACH AND EXPLAIN CONCEPTS IN THE MOMENT
Sometimes
learners need to
find their own way.
HOW TO TEACH PROGRAMMING
If you teach a novice about the best practice of DRY (Don't Repeat
Yourself), one of two things will happen: Either they won't believe in
its importance and generally ignore the rule. Or, they will believe in it
wholeheartedly without fully understanding why it's valuable, and
apply it to every situation imaginable. This is where you'll see a Chair
class inheriting from a Cat class because both have four legs. The
bottom line: It's not hard to teach a rule, but it's incredibly hard to
teach when it is appropriate to apply it.
CLASSROOM INSTRUCTION
HOW TO TEACH PROGRAMMING
CLASSROOM INSTRUCTION
Teaching requires
a completely fresh
perspective.
HOW TO TEACH PROGRAMMING
When you are teaching a concept to a beginner for the first time, it’s
important to keep the subjective nature of code readability in mind.
Abstractions, design patterns, shortcuts - these are all advanced tools
used to make code maintainable, but to a person who is not familiar
with them, the code becomes nearly impossible to understand.
Teachable code is code that makes the specific concept being taught
as explicit as possible.
CLASSROOM INSTRUCTION
HOW TO TEACH PROGRAMMING
CLASSROOM INSTRUCTION
Visual differences
will help avoid
confusion.
HOW TO TEACH PROGRAMMING
For a student who’s just learning about classes and methods, the first
example is surprisingly confusing. The curse of knowledge makes it
hard to appreciate how much is actually happening here. Nearly every
variable is named the same thing, and it’s hard to distinguish which
variable does what.
The second example makes it clear which variable is the input (by
adding an overly explicit prefix) and which is the instance variable.
This code would generally be considered to be less readable due to its
overly explicit nature, but it helps students distinguish between the
various pieces being presented here.
CLASSROOM INSTRUCTION
Avoid abstractions
at first.
HOW TO TEACH PROGRAMMING
Note that this takes some dedication - to teach code using these
explicit variable names, you would also need to use the same explicit
names in the routes file and html form to match. As cumbersome as
this sounds, this approach eliminates the abstraction in the params
hash and helps students make the appropriate connections. Once
they grasp the concept, feel free to demo code using more typical
conventions!
CLASSROOM INSTRUCTION
Learners need to
see each step.
HOW TO TEACH PROGRAMMING
Not only does this help with the teachability of the code, but it also
helps students debug their code when things go wrong. It’s easier to
see which part of the code has the problem when it’s not all on the
same line.
CLASSROOM INSTRUCTION
Show the big
picture first.
HOW TO TEACH PROGRAMMING
CLASSROOM INSTRUCTION
HOW TO TEACH PROGRAMMING
It’s easier for a beginner to understand the second code with a single
method, despite the fact that the first code with multiple methods is
easier for an advanced developer to read and maintain. Again, once
the structure of the method is understood, it is acceptable to break it
up into smaller methods. But don’t jump ahead until you are sure
students understand the overall structure of the method.
CLASSROOM INSTRUCTION
Test early,
test often.
HOW TO TEACH PROGRAMMING
In the above example, the first code is demoing two separate concepts
- getting values from params and saving something to the database.
The second example is demoing the single concept of saving
something to the database. After you prove this works, then replace
the hard-coded values with the params. This helps students see the
evolution of the code in testable pieces.
CLASSROOM INSTRUCTION
Don't always
demo things the
right way.
HOW TO TEACH PROGRAMMING
CLASSROOM INSTRUCTION
Stick to one
direction at a
time.
HOW TO TEACH PROGRAMMING
Don't introduce
multiple syntaxes
As an instructor, you will be tempted to show students multiple ways
of doing the same thing. In Ruby, you can write single-line blocks using
curly brackets instead of writing out the "do" and the "end":
Of course you want to teach someone the short syntax, it's way more
fun! But you have to ask yourself: Is it worth teaching an alternative
syntax given the cognitive load hit? What exactly does this syntax
offer? If it doesn't offer any new functionality for a programmer who's
just learning, then it may not be worth teaching.
This isn't to say you should never teach it. You should only teach an
alternative syntax once you feel comfortable that the student has
mastered the originally taught syntax.
CLASSROOM INSTRUCTION
Show, don't tell.
HOW TO TEACH PROGRAMMING
CLASSROOM INSTRUCTION
Distraction comes
in many forms.
HOW TO TEACH PROGRAMMING
CLASSROOM INSTRUCTION
It's not always
obvious when
someone is lost.
HOW TO TEACH PROGRAMMING
CLASSROOM INSTRUCTION
Don't let one
person speak for
everyone.
HOW TO TEACH PROGRAMMING
CLASSROOM INSTRUCTION
Understanding is
earned, not given.
HOW TO TEACH PROGRAMMING
CLASSROOM INSTRUCTION
Sometimes
silence is the
best strategy.
HOW TO TEACH PROGRAMMING
CLASSROOM INSTRUCTION
HOW TO TEACH PROGRAMMING
Conclusion
Teaching is one of the most important activities in the world. As an
individual, becoming a better teacher helps you become a better
learner, and becoming a better learner helps you become a better
teacher. As a society, teaching helps better the population, enabling
people to accomplish more than the sum of individual parts. This
goes double for programming, which has a potential reach greater
than any technology that came before it.
Today there are more resources for learning than ever before. Yet a
large portion of those resources lack the fundamental
understanding of what it means to learn and what it means to teach.
We hope that you can apply the principles described in this book to
improve your own teaching and make a difference in the world!
ACTUALIZE.CO