Thinking in Patterns with Java, Revision 0.6 - Contents
Thinking in Patterns with Java, Revision 0.6 - Title Page
Preface
Introduction
The Y2K syndrome
Context and composition
A word about checked exceptions
1: The pattern concept
What is a pattern?
Pattern taxonomy
Design Structures
Design principles
The Singleton
Classifying patterns
The development challenge
Exercises
2: Unit Testing
Write tests first
A very simple framework
Writing tests
White-box & black-box tests
Running tests
Automatically executing tests
Exercises
3: Building application frameworks
Template method
Exercises
4:Fronting for an implementation
Proxy
State
StateMachine
Table-Driven State Machine
The State class
Conditions for transition
Transition actions
The table
The basic machine
Simple vending machine
Testing the machine
Tools
Exercises
X: Decorators: dynamic type selection
Basic decorator structure
A coffee example
Class for each combination
The decorator approach
Compromise
Other considerations
Exercises
Y: Iterators: decoupling algorithms from containers
Type-safe iterators
5: Factories: encapsulating object creation
Simple Factory method
Polymorphic factories
Abstract factories
Exercises
6: Function objects
Command: choosing the operation at run-time
Strategy: choosing the algorithm at run-time
Chain of responsibility
Exercises
7: Changing the interface
Adapter
Façade
Package as a variation of Façade
Exercises
8: Table-driven code: configuration flexibility
Table-driven code using anonymous inner classes
9: Interpreter/ Multiple Languages
Interpreter motivation
Python overview
Built-in containers
Functions
Strings
Classes
Inheritance
Creating a language
Controlling the interpreter
Putting data in
Getting data out
Multiple interpreters
Controlling Java from Jython
Inner Classes
Using Java libraries
Inheriting from Java library classes
Creating Java classes with Jython
Building the Java classes from the Python code
The Java-Python Extension (JPE)
Summary
Exercises
10: Callbacks
Observer
Observing flowers
A visual example of observers
Exercises
11: Multiple dispatching
Visitor, a type of multiple dispatching
Exercises
12: Pattern refactoring
Simulating the trash recycler
Improving the design
“Make more objects”
A pattern for prototyping creation
Trash subclasses
Parsing Trash from an external file
Recycling with prototyping
Abstracting usage
Multiple dispatching
Implementing the double dispatch
The Visitor pattern
A Reflective Decorator
More coupling?
RTTI considered harmful?
Summary
Exercises
13: Projects
Rats & Mazes
Other maze resources
XML Decorator