The Object of Java fully embraces the object-oriented paradigm by taking an objects-centric approach to presenting problem solving and programming. Readers begin with four complete chapters focusing on objects, classes and methods. The presentation of primitive data occurs in Chapter 5, ensuring the necessary prior exposure to object declaration, object instantiation, assignment, method calling, parameter passage, class diagrams and object diagrams. The topics of aggregation and inheritance occur earlier than in many other CS1 books. In order to accommodate this placement of topics, control structures are covered later than in other books. Through many semesters of class-testing this objects-centric approach, students have developed a high degree of competence with both object-oriented features and the “classic” language features such as numeric expressions and control structures.
This book focuses on the skills and disciplines of software engineering that are needed for good programming. Since specifications are critical for conveying code behavior in the object-oriented model, discussions of method preconditions and postconditions, and class invariants are used consistently to document examples and to define example classes. The Unified Modeling Language is used extensively as the specification language. The book also uses the notion of patterns to identify numerous expressions, instructions, algorithms and designs that serve to pattern program segments.
This BlueJ version integrates the use of BlueJ throughout the presentation. Explanation of BlueJ facilities for programming, testing and debugging are included along with these topical discussions. An appendix that demonstrates key BlueJ features is also included.
- Integrates the use of BlueJ throughout the book.
- Presents Java by using “objects throughout” to get students immersed in an object-oriented mindset.
- Emphasizes the Software Engineering skills necessary to be a good programmer.
- Software Engineering Hint boxes offer a collection of software developer “best practices” such as how to format a language construct for good programming style, or the way that good programmers approach a common design problem.
- Instills the importance of specification by making extensive use of preconditions and postconditions.
- Uses the Unified Modeling Language (UML) for all diagramming notation. Using UML diagrams expose students to the same notations that have now become standard in the software development industry.
- Highlights commonly used patterns in many expressions, instructions, algorithms, and designs inside rectangles so that the reader may become familiar with a commonly-required solution and learn how and when it is applicable.
- Features the importance of testing by devoting special sections to ensure that readers develop basic debugging skills, and knowledge of simple path testing and black-box testing.
- The Java Inspector boxes in each chapter provide practical “how to” ideas of what to check, review, and walk-through before completing a program and also serve as a review of important material from the chapter.
Table of Contents
1. Objects and Classes.
Objects in Software.
Anatomy of a Software Class.
The Difference Between Objects and Classes.
Edit, Compile and Run.
Programming with BlueJ.
Introduction to Software Engineering.
A Sample of Object-oriented Software Development. 2. Introduction to Java Objects.
The Method Call.
Constructing and Assigning Objects.
Putting it Together in a Java Class.
Programming by Contract.
BlueJ Debugging. 3. Introduction to Design & Implementation.
Top-down Design — Refining Algorithms.
A Second Design Example.
A GUI Software Library.
Calling Methods with Parameters.
Debugging with BlueJ and System.out.println.
Summary. 4. Methods.
The Need for a Subprogram.
Private Parameterless Methods.
Introduction to Event Handling.
A Design Example Using AView. 5. Numeric Processing.
Primitive Integer Data Types.
Differences Between Primitives and References.
Real Numbers ( float and double types).
Mixed Type Numeric Expressions.
Primitive Methods (including Math).
Constants ( final). 6. Supplier Classes.
Clients and Suppliers in Software.
Manipulating Suppliers with BlueJ.
Scope and Lifetime.
Class Interface Design Principles.
Separating Read and Write Access.
char Data Type.
ALabel (optional). 7. Logic and Selection.
The if Instruction.
Nesting if Instructions.
The switch Instruction.
Logic and Programming (optional).
Assertions (optional). 8. Inheritance.
Class Relations: contains_a and is_a.
Specialization and Extension.
Inheriting for Event Handling.
Animating by Inheriting EventTimer (optional).
Design Example with Scrollbars and Text Fields (optional).
Summary. 9. Inheritance Hierarchies and Polymorphism.
The Object Class.
Equality by Content and by Identity. 10. Repetition.
The while Loop.
Loop Design Cautions.
The do loop.
Looping and Event Handling.
Testing and Loops. 11. Containers.
Containers of Objects.
Type Safety, Casting, and instanceOf.
Sorting by Insertion. 12. Introduction to Arrays.
Keeping Indices in Bounds.
Sequential Processing with for Loops.
Treating Arrays in Aggregate.
Arrays of Objects.
Arrays and Objects.
Sorting — The Selection Sort.
Two-dimensional Arrays. 13. File Input and Output.
The Java File Class.
Input and Output.
DataInputStream and DataOutputStream.
Persistent Objects (optional).
JFileChooser (optional). 14. Recursion.
From Recursive Definition to Method.
Recursion and Repetition.
More Complicated Forms of Recursion. 15. Library Issues: Packages, Statics, Applets & Delegation.
Applications and Applets.
Event Delegation (optional).
A. Intro to Computing Systems.
What is a Computer?
Analog or Digital?
How is Data Stored?
What are Binary Numbers?
How do Computers Communicate?
Why are Computers Called “Systems”?
B. Syntax Diagrams for Java.
C. Java Operator Precedence.
D. swing, awt & aLibrary.
Background on awt and swing.
Transitioning Common Features.
JFrame instead of Awindow.
JLabel instead of Alabel.
JComponent instead of AView, AOval, ARectangle and AroundRectangle.
JComponent instead of Aline.
JComponent instead of Aimage.
Event Delegation - Handling Mouse Events.
JButton instead of Abutton.
JScrollBar instead of Ascrollbar.
TextArea instead of AtextArea.
JTextField instead of AtextField.
E. UML Notations.
F. BlueJ Summary.
Installation and Configuration.
Working with Projects.
Working with Classes.
Testing and Debugging.