This text is intended for a basic, pre-AP high school course in programming and problem solving with Java. We present several major aspects of computing, some in stand-alone lessons and others spread across several lessons:
1. Programming Basics. This deals with the basic ideas of problem solving with computers, including primitive data types, control structures, methods, and algorithm analysis.
2. Object-Oriented Programming. OOP is today's dominant programming paradigm. All the essentials of this subject are covered.
3. Software Development Life Cycle. Rather than isolate software development techniques in one or two lessons, the book deals with them throughout in the context of numerous Case Studies.
4. Graphical User Interfaces and Event-Driven Programming. Many books at this level restrict themselves to character-based terminal I/O. The reason is simple. Graphical user interfaces and event-driven programming are usually considered too complex for beginning students. In this book, we circumvent the complexity barrier and show how to develop programs with graphical user interfaces with the same ease as their terminal-based counterparts.
5. Web Basics. The programming of Web pages with HTML and applets is introduced.
Focus on Fundamental Computer Science Topics
There seem to be two types of introductory Java textbooks. The first emphasizes basic problem solving
and programming techniques, and the second emphasizes language features. This book takes the former approach and
introduces Java features as they are needed to support programming concepts. In this way, all the AP required syntax
is covered without allowing the book to be syntax driven. Some additional and more advanced Java features, not
part of the AP requirement, are covered in Lessons 12-15 and Appendix B.
Methods and Objects, Early or Late?
Occasionally, people argue about whether methods and objects should be introduced early or late in the first course. In Java, even the simplest program involves both, so the problem really becomes one of how to introduce these concepts in a clear and meaningful manner from the outset. Starting with the first program, we show how to instantiate and send messages to objects. The book's early lessons (2 through 4) focus on the use of objects, arithmetic expressions, control constructs, and algorithms in the context of short, simple programs. As programs become more complex, it becomes advantageous to decompose them into cooperating components. With this end in mind, Lesson 5 shows how to develop systems of cooperating classes and methods. Thus, we take a pragmatic rather than an ideological approach to the question of when to introduce methods and objects with complete confidence that students will master both by the end of the course.
Input and Output Styles
The AP requires simple standard terminal output but no input. A realistic first course will need some form of input, if only from the keyboard. We provide easy to use open source toolkits for terminal I/O, GUI-based I/O, and simple graphics. From the perspective of the AP requirements, however, all this material on I/O is optional and should be fitted into the course only as time allows. It is the authors' experience that I/O adds interest without being overly burdensome; however, on some programming projects instructors may reasonably prefer to provide all or most of the interface-related code. In general, students and instructors are free to choose the I/O style that suits their needs and interests.
Lessons 2-6 use terminal I/O and demonstrate standard terminal-based interface techniques such as how to write query-based and menu-driven programs. After that, instructors have the choice of asking students to write terminal-based or GUI-based programs. Terminal input is based on the TerminalIO package, which is an extension of the standard stream classes. Later in the book, we show how to use these standard stream classes directly.
The early lessons also provide the option of using a TurtleGraphics package that allows students to draw images without worrying about Java's complex painting mechanisms. Again, later in the book, we take students through the significant details. The book uses turtle graphics because they provide an engaging context for illustrating the use of objects.
GUIs are usually considered beyond the scope of an introductory Java course. This book uses a package called BreezySwing that allows students to develop GUIs with the same ease as terminal-based interfaces. BreezySwing extends Java's Abstract Windowing Toolkit (AWT) and Swing in a manner that hides most of the underlying complexities from the beginning programmer. Using BreezySwing, students write event-driven programs with realistic graphical user interfaces, but without becoming entangled in numerous and difficult details.
All of the I/O packages are available on the CD accompanying this book and from the Web site http://www.wlu.edu/~lambertk/hsjava/. The Web site is the preferred source because it contains the latest release of BreezySwing together with online documentation and other related materials.
Case Studies, the Software Life Cycle, and Comments
The book contains numerous Case Studies. These are complete Java programs ranging from the simple to the substantial. To emphasize the importance and usefulness of the software development life cycle, Case Studies are presented in the framework of a user request followed by analysis, design, and implementation, with well-defined tasks performed at each stage. Some Case Studies are carried through several lessons or extended in end-of-lesson programming projects.
Programming consists of more than just writing code, so we encourage students to submit an analysis and design as part of major programming assignments. We also believe that code should be properly commented, and for purposes of illustration, we include comments in most of the listings in the book.
The book contains several different types of exercises. Most sections end with self-test questions that reinforce the reading by asking basic questions about the material in the section. Each lesson ends with a set of review exercises. All lessons but the first one include programming projects of varying degrees of difficulty. Finally, each lesson has a critical thinking exercise that allows the student to reflect on a major topic covered in the lesson.
Scattered throughout the book are short essays called Special Features. These present historical and social aspects of computing, including computer ethics and security.
We have tried to produce a high quality text, but should you encounter any errors, please report them to email@example.com. A listing of errata, should they exist, and other information about the book will be posted on the Web site http://www.wlu.edu/~lambertk/hsjava/.
Kenneth A. Lambert