thinkapjava.pdf

(1294 KB) Pobierz
354418885 UNPDF
How to Think Like a Computer Scientist
Java Version
ii
354418885.001.png
How to Think Like a Computer Scientist
Java Version
Allen B. Downey
Version 4.1
April 23, 2008
Copyright c 2003, 2008 Allen Downey.
Permission is granted to copy, distribute, and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.1 or any later ver-
sion published by the Free Software Foundation; with Invariant Sections being
“Preface”, with no Front-Cover Texts, and with no Back-Cover Texts. A copy
of the license is included in the appendix entitled “GNU Free Documentation
License.”
The GNU Free Documentation License is available from www.gnu.org or by
writing to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307, USA.
The original form of this book is L A T E X source code. Compiling this L A T E X
source has the eect of generating a device-independent representation of the
book, which can be converted to other formats and printed.
The L A T E X source for this book is available from
thinkapjava.com
This book was typeset using L A T E X. The illustrations were drawn in xg. All
of these are free, open-source programs.
Preface
“As we enjoy great Advantages from the Inventions of others, we
should be glad of an Opportunity to serve others by any Invention
of ours, and this we should do freely and generously.”
—Benjamin Franklin, quoted in Benjamin Franklin by Edmund S.
Morgan.
Why I wrote this book
This is the fourth edition of a book I started writing in 1999, when I was teaching
at Colby College. I had taught an introductory computer science class using the
Java programming language, but I had not found a textbook I was happy with.
For one thing, they were all too big! There was no way my students would read
800 pages of dense, technical material, even if I wanted them to. And I didn’t
want them to. Most of the material was too specic—details about Java and its
libraries that would be obsolete by the end of the semester, and that obscured
the material I really wanted to get to.
The other problem I found was that the introduction to object oriented pro-
gramming was too abrupt. Many students who were otherwise doing well just
hit a wall when we got to objects, whether we did it at the beginning, middle
or end.
So I started writing. I wrote a chapter a day for 13 days, and on the 14th day I
edited. Then I sent it to be photocopied and bound. When I handed it out on
the rst day of class, I told the students that they would be expected to read
one chapter a week. In other words, they would read it seven times slower than
I wrote it.
The philosophy behind it
Here are some of the ideas that made the book the way it is:
•Vocabulary is important. Students need to be able to talk about programs
and understand what I am saying. I tried to introduce the minimum
number of terms, to dene them carefully when they are rst used, and
Zgłoś jeśli naruszono regulamin