Objects First With Java: A Practical Introduction Using BlueJ, 3/e (Paperback)

David J. Barnes, Michael Kolling

  • 出版商: Prentice Hall
  • 出版日期: 2006-06-15
  • 定價: $1,020
  • 售價: 6.0$612
  • 語言: 英文
  • 頁數: 520
  • 裝訂: Paperback
  • ISBN: 013197629X
  • ISBN-13: 9780131976290
  • 相關分類: Java 程式語言
  • 立即出貨(限量) (庫存=1)

買這商品的人也買了...

商品描述

Description

The book has a very clear identity.

It takes a truly objects first approach to teaching problem solving using Java. These are complicated concepts so the book uses the development environment BlueJ to help the student’s understanding. BlueJ has a strong emphasis on visualization and interaction techniques, and allows the students to manipulate objects and call methods as a first exercise. BlueJ is free and freely available, and has been developed specifically for teaching.

The book is loaded with projects so that the student can really get a grip on actually solving problems; and it takes a “spiral approach”, introducing a topic in a simple context early on, then revisiting it later in the book to deepen understanding. It also comes with a CD containing JDK, BlueJ, a BlueJ tutorial and code for all the projects. The website contains style guide for all examples, PowerPoints for lecturers and also a Solutions Manual. 

 

Table of Contents

Foreword

Preface to the instructor

List of projects discussed in detail in this book

Acknowledgements

 

Part 1 Foundations of object orientation

 

Chapter 1 Objects and classes

1.1 Objects and classes

1.2 Creating objects

1.3 Calling methods

1.4 Parameters

1.5 Data types

1.6 Multiple instances

1.7 State

1.8 What is in an object?

1.9 Object interaction

1.10 Source code

1.11 Another example

1.12 Return values

1.13 Objects as parameters

1.14 Summary

 

Chapter 2 Understanding class definitions

2.1 Ticket machines

2.1.1 Exploring the behavior of a naïve ticket machine

2.2 Examining a class definition

2.3 Fields, constructors, and methods

2.3.1 Fields

2.3.2 Constructors

2.4 Passing data via parameters

2.5 Assignment

2.6 Accessor methods  

2.7 Mutator methods

2.8 Printing from methods  

2.9 Summary of the naïve ticket machine

2.10 Reflecting on the design of the ticket machine

2.11 Making choices: the conditional statement

2.12 A further conditional-statement example

2.13 Local variables

2.14 Fields, parameters, and local variables

2.15 Summary of the better ticket machine

2.16 Self-review exercises

2.17 Reviewing a familiar example

2.18 Summary

 

Chapter 3 Object interaction

3.1 The clock example

3.2 Abstraction and modularization

3.3 Abstraction in software

3.4 Modularization in the clock example

3.5 Implementing the clock display

3.6 Class diagrams versus object diagrams

3.7 Primitive types and object types

3.8 The ClockDisplay source code

3.8.1 Class NumberDisplay

3.8.2 String concatenation

3.8.3 The modulo operator

3.8.4 Class ClockDisplay

3.9 Objects creating objects

3.10 Multiple constructors

3.11 Method calls

3.11.1 Internal method calls

3.11.2 External method calls

3.11.3 Summary of the clock display

3.12 Another example of object interaction

3.12.1 The mail system example

3.12.2 The this keyword

3.13 Using a debugger

3.13.1 Setting breakpoints

3.13.2 Single stepping 

3.13.3 Stepping into methods

3.14 Method calling revisited

3.15 Summary

 

Chapter 4 Grouping objects

4.1 Grouping objects in flexible-size collections

4.2 A personal notebook

4.3 A first look at library classes

4.3.1 An example of using a library 

4.4 Object structures with collections

4.5 Generic classes

4.6 Numbering within collections

4.7 Removing an item from a collection

4.8 Processing a whole collection

4.8.1 The for-each loop

4.8.2 The while loop

4.8.3 Iterating over a collection

4.8.4 Index access versus iterators

4.9 Summary of the notebook example

4.10 Another example: an auction system

4.10.1 The Lot class

4.10.2 The Auction class

4.10.3 Anonymous objects

4.10.4 Using collections

4.11 Flexible collection summary

4.12 Fixed-size collections

4.12.1 A log-file analyzer

4.12.2 Declaring array variables

4.12.3 Creating array objects

4.12.4 Using array objects

4.12.5 Analyzing the log file

4.12.6 The for loop

4.13 Summary

 

Chapter 5 More sophisticated behavior

5.1 Documentation for library classes

5.2 The TechSupport system

5.2.1 Exploring the TechSupport system

5.2.2 Reading the code

5.3 Reading class documentation

5.3.1 Interfaces versus implementation

5.3.2 Using library-class methods

5.3.3 Checking string equality

5.4 Adding random behavior

5.4.1 The Random class

5.4.2 Random numbers with limited range

5.4.3 Generating random responses

5.4.4 Reading documentation for parameterized classes

5.5 Packages and import

5.6 Using maps for associations

5.6.1 The concept of a map

5.6.2 Using a HashMap

5.6.3 Using a map for the TechSupport system

5.7 Using sets

5.8 Dividing strings

5.9 Finishing the TechSupport system

5.10 Writing class documentation

5.10.1 Using javadoc in BlueJ

5.10.2 Elements of class documentation

5.11 Public versus private

5.11.1 Information hiding

5.11.2 Private methods and public fields

5.12 Learning about classes from their interfaces

5.13 Class variables and constants

5.13.1 The static key word

5.13.2 Constants

5.14 Summary

 

Chapter 6 Well-behaved objects

6.1 Introduction

6.2 Testing and debugging

6.3 Unit testing within BlueJ

6.3.1 Using inspectors

6.3.2 Positive versus negative testing

6.4 Test automation

6.4.1 Regression testing

6.4.2 Automated checking of test results

6.4.3 Recording a test

6.4.4 Fixtures

6.5 Modularization and interfaces

6.6 A debugging scenario

6.7 Commenting and style

6.8 Manual walkthroughs

6.8.1 A high-level walkthrough

6.8.2 Checking state with a walkthrough

6.8.3 Verbal walkthroughs

6.9 Print statements

6.9.1 Turning debugging information on or off

6.10 Choosing a test strategy

6.11 Debuggers

6.12 Putting the techniques into practice

6.13 Summary

 

Chapter 7 Designing classes

7.1 Introduction

7.2 The world-of-zuul game example

7.3 Introduction to coupling and cohesion

7.4 Code duplication

7.5 Making extensions

7.5.1 The task

7.5.2 Finding the relevant source code

7.6 Coupling

7.6.1 Using encapsulation to reduce coupling

7.7 Responsibility-driven design

7.7.1 Responsibilities and coupling

7.8 Localizing change

7.9 Implicit coupling

7.10 Thinking ahead

7.11 Cohesion

7.11.1 Cohesion of methods

7.11.2 Cohesion of classes

7.11.3 Cohesion for readability

7.11.4 Cohesion for reuse

7.12 Refactoring

7.12.1 Refactoring and testing

7.12.2 An example of refactoring

7.13 Refactoring for language independence

7.13.1 Enumerated types

7.13.2 Further decoupling of the command interface

7.14 Design guidelines

7.15 Executing without BlueJ

7.15.1 Class methods

7.15.2 The main method

7.15.3 Limitations of class methods

7.16 Summary

 

Part 2 Application structures

 

Chapter 8 Improving structure with inheritance

8.1 The DoME example

8.1.1 DoME classes and objects

8.1.2 DoME source code

8.1.3 Discussion of the DoME application

8.2 Using inheritance

8.3 Inheritance hierarchies

8.4 Inheritance in Java

8.4.1 Inheritance and access rights

8.4.2 Inheritance and initialization

8.5 DoME: adding other item types

8.6 Advantages of inheritance (so far)

8.7 Subtyping

8.7.1 Subclasses and subtypes

8.7.2 Subtyping and assignment

8.7.3 Subtyping and parameter passing

8.7.4 Polymorphic variables

8.7.5 Casting

8.8 The Object class

8.9 Autoboxing and Wrapper classes

8.10 The collection hierarchy

8.11 Summary

 

Chapter 9 More about inheritance

9.1 The problem: DoME’s print method

9.2 Static type and dynamic type

9.2.1 Calling print from Database

9.3 Overriding

9.4 Dynamic method lookup

9.5 Super call in methods

9.6 Method polymorphism

9.7 Object methods: toString

9.8 Protected access

9.9 Another example of inheritance with overriding

9.10 Summary

 

Chapter 10 Further abstraction techniques

10.1 Simulations

10.2 The foxes-and-rabbits simulation

10.2.1 The foxes-and-rabbits project

10.2.2 The Rabbit class

10.2.3 The Fox class

10.2.4 The Simulator class: setup

10.2.5 The Simulator class: a simulation step

10.2.6 Taking steps to improve the simulation

10.3 Abstract classes

10.3.1 The Animal superclass

10.3.2 Abstract methods

10.3.3 Abstract classes

10.4 More abstract methods

10.5 Multiple inheritance

10.5.1 An Actor class

10.5.2 Flexibility through abstraction

10.5.3 Selective drawing

10.5.4 Drawable actors: multiple inheritance

10.6 Interfaces

10.6.1 An Actor interface

10.6.2 Multiple inheritance of interfaces

10.6.3 Interfaces as types

10.6.4 Interfaces as specifications

10.6.5 A further example of interfaces

10.6.6 Abstract class or interface?

10.7 Summary of inheritance

10.8 Summary

 

Chapter 11 Building graphical user interfaces

11.1 Introduction

11.2 Components, layout, and event handling

11.3 AWT and Swing

11.4 The ImageViewer example

11.4.1 First experiments: creating a frame

11.4.2 Adding simple components

11.4.3 Adding menus

11.4.4 Event handling

11.4.5 Centralized receipt of events

11.4.6 Inner classes

11.4.7 Anonymous inner classes

11.5 ImageViewer 1.0: the first complete version

11.5.1 Image-processing classes

11.5.2 Adding the image

11.5.3 Layout

11.5.4 Nested containers

11.5.5 Image filters

11.5.6 Dialogs

11.6 ImageViewer 2.0: improving program structure

11.7 ImageViewer 3.0: more interface components

11.7.1 Buttons

11.7.2 Borders

11.8 Further extensions

11.9 Another example: SoundPlayer338

11.10 Summary

 

Chapter 12 Handling errors

12.1 The address-book project

12.2 Defensive programming

12.2.1 Client–server interaction

12.2.2 Argument checking

12.3 Server error reporting

12.3.1 Notifying the user

12.3.2 Notifying the client object

12.4 Exception-throwing principles

12.4.1 Throwing an exception

12.4.2 Exception classes

12.4.3 The effect of an exception

12.4.4 Unchecked exceptions

12.4.5 Preventing object creation

12.5 Exception handling

12.5.1 Checked exceptions: the throws clause

12.5.2 Catching exceptions: the try statement

12.5.3 Throwing and catching multiple exceptions

12.5.4 Propagating an exception

12.5.5 The finally clause

12.6 Defining new exception classes

12.7 Using assertions

12.7.1 Internal consistency checks

12.7.2 The assert statement

12.7.3 Guidelines for using assertions

12.7.4 Assertions and the BlueJ unit testing framework

12.8 Error recovery and avoidance

12.8.1 Error recovery

12.8.2 Error avoidance

12.9 Case study: text input/output

12.9.1 Readers, writers, and streams

12.9.2 The address-book-io project

12.9.3 Text output with FileWriter

12.9.4 Text input with FileReader

12.9.5 Scanner: reading input from the terminal

12.9.6 Object serialization

12.10 Summary

 

Chapter 13 Designing applications

13.1 Analysis and design

13.1.1 The verb/noun method

13.1.2 The cinema booking example

13.1.3 Discovering classes

13.1.4 Using CRC cards

13.1.5 Scenarios

13.2 Class design

13.2.1 Designing class interfaces

13.2.2 User interface design

13.3 Documentation

13.4 Cooperation

13.5 Prototyping

13.6 Software growth

13.6.1 Waterfall model

13.6.2 Iterative development

13.7 Using design patterns

13.7.1 Structure of a pattern

13.7.2 Decorator

13.7.3 Singleton

13.7.4 Factory method

13.7.5 Observer

13.7.6 Pattern summary

13.8 Summary

 

Chapter 14 A case study

14.1 The case study

14.1.1 The problem description

14.2 Analysis and design

14.2.1 Discovering classes

14.2.2 Using CRC cards

14.2.3 Scenarios

14.3 Class design

14.3.1 Designing class interfaces

14.3.2 Collaborators

14.3.3 The outline implementation

14.3.4 Testing

14.3.5 Some remaining issues

14.4 Iterative development

14.4.1 Development steps

14.4.2 A first stage

14.4.3 Testing the first stage

14.4.4 A later stage of development

14.4.5 Further ideas for development

14.4.6 Reuse

14.5 Another example

14.6 Taking things further

 

Appendices

A Working with a BlueJ project

B Java data types

C Java control structures

D Operators

E Running Java without BlueJ

F Configuring BlueJ

G Using the debugger

H JUnit unit-testing tools

I Javadoc

J Program style guide

K Important library classes

 

Index

商品描述(中文翻譯)

這本書具有非常明確的特色。它採用了真正以物件為先的方式來教授使用Java解決問題的方法。這些概念相當複雜,因此本書使用開發環境BlueJ來幫助學生理解。BlueJ強調可視化和互動技術,讓學生可以首先操作物件和呼叫方法。BlueJ是免費且可自由使用的,並且專為教學而開發。

這本書充滿了各種專案,讓學生真正掌握解決問題的能力;並且採用了「螺旋式教學法」,在書的早期以簡單的情境介紹一個主題,然後在書的後期重新討論以加深理解。書附帶一張光碟,其中包含JDK、BlueJ、BlueJ教程以及所有專案的程式碼。網站上還提供了所有範例的樣式指南、講師用的PowerPoints以及解答手冊。

目錄:
前言
給教師的前言
本書詳細討論的專案列表
致謝
第一部分 物件導向的基礎
第一章 物件和類別
1.1 物件和類別
1.2 創建物件
1.3 呼叫方法
1.4 參數
1.5 資料型別
1.6 多個實例
1.7 狀態
1.8 物件的內容
1.9 物件互動
1.10 原始碼
1.11 另一個範例
1.12 回傳值
1.13 物件作為參數
1.14 總結

第二章 理解類別定義
2.1 售票機
2.1.1 探索一個單純的售票機的行為
2.2 檢視類別定義
2.3 欄位、建構子和方法
2.3.1 欄位
2.3.2 建構子
2.4 透過參數傳遞資料
2.5 指派
2.6 存取方法
2.7 修改方法
2.8 從方法中列印
2.9 單純的售票機總結
2.10 反思售票機的設計
2.11 做出選擇:條件陳述式
2.12 進一步的條件陳述式範例
2.13 區域變數
2.14 欄位、參數和區域變數
2.15 更好的售票機總結
2.16 自我檢討練習
2.17 回顧一個熟悉的範例
2.18 總結

第三章 物件互動
3.1 時鐘範例
3.2 抽象和模組化
3.3 軟體中的抽象
3.4 時鐘範例中的模組化
3.5 實作時鐘顯示
3.6 類別圖與物件圖
3.7 原始型別和物件型別
3.8 時鐘顯示的原始碼
3.8.1 類別NumberDisplay
3.8.2 字串串接
3.8.3 取餘數運算子
3.8.4 類別ClockDisplay
3.9 物件創建物件
3.10 多個建構子
3.11 方法呼叫
3.11.1 內部方法呼叫
3.11.2 外部方法呼叫
3.11.3 時鐘顯示總結