Design Patterns For Dummies®

Book description

There's a pattern here, and here's how to use it!


Find out how the 23 leading design patterns can save you time and trouble

Ever feel as if you've solved this programming problem before? You -- or someone -- probably did, and that's why there's a design pattern to help this time around. This book shows you how (and when) to use the famous patterns developed by the "Gang of Four," plus some new ones, all designed to make your programming life easier.

Discover how to:
* Simplify the programming process with design patterns
* Make the most of the Decorator, Factory, and Adapter patterns
* Identify which pattern applies
* Reduce the amount of code needed for a task
* Create your own patterns

Table of contents

  1. Copyright
  2. About the Author
  3. Dedication
  4. Author’s Acknowledgments
  5. Publisher’s Acknowledgments
  6. 00. Introduction
    1. 0.1. About This Book
    2. 0.2. Foolish Assumptions
    3. 0.3. Conventions Used in This Book
    4. 0.4. How This Book Is Organized
      1. 0.4.1. Part I: Getting to Know Patterns
      2. 0.4.2. Part II: Becoming an OOP Master
      3. 0.4.3. Part III: The Part of Tens
    5. 0.5. Icons Used in This Book
    6. 0.6. Where to Go from Here
  7. 1. Getting to Know Patterns
    1. 1. Congratulations, Your Problem Has Already Been Solved
      1. 1.1. Just Find the Pattern that Fits
      2. 1.2. Enter the Gang of Four Book
      3. 1.3. Getting Started: The Mediator Pattern
      4. 1.4. Adapting to the Adapter Pattern
      5. 1.5. Standing In for Other Objects with the Proxy Pattern
      6. 1.6. Taking a Look at the Observer Pattern
    2. 2. Putting Plans into Action with the Strategy Pattern
      1. 2.1. Extending Object-Oriented Programming
        1. 2.1.1. The big four OOP building blocks
          1. 2.1.1.1. Abstraction is the good kind of breakdown
          2. 2.1.1.2. Encapsulating all that junk
          3. 2.1.1.3. Mighty polymorphism rangers
          4. 2.1.1.4. Inheritance without the pesky taxes
        2. 2.1.2. Composition versus inheritance: A first attempt at designing the new cars
      2. 2.2. Handling Change with “has-a” Instead of “is-a”
      3. 2.3. Drawing Up Your Plans
        1. 2.3.1. Creating your algorithms
        2. 2.3.2. Using your algorithms
        3. 2.3.3. Selecting algorithms at runtime
      4. 2.4. Making Your Move with the Strategy Pattern
    3. 3. Creating and Extending Objects with the Decorator and Factory Patterns
      1. 3.1. Closed for Modification, Open for Extension
      2. 3.2. Enter the Decorator Pattern
      3. 3.3. Putting the Decorator Pattern to Work
        1. 3.3.1. Creating a decorator
        2. 3.3.2. Adding a disk
        3. 3.3.3. Adding a CD
        4. 3.3.4. Adding a monitor
        5. 3.3.5. Testing it out
      4. 3.4. Improving the New Operator with the Factory Pattern
      5. 3.5. Building Your First Factory
        1. 3.5.1. Creating the factory
        2. 3.5.2. Creating the abstract Connection class
        3. 3.5.3. Creating the concrete connection classes
        4. 3.5.4. Testing it out
      6. 3.6. Creating a Factory the GoF Way
        1. 3.6.1. Creating an abstract factory
        2. 3.6.2. Creating a concrete factory
        3. 3.6.3. Creating the secure connection classes
        4. 3.6.4. Testing it out
    4. 4. Watch What’s Going On with the Observer and Chain of Responsibility Patterns
      1. 4.1. Notifying Observers with the Observer Pattern
        1. 4.1.1. Creating a subject interface
        2. 4.1.2. Creating an observer interface
        3. 4.1.3. Creating a subject
        4. 4.1.4. Creating observers
        5. 4.1.5. Testing the Database observers
      2. 4.2. Using Java’s Observer Interface and Observable Class
        1. 4.2.1. Watching with the Observer interface
        2. 4.2.2. Notifying with the Observable class
        3. 4.2.3. Creating the Observable object
        4. 4.2.4. Creating the Observer objects
        5. 4.2.5. Testing the Observable code
      3. 4.3. Using the Chain of Responsibility Pattern
        1. 4.3.1. Creating a help interface
        2. 4.3.2. Creating chainable objects
        3. 4.3.3. Testing the Help system
    5. 5. From One to Many: The Singleton and Flyweight Patterns
      1. 5.1. Instantiating Just One Object with the Singleton Pattern
        1. 5.1.1. Creating a Singleton-based database
        2. 5.1.2. Testing the Singleton pattern
        3. 5.1.3. Uh oh, don’t forget about multithreading
        4. 5.1.4. Putting the synchronized solution to work
        5. 5.1.5. Handling threading better
        6. 5.1.6. Putting the pre-thread solution to work
      2. 5.2. The Flyweight Pattern Makes One Look like Many
        1. 5.2.1. Creating a student
        2. 5.2.2. Testing the Flyweight pattern
        3. 5.2.3. Handling threading better
  8. 2. Becoming an OOP Master
    1. 6. Fitting Round Pegs into Square Holes with the Adapter and Facade Patterns
      1. 6.1. The Adapter Scenario
      2. 6.2. Fixing Connection Problems with Adapters
        1. 6.2.1. Creating Ace objects
        2. 6.2.2. Creating Acme objects
        3. 6.2.3. Creating an Ace-to-Acme object adapter
        4. 6.2.4. Testing the adapter
        5. 6.2.5. Inheriting class adapters
      3. 6.3. Simplifying Life with Facades
        1. 6.3.1. Dealing with a difficult object
        2. 6.3.2. Creating a simplifying facade
        3. 6.3.3. Testing the facade
    2. 7. Mass Producing Objects with the Template Method and Builder Patterns
      1. 7.1. Creating the First Robot
      2. 7.2. Creating Robots with the Template Method Pattern
        1. 7.2.1. Creating robots by template
        2. 7.2.2. Testing the creation of robots
        3. 7.2.3. Built-in Template Methods in Java
        4. 7.2.4. Adding a hook
        5. 7.2.5. Testing the hook method
      3. 7.3. Building Robots with the Builder Pattern
        1. 7.3.1. The client rules
        2. 7.3.2. Letting clients build robots
        3. 7.3.3. Creating some buildable robots
        4. 7.3.4. Testing the robot builder
    3. 8. Handling Collections with the Iterator and Composite Patterns
      1. 8.1. Accessing Objects with the Iterator Pattern
        1. 8.1.1. Accessing your objects with an iterator
        2. 8.1.2. Gathering the vice presidents into a collection
        3. 8.1.3. Creating the iterator
        4. 8.1.4. Iterating over vice presidents
        5. 8.1.5. More fun with for/in
      2. 8.2. Putting Together Composites
        1. 8.2.1. It all starts with an abstract class
        2. 8.2.2. Creating the vice president leaves
        3. 8.2.3. Creating the division branches
        4. 8.2.4. Building your corporation
      3. 8.3. Tracking the Composite Pattern in the Wild
    4. 9. Getting Control of Your Objects with the State and Proxy Patterns
      1. 9.1. Getting the State of Your Union with the State Pattern
        1. 9.1.1. Using methods to hold state
        2. 9.1.2. Using objects to encapsulate state
        3. 9.1.3. Creating the state objects
        4. 9.1.4. Putting the rental automat to the test
      2. 9.2. Standing In for Other Objects with Proxies
        1. 9.2.1. Can you hear me now? Creating the automat server
        2. 9.2.2. Anyone there? Creating the automat proxy
        3. 9.2.3. Using the proxy to connect around the world
    5. 10. Coordinating Your Objects with the Command and Mediator Patterns
      1. 10.1. Taking Command with the Command Pattern
        1. 10.1.1. Aiming at the target: Creating your receiver objects
        2. 10.1.2. Be the boss: Creating your commands
        3. 10.1.3. Getting your commands to actually do something: Creating the invoker
        4. 10.1.4. Putting commands to the test
        5. 10.1.5. Supporting undo
        6. 10.1.6. Testing the undo
      2. 10.2. Coordinating with the Mediator Pattern
        1. 10.2.1. Designing the Rutabagas-R-Us site
        2. 10.2.2. Connecting it all up with the mediator
        3. 10.2.3. Testing the Rutabagas-R-Us site
  9. 3. The Part of Tens
    1. 11. Ten More Design Patterns
      1. 11.1. Creating a Factory Factory: The Abstract Factory Pattern
      2. 11.2. Cloning when You Need It: The Prototype Pattern
      3. 11.3. Decoupling Abstractions from Implementations with the Bridge Pattern
      4. 11.4. Creating Your Own Language: The Interpreter Pattern
      5. 11.5. Forget Me Not: The Memento Pattern
      6. 11.6. The Visitor Stops In for a Moment
      7. 11.7. Going in Circles with Circular Buffers
      8. 11.8. Doing Your Magic Off-Screen with the Double Buffer Pattern
      9. 11.9. Getting Multiple-Use Objects Out of the Recycle Bin Design Pattern
      10. 11.10. Entering the Big Time with the Model/View/Controller Pattern
    2. 12. Ten Easy Steps to Create Your Own Patterns
      1. 12.1. Following the Pattern Catalog Style
      2. 12.2. Introducing the Veto Pattern
        1. 12.2.1. Intent
        2. 12.2.2. Motivation
        3. 12.2.3. Applicability
        4. 12.2.4. Structure
        5. 12.2.5. Participants
        6. 12.2.6. Collaborations
        7. 12.2.7. Consequences
        8. 12.2.8. Implementation/Sample Code
        9. 12.2.9. Known Uses
        10. 12.2.10. Related Patterns
      3. 12.3. Getting Your Pattern into a Pattern Catalog
  10. A. Design Patterns For Dummies®
    1. A.1. The 23 Gang of Four Design Patterns
      1. A.1.1. The Strategy design pattern
      2. A.1.2. The Decorator design pattern
      3. A.1.3. The Factory Method design pattern
      4. A.1.4. The Observer design pattern
      5. A.1.5. The Chain of Responsibility design pattern
      6. A.1.6. The Singleton design pattern
      7. A.1.7. The Flyweight design pattern
      8. A.1.8. The Adapter design pattern
      9. A.1.9. The Facade design pattern
      10. A.1.10. The Template design pattern
      11. A.1.11. The Builder design pattern
      12. A.1.12. The Iterator design pattern
      13. A.1.13. The Composite design pattern
      14. A.1.14. The Command design pattern
      15. A.1.15. The Mediator design pattern
      16. A.1.16. The State design pattern
      17. A.1.17. The Proxy design pattern
      18. A.1.18. The Abstract Factory design pattern
      19. A.1.19. The Prototype design pattern
      20. A.1.20. The Bridge design pattern
      21. A.1.21. The Interpreter design pattern
      22. A.1.22. The Memento design pattern
      23. A.1.23. The Visitor design pattern

Product information

  • Title: Design Patterns For Dummies®
  • Author(s): Steve Holzner Ph.D.
  • Release date: May 2006
  • Publisher(s): Wiley
  • ISBN: 9780471798545