Thinking in Patterns with Java - Tutok, 2003.pdf
(
425 KB
)
Pobierz
Thinking in Patterns with Java
in
with Java
Bruce Eckel
President, MindView, Inc.
Revision 0.5a
Please note that this document is in its initial form, and much remains to
be done. Corrections and comments should go to
http://www.topica.com/lists/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 challenge17
Exercises .............................. 17
2: Unit Testing 19
Write tests first ................... 20
A very simple framework. 21
Writing tests ....................... 23
White-box & black-box tests26
Running tests...................... 28
Automatically executing tests
30
Exercises .............................. 31
3: Building application frameworks
33
Template method............... 33
4:Fronting for an implementation
35
Proxy.................................... 36
State...................................... 37
StateMachine ...................... 40
Tools..................................... 47
Exercises .............................. 47
X: Iterators: decoupling algorithms from containers
49
Type-safe iterators ............. 50
5: Factories: encapsulating object creation
53
Simple Factory method ..... 54
Polymorphic factories........ 56
Abstract factories................ 59
Exercises .............................. 62
6: Function objects 63
Command ............................ 63
Strategy ................................ 65
Chain of responsibility ...... 67
Exercises .............................. 69
7: Changing the interface 71
Adapter ................................ 71
Façade .................................. 73
Package as a variation of
Façade
.. 74
Exercises .............................. 75
8: Table-driven code: configuration flexibility
77
Table-driven code using anonymous inner classes 77
9: Interpreter/ Multiple Languages
79
Interpreter............................ 80
Motivation ........................... 80
Python overview ................ 81
Built-in containers ......................... 82
Functions ........................................ 83
Strings ............................................. 84
Classes............................................. 85
Creating a language ........... 89
Configuring Jython ....................... 93
Generating documentation93
Controlling the interpreter 94
Putting data in ............................... 94
Getting data out........................... 100
Multiple interpreters ................... 103
Controlling Java from Jython104
Using Java libraries .......... 108
Inheriting from Java library classes110
Creating Java classes with Jython 111
Building the Java classes from the Python code
116
Summary ........................... 117
Exercises ............................ 118
10: Callbacks 119
Observer ............................ 119
Observing flowers ....................... 121
A visual example of observers
125
Exercises ............................ 128
11: Multiple dispatching 129
Visitor, a type of multiple dispatching
132
Exercises ............................ 135
12: Pattern refactoring 137
Simulating the trash recycler137
Improving the design...... 141
“Make more objects”................... 142
A pattern for prototyping creation 145
Trash
subclasses .......................... 150
Parsing
Trash
from an external file151
Recycling with prototyping ....... 155
Abstracting usage ............ 156
Multiple dispatching ....... 161
Implementing the double dispatch162
The
Visitor
pattern ........... 169
A Reflective Decorator................ 172
More coupling? ............................ 178
RTTI considered harmful?178
Summary ........................... 181
Exercises ............................ 183
13: Projects 184
Rats & Mazes .................... 184
Other maze resources.................. 189
XML Decorator................. 189
Plik z chomika:
Ryjufka
Inne pliki z tego folderu:
Antipatterns, 2006.pdf
(3423 KB)
Applied Java Patterns, 2001.pdf
(2772 KB)
Concurrent Programming in Java, Design Patterns, 1999.chm
(1416 KB)
Design Patterns Workbook, 2002.pdf
(5089 KB)
Design Patterns Explained With Java and UML2, 2008.pdf
(1343 KB)
Inne foldery tego chomika:
Advanced Topics
Ant
Application Servers
Certification Guides
Data Structures
Zgłoś jeśli
naruszono regulamin