Note: Supplemental materials are not guaranteed with Rental or Used book purchases.
Purchase Benefits
Looking to rent a book? Rent Head First Design Patterns [ISBN: 9780596007126] for the semester, quarter, and short term or search our site for other textbooks by Freeman, Eric. Renting a textbook can save you up to 90% from the cost of buying.
Eric Freeman is a computer scientist with a passion for media and software architectures and coauthor of Head First Design Patterns. He just wrapped up four years at a dream job-- directing internet broadband and wireless efforts at Disney--and is now back to writing, creating cool software, and hacking Java and Macs. Eric spent a lot of the '90s working on alternatives to the desktop metaphor with David Gelernter (and they're both still asking the question, "Why do I have to give a file a name?"). Based on this work, Eric landed a Ph.D. at Yale University in 1997. He also co-founded Mirror Worlds Technologies (now acquired) to create a commercial version of his thesis work, Lifestreams.
In a previous life, Eric built software for networks and supercomputers. You might know him from such books as JavaSpaces Principles Patterns and Practice. Eric has fond memories of implementing tuple-space systems on Thinking Machine CM-5s and creating some of the first internet information systems for NASA in the late 1980s.
When he's not writing text or code you'll find him spending more time tweaking than watching his home theater and trying to restore a circa 1980s Dragon's Lair video game. He also wouldn't mind moonlighting as an electronica DJ.
Write to him at eric at wickedlysmart dot com or visit him at http://www.ericfreeman.com .
Elisabeth Robson (formerly Freeman) is coauthor of O'Reilly's Head First Design Patterns and Head First HTML with CSS & XHTML. She is currently Special Projects Director at O'Reilly where she is developing new brain-friendly learning ideas and products.
Bert Bates is a 20-year software developer, a Java instructor, and a co-developer of Sun's upcoming EJB exam (Sun Certified Business Component Developer). His background features a long stint in artificial intelligence, with clients like the Weather Channel, A&E Network, Rockwell, and Timken.
Kathy Sierra has been interested in learning theory since her days as a game developer (Virgin, MGM, Amblin'). More recently, she's been a master trainer for Sun Microsystems, teaching Sun's Java instructors how to teach the latest technologies to customers, and a lead developer of several Sun certification exams. Along with her partner Bert Bates, Kathy created the Head First series. She's also the original founder of the Software Development/Jolt Productivity Award-winning javaranch.com, the largest (and friendliest) all-volunteer Java community.
Intro to Design Patterns | |
Welcome to Design Patterns: Someone has already solved your problems | |
The SimUDuck app | p. 2 |
Joe thinks about inheritance... | p. 5 |
How about an interface? | p. 6 |
The one constant in software development | p. 8 |
Separating what changes from what stays the same | p. 10 |
Designing the Duck Behaviors | p. 11 |
Testing the Duck code | p. 18 |
Setting behavior dynamically | p. 20 |
The Big Picture on encapsulated behaviors | p. 22 |
HAS-A can be better than IS-A | p. 23 |
The Strategy Pattern | p. 24 |
The power of a shared pattern vocabulary | p. 28 |
How do I use Design Patterns? | p. 29 |
Tools for your Design Toolbox | p. 32 |
Exercise Solutions | p. 34 |
The Observer Pattern | |
Keeping your Objects in the Know: Don't miss out when something interesting happens! | |
The Weather Monitoring application | p. 39 |
Meet the Observer Pattern | p. 44 |
Publishers + Subscribers = Observer Pattern | p. 45 |
Five minute drama: a subject for observation | p. 48 |
The Observer Pattern defined | p. 51 |
The power of Loose Coupling | p. 53 |
Designing the Weather Station | p. 56 |
Implementing the Weather Station | p. 57 |
Using Java's built-in Observer Pattern | p. 64 |
The dark side of java.util. Observable | p. 71 |
Tools for your Design Toolbox | p. 74 |
Exercise Solutions | p. 78 |
The Decorator Pattern | |
Decorating Objects: Just call this chapter "Design Eye for the Inheritance Guy." | |
Welcome to Starbuzz Coffee | p. 80 |
The Open-Closed Principle | p. 86 |
Meet the Decorator Pattern | p. 88 |
Constructing a Drink Order with Decorators | p. 89 |
The Decorator Pattern Defined | p. 91 |
Decorating our Beverages | p. 92 |
Writing the Starbuzz code | p. 95 |
Real World Decorators: Java I/O | p. 100 |
Writing your own Java I/O Decorator | p. 102 |
Tools for your Design Toolbox | p. 105 |
Exercise Solutions | p. 106 |
The Factory Pattern | |
Baking with OO Goodness: Get ready to cook some loosely coupled OO designs | |
When you see "new", think "concrete" | p. 110 |
Objectville Pizza | p. 112 |
Encapsulating object creation | p. 114 |
Building a simple pizza factory | p. 115 |
The Simple Factory defined | p. 117 |
A Framework for the pizza store | p. 120 |
Allowing the subclasses to decide | p. 121 |
Let's make a PizzaStore | p. 123 |
Declaring a factory method | p. 125 |
Meet the Factory Method Pattern | p. 131 |
Parallel class hierarchies | p. 132 |
Factory Method Pattern defined | p. 134 |
A very dependent PizzaStore | p. 137 |
Looking at object dependencies | p. 138 |
The Dependency Inversion Principle | p. 139 |
Meanwhile, back at the PizzaStore... | p. 144 |
Families of ingredients... | p. 145 |
Building our ingredient factories | p. 146 |
Looking at the Abstract Factory | p. 153 |
Behind the scenes | p. 154 |
Abstract Factory Pattern defined | p. 156 |
Factory Method and Abstract Factory compared | p. 160 |
Tools for your Design Toolbox | p. 162 |
Exercise Solutions | p. 164 |
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 | p. 170 |
The Little Singleton | p. 171 |
Dissecting the classic Singleton Pattern | p. 173 |
Confessions of a Singleton | p. 174 |
The Chocolate Factory | p. 175 |
Singleton Pattern defined | p. 177 |
Hershey, PA, we have a problem... | p. 178 |
BE the JVM | p. 179 |
Dealing with multithreading | p. 180 |
Singleton Q&A | p. 184 |
Tools for your Design Toolbox | p. 186 |
Exercise Solutions | p. 188 |
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 | p. 192 |
The Remote Control | p. 193 |
Taking a look at the vendor classes | p. 194 |
Meanwhile, back at the Diner... | p. 197 |
Let's study the Diner interaction | p. 198 |
The Objectville Diner Roles and Responsibilities | p. 199 |
From the Diner to the Command Pattern | p. 201 |
Our first command object | p. 203 |
The Command Pattern defined | p. 206 |
The Command Pattern and the Remote Control | p. 208 |
Implementing the Remote Control | p. 210 |
Putting the Remote Control through its paces | p. 212 |
Time to write that documentation | p. 215 |
Using state to implement Undo | p. 220 |
Every remote needs a Party Mode! | p. 224 |
Using a Macro Command | p. 225 |
More uses of the Command Pattern: Queuing requests | p. 228 |
More uses of the Command Pattern: Logging requests | p. 229 |
Tools for your Design Toolbox | p. 230 |
Exercise Solutions | p. 232 |
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 | p. 236 |
Object Oriented Adapters | p. 237 |
The Adapter Pattern explained | p. 241 |
Adapter Pattern defined | p. 243 |
Object and Class Adapters | p. 244 |
Tonight's talk: The Object Adapter and Class Adapter | p. 247 |
Real World Adapters | p. 248 |
Adapting an Enumeration to an Iterator | p. 249 |
Tonight's talk: The Decorator Pattern and the Adapter Pattern | p. 252 |
Home Sweet Home Theater | p. 255 |
Lights, Camera, Facade! | p. 258 |
Constructing your Home Theater Facade | p. 261 |
Facade Pattern defined | p. 264 |
The Principle of Least Knowledge | p. 265 |
Tools for your Design Toolbox | p. 270 |
Exercise Solutions | p. 272 |
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 | p. 277 |
Abstracting Coffee and Tea | p. 280 |
Taking the design further | p. 281 |
Abstracting prepareRecipe() | p. 282 |
What have we done? | p. 285 |
Meet the Template Method | p. 286 |
Let's make some tea | p. 287 |
What did the Template Method get us? | p. 288 |
Template Method Pattern defined | p. 289 |
Code up close | p. 290 |
Hooked on Template Method... | p. 292 |
Using the hook | p. 293 |
Coffee? Tea? Nah, let's run the TestDrive | p. 294 |
The Hollywood Principle | p. 296 |
The Hollywood Principle and the Template Method | p. 297 |
Template Methods in the Wild | p. 299 |
Sorting with Template Method | p. 300 |
We've got some ducks to sort | p. 301 |
Comparing ducks and ducks | p. 302 |
The making of the sorting duck machine | p. 304 |
Swingin' with Frames | p. 306 |
Applets | p. 307 |
Tonight's talk: Template Method and Strategy | p. 308 |
Tools for your Design Toolbox | p. 311 |
Exercise Solutions | p. 312 |
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 | p. 316 |
Comparing Menu implementations | p. 318 |
Can we encapsulate the iteration? | p. 323 |
Meet the Iterator Pattern | p. 325 |
Adding an Iterator to DinerMenu | p. 326 |
Looking at the design | p. 331 |
Cleaning things up with java.util.Iterator | p. 333 |
What does this get us? | p. 335 |
Iterator Pattern defined | p. 336 |
Single Responsibility | p. 339 |
Iterators and Collections | p. 348 |
Iterators and Collections in Java 5 | p. 349 |
Just when we thought it was safe... | p. 353 |
The Composite Pattern defined | p. 356 |
Designing Menus with Composite | p. 359 |
Implementing the Composite Menu | p. 362 |
Flashback to Iterator | p. 368 |
The Null Iterator | p. 372 |
The magic of Iterator & Composite together... | p. 374 |
Tools for your Design Toolbox | p. 380 |
Exercise Solutions | p. 381 |
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? | p. 387 |
State Machines 101 | p. 388 |
A first attempt at a state machine | p. 390 |
You knew it was coming...a change request! | p. 394 |
The messy STATE of things... | p. 396 |
Defining the State interfaces and classes | p. 399 |
Implementing our State Classes | p. 401 |
Reworking the Gumball Machine | p. 402 |
The State Pattern defined | p. 410 |
State versus Strategy | p. 411 |
State sanity check | p. 417 |
We almost forgot! | p. 420 |
Tools for your Design Toolbox | p. 423 |
Exercise Solutions | p. 424 |
The Proxy Pattern | |
Controlling Object Access: Every play good cop, bad cop? | |
Monitoring the gumball machines | p. 430 |
The role of the 'remote proxy' | p. 434 |
RMI detour | p. 437 |
GumballMachine remote proxy | p. 450 |
Remote proxy behind the scenes | p. 458 |
The Proxy Pattern defined | p. 460 |
Get Ready for virtual proxy | p. 462 |
Designing the CD cover virtual proxy | p. 464 |
Virtual proxy behind the scenes | p. 470 |
Using the Java API's proxy | p. 474 |
Five minute drama: protecting subjects | p. 478 |
Creating a dynamic proxy | p. 479 |
The Proxy Zoo | p. 488 |
Tools for your Design Toolbox | p. 491 |
Exercise Solutions | p. 492 |
Compound Patterns | |
Patterns of Patterns: Who would have ever guessed that Patterns could work together? | |
Compound Patterns | p. 500 |
Duck reunion | p. 501 |
Adding an adapter | p. 504 |
Adding a decorator | p. 506 |
Adding a factory | p. 508 |
Adding a composite, and iterator | p. 513 |
Adding an observer | p. 516 |
Patterns summary | p. 523 |
A duck's eye view: the class diagram | p. 524 |
Model-View-Controller, the song | p. 526 |
Design Patterns are your key to the MVC | p. 528 |
Looking at MVC through patterns-colored glasses | p. 532 |
Using MVC to control the beat... | p. 534 |
The Model | p. 537 |
The View | p. 539 |
The Controller | p. 542 |
Exploring strategy | p. 545 |
Adapting the model | p. 546 |
Now we're ready for a HeartController | p. 547 |
MVC and the Web | p. 549 |
Design Patterns and Model 2 | p. 557 |
Tools for your Design Toolbox | p. 560 |
Exercise Solutions | p. 561 |
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 | p. 578 |
Design Pattern defined | p. 579 |
Looking more closely at the Design Pattern definition | p. 581 |
May the force be with you | p. 582 |
Pattern catalogs | p. 583 |
How to create patterns | p. 586 |
So you wanna be a Design Patterns writer? | p. 587 |
Organizing Design Patterns | p. 589 |
Thinking in patterns | p. 594 |
Your mind on patterns | p. 597 |
Don't forget the power of the shared vocabulary | p. 599 |
Top five ways to share your vocabulary | p. 600 |
Cruisin' Objectville with the Gang of Four | p. 601 |
Your journey has just begun... | p. 602 |
Other Design Pattern resources | p. 603 |
The Patterns Zoo | p. 604 |
Annihilating evil with Anti-Patterns | p. 606 |
Tools for your Design Toolbox | p. 608 |
Leaving Objectville... | p. 609 |
Appendix: Leftover Patterns: Not everyone can be the most popular | |
Bridge | p. 612 |
Builder | p. 614 |
Chain of Responsibility | p. 616 |
Flyweight | p. 618 |
Interpreter | p. 620 |
Mediator | p. 622 |
Memento | p. 624 |
Prototype | p. 626 |
Visitor | p. 628 |
Index | p. 631 |
Table of Contents provided by Ingram. All Rights Reserved. |
The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.
The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.