文档介绍:Thinking
in
Patterns
with Java
Bruce Eckel
President, MindView, Inc.
Revision
Please note that this document is in its initial form, and much remains to
be done. Corrections ments should go to
ts/TIPatterns/
Contents
Preface 7
Introduction 9
1: The pattern concept 11
What is a pattern? ..............11
Pattern taxonomy.............. 13
The singleton ..................... 14
Classifying patterns........... 15
The development challenge16
Exercises............................ 17
2: Unit Testing 19
Write tests first..................20
A very simple framework .. 21
Writing tests ......................23
White-box & black-box tests25
Running tests.....................28
Automatically executing tests30
Exercises............................30
3: Building application frameworks 31
Template method .............. 31
4:Fronting for an implementation 33
Proxy..................................34
State ...................................35
StateMachine.....................38
Tools ..................................44
Exercises............................45
X: Iterators: decoupling algorithms from containers 47
Type-safe iterators ............48
5: Factories: encapsulating object creation 51
Simple Factory method.....52
Polymorphic factories .......54
Abstract factories .............. 57
Exercises............................60
6: Function objects 61
Command .......................... 61
Strategy..............................63
Chain of responsibility ......65
Exercises ............................67
7: Changing the interface 69
Adapter ..............................69
Façade................................ 71
Package as a variation of Façade .72
Exercises ............................73
8: Table-driven code: configuration flexibility 75
Table-driven code using anonymous inner classes 75
9: Interpreter/ Multiple Languages