xiv Introduction
programming may be so mechanical in nature that your creativity is never
tested. But all programs require problem solving at some point, and all good
programmers can solve problems.
Problem solving is hard. It’s true that a few people make it look easy—
the “naturals,” the programming world’s equivalent of a gifted athlete, like
Michael Jordan. For these select few, high-level ideas are effortlessly translated
into source code. To make a Java metaphor, it’s as if their brains execute Java
natively, while the rest of us have to run a virtual machine, interpreting as we go.
Not being a natural isn’t fatal to becoming a programmer—if it were, the
world would have few programmers. Yet I’ve seen too many worthy learners
struggle too long in frustration. In the worst cases, they give up programming
entirely, convinced that they can never be programmers, that the only good
programmers are those born with an innate gift.
Why is learning to solve programming problems so hard?
In part, it’s because problem solving is a different activity from learning
programming syntax and therefore uses a different set of mental “muscles.”
Learning programming syntax, reading programs, memorizing elements of
an application programming interface—these are mostly analytical “left brain”
activities. Writing an original program using previously learned tools and
skills is a creative “right brain” activity.
Suppose you need to remove a branch that has fallen into one of the rain
gutters on your house, but your ladder isn’t quite long enough for you to
reach the branch. You head into your garage and look for something, or a
combination of things, that will enable you to remove the branch from the
gutter. Is there some way to extend the ladder? Is there something you can
hold at the top of the ladder to grab or dislodge the branch? Maybe you could
just get on the roof from another place and get the branch from above. That’s
problem solving, and it’s a creative activity. Believe it or not, when you design
an original program, your mental process is quite similar to that of the person
figuring out how to remove the branch from the gutter and quite different
from that of a person debugging an existing
for loop.
Most programming books, though, focus their attention on syntax and
semantics. Learning the syntax and semantics of a programming language is
essential, but it’s only the first step in learning how to program in that lan-
guage. In essence, most programming books for beginners teach how to read
a program, not how to write one. Books that do focus on writing are often
effectively “cookbooks” in that they teach specific “recipes” for use in particu-
lar situations. Such books can be quite valuable as time savers, but not as a
path toward learning to write original code. Think about cookbooks in the
original sense. Although great cooks own cookbooks, no one who relies upon
cookbooks can be a great cook. A great cook understands ingredients, prepa-
ration methods, and cooking methods and knows how they can be combined
to make great meals. All a great cook needs to produce a tasty meal is a fully
stocked kitchen. In the same way, a great programmer understands language
syntax, application frameworks, algorithms, and software engineering princi-
ples and knows how they can be combined to make great programs. Give a
great programmer a list of specifications, turn him loose with a fully stocked
programming environment, and great things will happen.
www.it-ebooks.info