O'Reilly logo

Learning Java Through Games by Lubomir Stanchev

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Preface
Java is a programming language that was originally developed in 1995 by James Gosling
at Sun Microsystems, which later became part of Oracle Corporation. Since then, seven
major revisions of the language have been introduced and thousands of textbooks that
describe every nitty-gritty detail of the language have been published. At the same time,
many computer science departments of universities throughout the world have adopted
Java as their introductory programming language. The reason is that Java is a strongly
typed language that is easy to learn and apply. The language also helps identify erroneous
code early in the coding process. The popularity of Java as an introductory programming
language has led to the publication of thousands more textbooks that use the Java language
to introduce the reader to basic programming principles.
This textbook stands somewhere in the middle. It tries to cover as much material as
possible from the latest Java standard (Java SE 7). At the same time, it is a textbook that is
aimed at readers with no previous programming background. It not only teaches how to use
the different features of the language, but it also teaches the reader how to program. What
makes this textbook unique is its application-motivated approach. The textbook contains
a plethora of games. Almost all Java constructs are introduced as a necessity to implement
different game features. Most chapters start with a description of a game. Next, different
Java constructs that can be used to implement the features of the game are introduced
on need-to-use bases. The textbook reads similar to a mystery novel. The reader must
read through the whole chapter in order to understand all the features that are needed to
implement the game.
The second strength of the textbook is that, unlike most existing Java textbooks, it
spends a lot of time preaching good software development practices. Martin Fowler once
famously wrote, “Any fool can write code that a computer can understand. Good program-
mers write code that humans can understand.” This textbook tries to teach the reader not
only how to write code that works, but also how to follow good software practices. All
sample programs in the textbook strive to achieve low cohesion and high coupling, which
is the marksmanship of well-designed code. Many programs in the textbook are refactored
multiple times in order to achieve code that is easy to understand, reuse, and maintain.
The author of this textbook firmly believes that even novice programmers should be taught
good programming practices. The reason is that if one does not develop good programming
habits from the outset, then it is more difficult to develop them afterwards.
The textbook is split in two parts. Chapters 1–7 cover basic programming techniques,
such as conditional statements, loops, methods, arrays, and classes. Chapters 8–15 cover
more advanced topics, such as class inheritance, recursions, sorting algorithms, GUI pro-
gramming, exception handling, files, and applets. The textbook is designed to be either
used by a reader who wants to learn the language on their own or as part of a two-course
introduction to programming sequence. Most chapters build on each other and the best way
to read the textbook is from start to finish. A dependency diagram of the chapters is shown
in Figure 0.1.
Chapter 1 introduces basic computer concepts, such as main memory, hard disk, oper-
ating system, and binary numbers. It should be read by readers that have little computer
xiii

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required