AddisonWesley - Design Patterns Java.PDF

(2282 KB) Pobierz
Click on your interest section for more information :
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
Tax
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
l
805781917.050.png 805781917.061.png 805781917.072.png 805781917.079.png
 
805781917.001.png
1
2
T HE
D ESIGN P ATTERNS
J AVA C OMPANION
J AMES W. C OOPER
October 2, 1998
Copyright © 1998, by James W. Cooper
805781917.002.png 805781917.003.png 805781917.004.png 805781917.005.png 805781917.006.png 805781917.007.png 805781917.008.png 805781917.009.png 805781917.010.png 805781917.011.png 805781917.012.png 805781917.013.png 805781917.014.png 805781917.015.png 805781917.016.png 805781917.017.png 805781917.018.png 805781917.019.png 805781917.020.png 805781917.021.png 805781917.022.png 805781917.023.png 805781917.024.png 805781917.025.png 805781917.026.png 805781917.027.png 805781917.028.png 805781917.029.png 805781917.030.png 805781917.031.png 805781917.032.png 805781917.033.png 805781917.034.png 805781917.035.png 805781917.036.png 805781917.037.png 805781917.038.png 805781917.039.png 805781917.040.png 805781917.041.png 805781917.042.png 805781917.043.png 805781917.044.png 805781917.045.png 805781917.046.png 805781917.047.png 805781917.048.png 805781917.049.png 805781917.051.png 805781917.052.png 805781917.053.png 805781917.054.png 805781917.055.png 805781917.056.png 805781917.057.png 805781917.058.png 805781917.059.png 805781917.060.png 805781917.062.png 805781917.063.png 805781917.064.png 805781917.065.png 805781917.066.png 805781917.067.png 805781917.068.png 805781917.069.png 805781917.070.png 805781917.071.png 805781917.073.png 805781917.074.png 805781917.075.png 805781917.076.png 805781917.077.png 805781917.078.png
3
Some Background on Design Patterns
10
Defining Design Patterns
11
This Book and its Parentage
13
The Learning Process
13
Studying Design Patterns
14
Notes on Object Oriented Approaches
14
The Java Foundation Classes
15
Java Design Patterns
15
1. Creational Patterns 17
The Factory Pattern
18
How a Factory Works
18
Sample Code
18
The Two Derived Classes
19
Building the Factory
20
Factory Patterns in Math Computation
22
When to Use a Factory Pattern
24
Thought Questions
25
The Abstract Factory Pattern
26
A GardenMaker Factory
26
How the User Interface Works
28
Consequences of Abstract Factory
30
Thought Questions
30
The Singleton Pattern
31
Throwing the Exception
32
Creating an Instance of the Class
32
Static Classes as Singleton Patterns
33
Creating Singleton Using a Static Method
34
4
Finding the Singletons in a Large Program
35
Other Consequences of the Singleton Pattern
35
The Builder Pattern
37
An Investment Tracker
38
Calling the Builders
40
The List Box Builder
42
The Checkbox Builder
43
Consequences of the Builder Pattern
44
Thought Questions
44
The Prototype Pattern
45
Cloning in Java
45
Using the Prototype
47
Consequences of the Prototype Pattern
50
Summary of Creational Patterns
51
2. The Java Foundation Classes 52
Installing and Using the JFC
52
Ideas Behind Swing
53
The Swing Class Hierarchy
53
Writing a Simple JFC Program
54
Setting the Look and Feel
54
Setting the Window Close Box
55
Making a JxFrame Class
55
A Simple Two Button Program
56
More on JButtons
57
Buttons and Toolbars
59
Radio Buttons
59
The JToolBar
59
Toggle Buttons
60
Zgłoś jeśli naruszono regulamin