Head First Design Patterns (2008).pdf
(
11319 KB
)
Pobierz
DPFrontMatterFinalFinalwithQuotes.indd
table of
contents
Table of Contents (summary)
Intro
xxv
1 Welcome to Design Patterns:
an introduction
1
2 Keeping your Objects in the know:
the Observer Pattern
37
3 Decorating Objects:
the Decorator Pattern
79
4 Baking with OO goodness:
the Factory Pattern
109
5 One of a Kind Objects:
the Singleton Pattern
169
6 Encapsulating Invocation:
the Command Pattern
191
7 Being Adaptive:
the Adapter and Facade Patterns
235
8 Encapsulating Algorithms:
theTemplate Method Pattern
275
9 Well-managed Collections:
the Iterator and Composite Patterns
315
10 The State of Things:
the State Pattern
385
11 Controlling Object Access:
the Proxy Pattern
429
12 Patterns of Patterns:
Compound Patterns
499
13 Patterns in the Real World:
Better Living with Patterns
577
14 Appendix:
Leftover Patterns
611
Table of Contents (the real thing)
Intro
Your brain on Design Patterns.
Here
you
are trying to
learn
something, while
here your
brain
is doing you a favor by making sure the learning doesn’t
stick
. Your brain’s
thinking, “Better leave room for more important things, like which wild animals to avoid and
whether naked snowboarding is a bad idea.” So how
do
you trick your brain into thinking
that your life depends on knowing Design Patterns?
Who is this book for?
xxvi
We know what your brain is thinking
xxvii
Metacognition
xxix
Bend your brain into submission
xxxi
Technical reviewers
xxxiv
Acknowledgements
xxxv
x
intro to Design Patterns
Someone has already solved your problems.
In this chapter,
you’ll learn why (and how) you can exploit the wisdom and lessons learned by
other developers who’ve been down the same design problem road and survived
the trip. Before we’re done, we’ll look at the use and benefits of design patterns,
look at some key OO design principles, and walk through an example of how one
pattern works. The best way to use patterns is to
load your brain
with them and
then
recognize places
in your designs and existing applications where you can
apply them
. Instead of
code
reuse, with patterns you get
experience
reuse.
The SimUDuck app
2
Remember, knowing
concepts like abstraction,
inheritance, and polymorphism do
not make you a good object oriented
designer. A design guru thinks
about how to create flexible
designs that are maintainable
and that can cope with
change.
Joe thinks about inheritance...
5
How about an interface?
6
The one constant in software development
8
Separating what changes from what stays the same
10
Designing the Duck Behaviors
11
Testing the Duck code
18
Setting behavior dynamically
20
The Big Picture on encapsulated behaviors
22
HAS-A can be better than IS-A
23
The Strategy Pattern
24
The power of a shared pattern vocabulary
28
How do I use Design Patte
rns?
29
Tools for your Design Toolbox
32
Exercise Solutions
34
Object that
holds state
OBSERVER
8
int
8
8
8
8
O
Automatic update/notification
Observers
xi
1
Welcome to Design Patterns
table of
contents
the Observer Pattern
Don’t miss out when something interesting happens!
We’ve got a pattern that keeps your objects in the know when something they
might care about happens. Objects can even decide at runtime whether they
want to be kept informed. The Observer Pattern is one of the most heavily used
patterns in the JDK, and it’s incredibly useful. Before we’re done, we’ll also look
at one to many relationships and loose coupling (yeah, that’s right, we said
coupling). With Observer, you’ll be the life of the Patterns Party.
The Weather Monitoring application
39
Meet the Observer Pattern
44
Publishers + Subscribers = Observer Pattern
45
Five minute drama: a subject for observation
48
The Observer Pattern defined
51
The power of Loose Coupling
53
Designing the Weather Station
56
Implementing the Weather Station
57
Using Java’s built-in Observer Pattern
64
The dark side of java.util.Observable
71
Tools for your Design Toolbox
74
Exercise Solutions
78
Object that
holds state
ONE TO MANY RELATIONSHIP
8
8
8
8
8
int
O
Automatic update/notification
Observers
xii
2
Keeping your Objects in the Know
the Decorator Pattern
Just call this chapter “Design Eye for the Inheritance
Guy.”
We’ll re-examine the typical overuse of inheritance and you’ll learn how
to decorate your classes at runtime using a form of object composition. Why?
Once you know the techniques of decorating, you’ll be able to give your (or
someone else’s) objects new responsibilities
without making any code changes
to the underlying classes.
Welcome to Starbuzz Coffee
80
The Open-Closed Principle
86
I used to think real men
subclassed everything. That was until
I learned the power of extension
at runtime, rather than at compile
time. Now look at me!
Meet the Decorator Pattern
88
Constructing a Drink Order with Decorators
89
The Decorator Pattern Defined
91
Decorating our Beverages
92
Writing the Starbuzz code
95
Real World Decorators: Java I/O
100
Writing your own Java I/O Decorator
102
Tools for your Design Toolbox
105
Exercise Solutions
106
xiii
3
Decorating Objects
Plik z chomika:
Jimmy83
Inne pliki z tego folderu:
CSharp Design Patterns A Tutorial 2002.chm
(2638 KB)
pro-css-and-html-design-patterns.9781590598047.28240(1).pdf
(10921 KB)
OReilly.C.Sharp.3.0.Design.Patterns.Jan.2008.pdf
(2818 KB)
Gang Of Four - Design Patterns, Elements Of Reusable Object Oriented Software - Addison Wesley - Site 518 Pg - Pdf 002.pdf
(4748 KB)
Head First Design Patterns (2008).pdf
(11319 KB)
Inne foldery tego chomika:
ASP
C#
EDCL
Kursy
Network Programming
Zgłoś jeśli
naruszono regulamin