| |
| |
Intro to Design Patterns | |
| |
| |
| |
Welcome to Design Patterns: Someone has already solved your problems | |
| |
| |
The SimUDuck app | |
| |
| |
Joe thinks about inheritance... | |
| |
| |
How about an interface? | |
| |
| |
The one constant in software development | |
| |
| |
Separating what changes from what stays the same | |
| |
| |
Designing the Duck Behaviors | |
| |
| |
Testing the Duck code | |
| |
| |
Setting behavior dynamically | |
| |
| |
The Big Picture on encapsulated behaviors | |
| |
| |
HAS-A can be better than IS-A | |
| |
| |
The Strategy Pattern | |
| |
| |
The power of a shared pattern vocabulary | |
| |
| |
How do I use Design Patterns? | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Exercise Solutions | |
| |
| |
The Observer Pattern | |
| |
| |
| |
Keeping your Objects in the Know: Don't miss out when something interesting happens! | |
| |
| |
The Weather Monitoring application | |
| |
| |
Meet the Observer Pattern | |
| |
| |
Publishers + Subscribers = Observer Pattern | |
| |
| |
Five minute drama: a subject for observation | |
| |
| |
The Observer Pattern defined | |
| |
| |
The power of Loose Coupling | |
| |
| |
Designing the Weather Station | |
| |
| |
Implementing the Weather Station | |
| |
| |
Using Java's built-in Observer Pattern | |
| |
| |
The dark side of java.util. Observable | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Exercise Solutions | |
| |
| |
The Decorator Pattern | |
| |
| |
| |
Decorating Objects: Just call this chapter "Design Eye for the Inheritance Guy." | |
| |
| |
Welcome to Starbuzz Coffee | |
| |
| |
The Open-Closed Principle | |
| |
| |
Meet the Decorator Pattern | |
| |
| |
Constructing a Drink Order with Decorators | |
| |
| |
The Decorator Pattern Defined | |
| |
| |
Decorating our Beverages | |
| |
| |
Writing the Starbuzz code | |
| |
| |
Real World Decorators: Java I/O | |
| |
| |
Writing your own Java I/O Decorator | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Exercise Solutions | |
| |
| |
The Factory Pattern | |
| |
| |
| |
Baking with OO Goodness: Get ready to cook some loosely coupled OO designs | |
| |
| |
When you see "new", think "concrete" | |
| |
| |
Objectville Pizza | |
| |
| |
Encapsulating object creation | |
| |
| |
Building a simple pizza factory | |
| |
| |
The Simple Factory defined | |
| |
| |
A Framework for the pizza store | |
| |
| |
Allowing the subclasses to decide | |
| |
| |
Let's make a PizzaStore | |
| |
| |
Declaring a factory method | |
| |
| |
Meet the Factory Method Pattern | |
| |
| |
Parallel class hierarchies | |
| |
| |
Factory Method Pattern defined | |
| |
| |
A very dependent PizzaStore | |
| |
| |
Looking at object dependencies | |
| |
| |
The Dependency Inversion Principle | |
| |
| |
Meanwhile, back at the PizzaStore... | |
| |
| |
Families of ingredients... | |
| |
| |
Building our ingredient factories | |
| |
| |
Looking at the Abstract Factory | |
| |
| |
Behind the scenes | |
| |
| |
Abstract Factory Pattern defined | |
| |
| |
Factory Method and Abstract Factory compared | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Exercise Solutions | |
| |
| |
The Singleton Pattern | |
| |
| |
| |
One of a Kind Objects: The Singleton Pattern: your ticket to creating one-of-a-kind objects, for which there is only one instance | |
| |
| |
One and only one object | |
| |
| |
The Little Singleton | |
| |
| |
Dissecting the classic Singleton Pattern | |
| |
| |
Confessions of a Singleton | |
| |
| |
The Chocolate Factory | |
| |
| |
Singleton Pattern defined | |
| |
| |
Hershey, PA, we have a problem... | |
| |
| |
BE the JVM | |
| |
| |
Dealing with multithreading | |
| |
| |
Singleton Q&A | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Exercise Solutions | |
| |
| |
The Command Pattern | |
| |
| |
| |
Encapsulating Invocation: In this chapter we take encapsulation to a whole new level: we're going to encapsulate method invocation | |
| |
| |
Home Automation or Bust | |
| |
| |
The Remote Control | |
| |
| |
Taking a look at the vendor classes | |
| |
| |
Meanwhile, back at the Diner... | |
| |
| |
Let's study the Diner interaction | |
| |
| |
The Objectville Diner Roles and Responsibilities | |
| |
| |
From the Diner to the Command Pattern | |
| |
| |
Our first command object | |
| |
| |
The Command Pattern defined | |
| |
| |
The Command Pattern and the Remote Control | |
| |
| |
Implementing the Remote Control | |
| |
| |
Putting the Remote Control through its paces | |
| |
| |
Time to write that documentation | |
| |
| |
Using state to implement Undo | |
| |
| |
Every remote needs a Party Mode! | |
| |
| |
Using a Macro Command | |
| |
| |
More uses of the Command Pattern: Queuing requests | |
| |
| |
More uses of the Command Pattern: Logging requests | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Exercise Solutions | |
| |
| |
The Adapter and Facade Patterns | |
| |
| |
| |
Being Adaptive: In this chapter we're going to attempt such impossible feats as putting a square peg in a round hole | |
| |
| |
Adapters all around us | |
| |
| |
Object Oriented Adapters | |
| |
| |
The Adapter Pattern explained | |
| |
| |
Adapter Pattern defined | |
| |
| |
Object and Class Adapters | |
| |
| |
Tonight's talk: The Object Adapter and Class Adapter | |
| |
| |
Real World Adapters | |
| |
| |
Adapting an Enumeration to an Iterator | |
| |
| |
Tonight's talk: The Decorator Pattern and the Adapter Pattern | |
| |
| |
Home Sweet Home Theater | |
| |
| |
Lights, Camera, Facade! | |
| |
| |
Constructing your Home Theater Facade | |
| |
| |
Facade Pattern defined | |
| |
| |
The Principle of Least Knowledge | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Exercise Solutions | |
| |
| |
The Template Method Pattern | |
| |
| |
| |
Encapsulating Algorithms: We've encapsulated object creation, method invocation, complex interfaces, ducks, pizzas...what could be next? | |
| |
| |
Whipping up some coffee and tea classes | |
| |
| |
Abstracting Coffee and Tea | |
| |
| |
Taking the design further | |
| |
| |
Abstracting prepareRecipe() | |
| |
| |
What have we done? | |
| |
| |
Meet the Template Method | |
| |
| |
Let's make some tea | |
| |
| |
What did the Template Method get us? | |
| |
| |
Template Method Pattern defined | |
| |
| |
Code up close | |
| |
| |
Hooked on Template Method... | |
| |
| |
Using the hook | |
| |
| |
Coffee? Tea? Nah, let's run the TestDrive | |
| |
| |
The Hollywood Principle | |
| |
| |
The Hollywood Principle and the Template Method | |
| |
| |
Template Methods in the Wild | |
| |
| |
Sorting with Template Method | |
| |
| |
We've got some ducks to sort | |
| |
| |
Comparing ducks and ducks | |
| |
| |
The making of the sorting duck machine | |
| |
| |
Swingin' with Frames | |
| |
| |
Applets | |
| |
| |
Tonight's talk: Template Method and Strategy | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Exercise Solutions | |
| |
| |
The Iterator and Composite Patterns | |
| |
| |
| |
Well-Managed Collections: There are lots of ways to stuff objects into a collection | |
| |
| |
Objectville Diner and Pancake House merge | |
| |
| |
Comparing Menu implementations | |
| |
| |
Can we encapsulate the iteration? | |
| |
| |
Meet the Iterator Pattern | |
| |
| |
Adding an Iterator to DinerMenu | |
| |
| |
Looking at the design | |
| |
| |
Cleaning things up with java.util.Iterator | |
| |
| |
What does this get us? | |
| |
| |
Iterator Pattern defined | |
| |
| |
Single Responsibility | |
| |
| |
Iterators and Collections | |
| |
| |
Iterators and Collections in Java 5 | |
| |
| |
Just when we thought it was safe... | |
| |
| |
The Composite Pattern defined | |
| |
| |
Designing Menus with Composite | |
| |
| |
Implementing the Composite Menu | |
| |
| |
Flashback to Iterator | |
| |
| |
The Null Iterator | |
| |
| |
The magic of Iterator & Composite together... | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Exercise Solutions | |
| |
| |
The State Pattern | |
| |
| |
| |
The State of Things: A little known fact: the Strategy and State Patterns were twins separated at birth | |
| |
| |
How do we implement state? | |
| |
| |
State Machines 101 | |
| |
| |
A first attempt at a state machine | |
| |
| |
You knew it was coming...a change request! | |
| |
| |
The messy STATE of things... | |
| |
| |
Defining the State interfaces and classes | |
| |
| |
Implementing our State Classes | |
| |
| |
Reworking the Gumball Machine | |
| |
| |
The State Pattern defined | |
| |
| |
State versus Strategy | |
| |
| |
State sanity check | |
| |
| |
We almost forgot! | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Exercise Solutions | |
| |
| |
The Proxy Pattern | |
| |
| |
| |
Controlling Object Access: Every play good cop, bad cop? | |
| |
| |
Monitoring the gumball machines | |
| |
| |
The role of the 'remote proxy' | |
| |
| |
RMI detour | |
| |
| |
GumballMachine remote proxy | |
| |
| |
Remote proxy behind the scenes | |
| |
| |
The Proxy Pattern defined | |
| |
| |
Get Ready for virtual proxy | |
| |
| |
Designing the CD cover virtual proxy | |
| |
| |
Virtual proxy behind the scenes | |
| |
| |
Using the Java API's proxy | |
| |
| |
Five minute drama: protecting subjects | |
| |
| |
Creating a dynamic proxy | |
| |
| |
The Proxy Zoo | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Exercise Solutions | |
| |
| |
Compound Patterns | |
| |
| |
| |
Patterns of Patterns: Who would have ever guessed that Patterns could work together? | |
| |
| |
Compound Patterns | |
| |
| |
Duck reunion | |
| |
| |
Adding an adapter | |
| |
| |
Adding a decorator | |
| |
| |
Adding a factory | |
| |
| |
Adding a composite, and iterator | |
| |
| |
Adding an observer | |
| |
| |
Patterns summary | |
| |
| |
A duck's eye view: the class diagram | |
| |
| |
Model-View-Controller, the song | |
| |
| |
Design Patterns are your key to the MVC | |
| |
| |
Looking at MVC through patterns-colored glasses | |
| |
| |
Using MVC to control the beat... | |
| |
| |
The Model | |
| |
| |
The View | |
| |
| |
The Controller | |
| |
| |
Exploring strategy | |
| |
| |
Adapting the model | |
| |
| |
Now we're ready for a HeartController | |
| |
| |
MVC and the Web | |
| |
| |
Design Patterns and Model 2 | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Exercise Solutions | |
| |
| |
Better Living with Patterns | |
| |
| |
| |
Patterns in the Real World: Ahhhh, now you're ready for a bright new world filled with Design Patterns | |
| |
| |
Your Objectville guide | |
| |
| |
Design Pattern defined | |
| |
| |
Looking more closely at the Design Pattern definition | |
| |
| |
May the force be with you | |
| |
| |
Pattern catalogs | |
| |
| |
How to create patterns | |
| |
| |
So you wanna be a Design Patterns writer? | |
| |
| |
Organizing Design Patterns | |
| |
| |
Thinking in patterns | |
| |
| |
Your mind on patterns | |
| |
| |
Don't forget the power of the shared vocabulary | |
| |
| |
Top five ways to share your vocabulary | |
| |
| |
Cruisin' Objectville with the Gang of Four | |
| |
| |
Your journey has just begun... | |
| |
| |
Other Design Pattern resources | |
| |
| |
The Patterns Zoo | |
| |
| |
Annihilating evil with Anti-Patterns | |
| |
| |
Tools for your Design Toolbox | |
| |
| |
Leaving Objectville... | |
| |
| |
| |
Appendix: Leftover Patterns: Not everyone can be the most popular | |
| |
| |
Bridge | |
| |
| |
Builder | |
| |
| |
Chain of Responsibility | |
| |
| |
Flyweight | |
| |
| |
Interpreter | |
| |
| |
Mediator | |
| |
| |
Memento | |
| |
| |
Prototype | |
| |
| |
Visitor | |
| |
| |
Index | |