Slide 0

5 Tips
to help
you tackle
programming
1
by Cay Horstmann
First Do It By Hand
If you can’t do it by hand, you
can’t tell a computer how to do it.
Before doing any work on the
computer, get some sheets of
paper and a pencil. Choose an
example of your problem—not
too hard, but not trivial either.
Solve it by hand. The minutes
spent on this step will save you
hours later.
1

Slide 1

2
Solve a Simpler
Problem First
When you face a complex problem,
it is easy to get discouraged. A
great strategy is to solve a simpler
problem first. Ask yourself what
is the absolutely simplest part of
the task that is helpful for the end
result. Start from there. Then add
another feature, and another.
With some practice, you can
design a plan that builds
up a complete solution as
a manageable sequence of
intermediate steps. That way, you
will experience sweet success at
each step, and you will have the
energy to reach a final conclusion.
2

Slide 2

3
Use Physical Objects
Sometimes, you are given a problem
and have no idea how to solve it. You
may know that a loop is required, or
that you need to swap elements, but
that’s not enough to design a solution.
Try acting out your problem with
physical objects. Coins, playing cards,
scrabble tiles, or tin soldiers work great.
Suppose you need to arrange values in
a certain way. Try moving the objects
around until you discover a systematic
way that always achieves the correct
result. Then you are ready to write
pseudocode and code.
3

Slide 3

4
Try Some Code
Your textbook and the library
documentation can be confusing at times.
A quick way of making sense out of the
documentation is to try something out.
For example, suppose you suspect that
the “replace” function can be useful but
you don’t really know what it replaces
or how you can get the result. Make a
string, replace “i” with “x”, and watch what
happens. Many development environments
have a way of running quick experiments
without writing a full-fledged program.
4

Slide 4

5
Write More Code
Programming is not a spectator sport.
Understanding the concepts only gets
you so far. You need to have your hands
on the ball to gain experience. You can
start out with worked examples that
walk you through a solution, a step at
a time. Then set yourself a challenge
to push the example a bit further, and
implement your enhancement.
That way, you build upon something that
works, and you gain valuable experience
reading and writing code.
5

Slide 5