Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .

I The Varieties of Data
1 Primitive Forms of Data
2 Classes
2.1 Finger Exercises on Plain Classes
2.2 Designing Classes
3 Class References, Object Containment
3.1 Finger Exercises on Object Containment
3.2 Designing Classes that Refer to Classes
4 Unions of Classes
4.1 Types vs Classes
4.2 Finger Exercises on Unions
4.3 Designing Unions of Classes
5 Unions, Self-References and Mutual References
5.1 Containment in Unions, Part 1
5.2 Containment in Unions, Part 2
5.3 Finger Exercises on Containment in Unions
6 Designing Class Hierarchies
6.1 Exercises
6.2 Case Study: Fighting UFOs
Intermezzo 1: Classes and Interfaces
Vocabulary and Grammar
Meaning
Syntax Errors, Type Errors, and Run-time Errors
8 Expressions 1, Computing with Primitive Types
9 Expressions 2, Method Calls
10 Methods for Classes
10.1 Designs through Templates
10.2 Finger Exercises
10.3 Designing Methods for Classes
10.4 Conditional Computations
10.5 Composing methods
11 Methods and Object Containment
11.1 Finger Exercises
11.2 Designing Methods for Classes that Contain Classes
12 Methods and Unions of Classes
12.1 Example: Plain Geometric Shapes
12.2 Signaling Errors
13 Types, Classes, and How Method Calls Compute
13.1 Method Dispatch
13.2 The Role of Types
14 Methods and Unions of Classes (Continued)
14.1 How Libraries Work, Part 1: Drawing Geometric Shapes
14.2 Finger Exercises
14.3 Designing Methods for Unions of Classes
15 Methods and Classes with Mutual References
15.1 Example: Managing a Runner’s Logs
15.2 Example: Sorting
15.3 Example: Overlapping Shapes
15.4 Example: River Systems
15.5 Finger Exercises
16 Designing Methods
16.1 The Varieties of Templates
16.2 Wish Lists
16.3 Case Study: Fighting UFOs, with Methods
Intermezzo 2: Methods
Vocabulary and Grammar for Methods
Type Checking
Meaning: Evaluating Method Calls
III Abstracting with Classes
18 Similarities in Classes
18.1 Common Fields, Superclasses
18.2 Abstract Classes, Abstract Methods
18.3 Lifting Methods, Inheriting Methods
18.4 Creating a Superclass, Creating a Union
18.5 Deriving Subclasses
19 Designing Class Hierarchies with Methods
19.1 Local Variables and Composition
19.2 Abstracting with Methods
19.3 Abstracting within Unions of Classes
19.4 Abstracting through the Creation of Unions
19.5 Deriving Subclasses from “Library” Classes
19.6 Creating Subclasses for Special Objects
19.7 How Libraries Work, Part 2: Deriving Classes
19.8 Case Study: Fighting UFOs, All the Way
19.9 Mini Project: Worm
20 State Encapsulation and Self-Preservation
20.1 The Power of Constructors
20.3 Encapsulating and Privacy
20.4 Guidelines for State Encapsulation
20.5 Finger Exercises on Encapsulation
21 Extensional Equality, Part 1
21.1 Equality for Plain Classes
21.2 Equality for Inheritance
21.3 Equality for Containment and Unions
Intermezzo 3: Abstract Classes, Privacy
Abstract Classes and Class Extensions
Privacy for Methods
IV Circular Objects, Imperative Methods
23 Circular Data
23.1 Designing Classes for Circular Objects, Constructors
23.2 The True Nature of Constructors
23.3 Circularity and Encapsulation
23.4 Example: Family Trees
24 Methods on Circular Data
25 The State of the World and How It Changes
26 Assignments and Changes in the World
26.1 Example: Dropping Blocks
26.2 Example: Accounts
26.3 How Libraries Work 3: An Alternative World
27 Designing Stateful Classes, Imperative Methods
27.1 When to Use Stateful Classes and Imperative Methods
27.2 How to Design Stateful Classes, Imperative Methods
27.3 Imperative Methods and Templates
27.4 Imperative Methods and Abstraction
27.5 Danger!
27.6 Case Study: More on Bank Accounts
27.7 Case Study Repeated: A Stateful Approach to UFOs
27.8 Case Study: A Deck of Cards
28.5 Danger! Extensional Equality and Cycles
Intermezzo 4: Assignments
V Abstracting Data Representations
30 Types and Similarities between Plain Classes
30.1 Classes with Common Structure, Different Types
30.2 Abstracting Types via Subtyping
30.3 Abstracting Types via Generics
31 Types and Similarities between Hierarchies
31.1 Abstracting Types via Subtyping, Part 2
31.2 Abstracting Types via Subtyping plus Interfaces
31.3 Abstracting Types via Generics, Part 2
31.4 Abstracting Types via Generics plus Interfaces
32 Designing General Classes and Frameworks
32.1 Subtyping Summarized
32.2 Generalizing via Subtyping
32.3 Generalizing via Generics
32.4 Finger Exercises: Sets, Stacks, Queues, and Trees Again
32.5 Errors, also known as Runtime Exceptions
33 Designing (to) Interfaces
33.1 Organizing Programs, Hiding Auxiliary Methods
33.2 Getters, Predicates, and Setters
33.3 Interfaces as Speciﬁcations
34 Extensible Frameworks: Abstracting Constructors
34.1 Data Extensions are Easy
34.2 Function Extension: A Design that doesn’t Quite Work
34.3 ... and how to Fix it (Mostly)
34.4 Function Extension: Take 2
34.5 Mini Project: The Towers of Hanoi
Intermezzo 5: Generic Classes
VI Abstracting Data Traversals
36 Patterns in Traversals
36.1 Example: Menus Designed from Scratch
36.2 Example: Menus Designed as Lists
36.3 Methods as Objects
36.4 List Traversals and Polymorphic Methods
36.5 Example: fold
36.6 Example: Arithmetic Expressions and Traversals
37 Designing Abstract Traversal Methods
37.1 Methods as Objects via Subtyping
37.2 Methods as Objects via Generics
37.3 Abstracting over Method Calls, Anonymous Inner Classes
37.4 Inner Classes, Anonymous Classes
37.5 Visitor Traversals and Designing Visitors
37.6 Finger Exercises: Visiting Lists, Trees, Sets
37.7 Extended Exercise: Graphs and Visitors
37.8 Where to Use Traversals, or Aggregation
37.9 Object-Oriented and Functional Programming
38 Traversing with Effects
38.1 Abstracting over Imperative Traversals: the forEach Method
38.2 Using the forEach Method
38.3 Using forEach with Anonymous Classes
38.4 Mini Projects, including a Final Look at “War of the Worlds”
38.5 Abusing the forEach Method
39 Extensible Frameworks with Visitors
Intermezzo 6: Generic Methods, Inner Classes
VII Loops and Arrays
41 The Design Flaw
42 Loops
42.1 Designing Loops
42.2 Designing Nested Loops
0 of .
Results for:
P. 1
How to Design Classes

# How to Design Classes

Ratings: (0)|Views: 19|Likes:

### Availability:

See more
See less

05/02/2014

pdf

text

original

Pages 14 to 83 are not shown in this preview.
Pages 97 to 249 are not shown in this preview.