PREFACE
To properly introduce students to computing, we believe that the first computing course should accomplish two goals:
- Introduce students to the breadth of the discipline of computing, so that they come to understand the role of programming in the broader context of computing.
- Introduce the methodologies and techniques of computer programming using a modern programming language, providing a (fairly) complete introduction to the language.
The aim of this textbook is to accomplish both of these goals, the latter using Java.
THE BREADTH OF COMPUTING
The first goal grows out of an important theme of curriculum recommendations of the Association of Computing Machinery (ACM) that an introductory course in computing should introduce the various knowledge areas of the discipline:
- Architecture
- Artificial Intelligence and Robotics
- Database and Information Retrieval
- Human-Computer Communication
- Numerical and Symbolic Computation
- Operating Systems
- Programming Languages
- Software Methodology and Engineering
- Social, Ethical, and Professional Context
To accomplish the first goal, we include the Part of the Picture sections, several of which are written by experts in various areas of computing. These sections introduce these areas, trying to capture the spirit of these curriculum guidelines in a natural, unobtrusive way. They have been carefully selected to provide an overview of the discipline of computer science and to provide a foundation for further study in theoretical and/or applied computer science. Titles include:
What is Computer Science? The History of Computing
Introduction to Computer Systems
Ethics and Issues (by Anne Marchant)
Data Representation
Computability Theory
Boolean Logic and Digital Design
Computer Architecture (by William Stallings)
Introduction to Algorithm Analysis
Numerical Methods
Database Systems (by Keith VanderLinden)
Artificial Intelligence (by Keith VanderLinden)
The TCP/IP Communications Architecture (by William Stallings)
Data Structures
A solid base is thus established for later courses in theoretical and/or applied computer science.
CS1 & CS2
To help with accomplishing the second goal, a sequel to this book is planned. This first text will introduce the essential ideas of Java programming and the breadth of the discipline of computing, making it ideal for a one-semester course in computer science. The second text will be available in two flavors:
- C++: An Introduction to Data Structures (already available) for those who wish to change to C++ in the CS2 course
- Java: An Introduction to Data Structures, for those who wish to continue with the same language in the CS2 course.
Both will introduce elementary data structures and their implementations as well as other topics that are traditionally taught in the second course including sorting, searching, and algorithm analysis. Together, this text followed by one of those listed above will provide a solid introduction to the discipline of computer science.
PEDAGOGICAL APPROACHES
A popular feature of other texts we have written is to use a problem at the beginning of each chapter to introduce the subject of that chapter (e.g., methods, control, structures, inheritance, and so on). Following this example, the concepts and theory behind those ideas are explored, and other examples given to reinforce the ideas. In this approach, students see the practice of a new topic before the abstract definitions and theory that underlie that topic, providing them with a framework in which those abstract aspects can be organized and understood.
We also continue the "use it, then build it" approach with respect to the more difficult topics for beginning programmerse.g., methods, classes, and graphical programminga kind of spiral approach that revisits topics in increasingly greater detail. For example, to show students how methods are used, predefined methods are used in Chapters 2 and 3 as components of expressions. Once students have experience using (predefined) methods, Chapters 4 and 5 teach them to build simple methods, and subsequent chapters show how to build increasingly sophisticated methods. Similarly, students are introduced to classes in Chapter 1, with more practice following in subsequent chapters. Once students are firmly grounded in building and using classes, they explore inheritance and polymorphism in detail in Chapter 11. Through this "use it, then build it" approach, students receive extensive exposure to the concepts underlying each of these constructs, reducing the learning curve when the time comes to actually build those constructs.
We have added chapter objectives and expanded the end-of-chapter features to include a chapter summary that contains key terms and concepts along with documentation for some of the key Java classes used in the chapter. These augment the popular programming pointers used in others of our texts to provide students with good program design and style guidelines as well as warn of potential pitfalls.
This text also exposes the introductory student to object-oriented programming early and consistently. We have included many examples of developing a program to solve a problem, all of which use a design strategy that we have termed object-centered design (OCD). This gives the students a problem-solving methodology to follow. The example programs all model good documentation techniques and habits to help students learn the importance of writing maintainable programs.
New to this text are the Graphical/Internet Java sections designed to introduce students to graphics programming. The approach here also is a spiral one. Chapter 1 contains a simple greeting applet, Chapter 2 gives a simple GUI greeting application. In each chapter thereafter, the applet and/or GUI application being built is increasingly more sophisticatedfor example, event-driven programming is introduced in Chapter 7 and using threads in animations in Chapter 13. The examples all make use of Java's Swing components. There is one such section per chapter, but if desired, they can be passed over in a first look at "text-based" Java programming and then covered later.
CONTENT AND ORGANIZATION
- The background and introductory information has been consolidated into a Chapter 0, which instructors can cover in lecture, assign as reading, or omit as preferred. The presentation of computing history has been updated with more events and photos in a timeline of important people and events in the history of computing.
- Chapter 1 introduces Java applications and applets with a very simple example. It also introduces the design methodology, called object-centered design, a four-phase graduated methodology that novice programmers can use as an aid in designing software solutions. This methodology is used consistently to solve the problems presented throughout the remainder of the text. As the reader learns new language constructs in subsequent chapters, the methodology is expanded to incorporate these new constructsfor example, use methods to create new operations not provided in the language and classes to create new types for objects needed in a problem. A superb new presentation of the major ethical issues in computing has been contributed by Ann Marchant of George Mason University.
- Chapters 2 and 3 introduce the fundamental ideas of types, operations and expressions, including predefined methods.
- Chapters 4 and 5 introduce reusability, using methods as a way to encapsulate program statements that can be reused. Object-centered design is expanded (phase II) to incorporate this new idea.
- Chapter 6 builds on the ideas introduced in Chapters 1-3, presenting classes and instance methods. Object-centered design is again expanded (phase III) to incorporate this new idea. Our colleague Keith VanderLinden has contributed a Part of the Picture section on artificial intelligence for this chapter.
- Chapters 7 and 8 expand on the introduction in Chapter 5 to control structures for selection and repetition. These control structures are used to build increasingly sophisticated functions. Recursion is also introduced in Chapter 8. These chapters also include a concise but thorough summary of computer architecture contributed by William Stallings.
- Chapter 9 introduced arrays and illustrates their use with several examples. The important topics of sorting and searching are also introduced as well as multidimensional arrays. A Class Matrix is constructed in detail.
- Chapter 10 introduces file input and output, along with the important concept of exceptions in Java. Our colleague Keith VanderLinden kindly contributed a Part of the Picture section on databases.
- Chapter 11 builds on earlier chapters, reinforcing the idea of reusability through class extension and inheritance, showing how one class can reuse the work of another. Object-centered design is expanded a final time (phase IV), resulting in object-oriented design.
- Chapter 12 introduces Java's ArrayList and LinkedList classes and uses them to implement stacks and queues. A modified structure is used in a polygon-sketching GUI. Binary search trees are also introduced in this chapter.
- Chapter 13 introduces the more advanced capabilities of Java: multithreading and client-server networking. An animation of moon phases demonstrates the use of threads in graphical programming.
STANDARD JAVA
We have used the specification of Java 2 published by Sun as our primary reference in preparing this text. This language specification along with the API documentation can be found at Sun's website (java.sun.com/docs).
OTHER FEATURES
- The websites cs.calvin.edu/books/java/intro/1e/ will be maintained by the authors and will include corrections, additions, reference materials, Internet exercises, and other supplementary materials. These and additional items, including an on-line study guide, will also be available at the Companion Website (www.prenhall.com/adams) for this text.
- Chapter objectives and summaries consisting of key words and notes help the student identify the main concepts of each chapter
- Programming Pointers at chapter ends highlight important points, including:
- Proper techniques of design and style
- Common programming pitfalls
- Approximately 450 Quick Quiz questions provide a quick check of understanding the material being studied. The answers to all of the quick-quiz questions are given in the text.
- Nearly 500 written exercises extend the quick quizzes and apply the material of the preceding section(s). No answers for these are provided in the text and they can therefore be used for written assignments
- The Programming Problems sections at the end of the chapters contain more than 300 programming problems drawn from a wide range of application areas.
- An attractive new design makes the text attractive and readable.
- Color is used to emphasize and highlight important features.
- Boxed displays make it easy to find descriptions of the basic Java statements and constructs.
- Icons serve as markers to point out key parts of the text.
SUPPLEMENTARY MATERIALS
- Websites at www.prenhall.com/adams and cs.calvin.edu/books/java/intro/1e will contain source code, color screen snaps of graphical output produced by programs, an online study guide, links to important sites that correspond to items in the text, and many other supplementary materials.
- The CD-ROM accompanying this text also contains most of the above items along with a Java compiler (JBuilder), an HTML reference guide, and a lab manual containing laboratory exercises and projects coordinated with the text.
- The Instructor's Resource CD-ROM contains the preceding materials along with PowerPoint slides along with solutions to the exercises and many of the programming problems.
- A lab manual contains laboratory exercises and projects coordinated with the text.
SUGGESTIONS
The authors welcome feedback, both positive and negative. Comments on features of the text that work especially well as well as those that could be improved will aid us in the preparation of subsequent editions. We would also appreciate being notified of errors. Such comments can be directed to any of the authors at [email protected], [email protected], or [email protected] via the Internet, or at the following address:
Department of Computer Science
Calvin College
3201 Burton SE
Grand Rapids, MI 49546
USA
ACKNOWLEDGMENTS
We express our sincere appreciation to all who helped in any way in the preparation of this text, especially Alan Apt, Scott Disanno, Toni Holm, Nick Murray, Heather Scott, Ana Terry, and Jake Warde. We also appreciate the valuable comments and suggestions made by the following reviewers: Donald Cooley (Utah State Univ.), Mike Davarpanah (Cal Poly Pomona), Brian Durney (Brigham Young Univ., Hawaii), Henry Ettinger (Rochester Institute of Technology), Pedro Larios (Metrowerks), Ralph Sanford (Bristol Community College), and Pam Vermeer (Washington and Lee Univ.) We also thank Ann Marchant, William Stallings, and Keith VanderLinden for contributing Part of the Picture sections. And, of course, we must also thank our families-Barb, Roy, and Ian; Shar, Jeff, Jim, Greg, Julie, Joshua, Derek, Tom, Joni, and Abigail; Dawn, Rebecca, Megan, and Sara- for encouraging and supporting us, and for being understanding and patient when we slighted their needs and wants. Above all, we give thanks to God for giving us the opportunity, ability, and stamina to prepare this text.
JOEL ADAMS
LARRY NYHOFF
JEFFREY NYHOFF