Foreword
Preface
About the Authors
List of Design Patterns
Section 1 Agile Development
Chapter 1 Agile Practices
The Agile Alliance
The Manifesto of the Agile Alliance
Principles
Conclusion
Bibliography
Chapter 2 Overview of Extreme Programming
The Practices of Extreme Programming
Customer Team Member
User Stories
Short Cycles
Acceptance Tests
Pair Programming
Test-Driven Development
Collective Ownership
Continuous Integration
Sustainable Pace
Open Workspace
The Planning Game
Simple Design
Refactoring
Metaphor
Conclusion
Bibliography
Chapter3 Planning
Initial Exploration
Spiking, Splitting, and Velocity
Release Planning
Iteration Planning
Task Planning
The Halfway Point
Iterating
Conclusion
Bibliography
Chapter 4 Testing
Test Driven Development
An Example of Test-First Design
Test Isolation
Serendipitous De. coupling
Acceptance Tests
Example of Acceptance Testing
Serendipitous Architecture
Conclusion
Bibliography
Chapter 5 Refactoring
Generating Primes: A Simple Example of Refactoring
The Final Reread
Conclusion
Bibliography
Chapter 6 A Programming Episode
The Bowling Game
Conclusion
Section 2 Agile Design
Symptoms of Poor Design
Principles
Smells and Principles
Bibliography
Chapter 7 What Is Agile Design?
What Goes Wrong with Software?
Design Smells--The Odors of Rotting Software
What Stimulates the Software to Rot?
Agile Teams Don't Allow the Software to Rot
The "Copy" Program
Agile Design of the Copy Example
How Did the Agile Developers Know What to Do?
Keeping the Design As Good As It Can Be
Conclusion
Bibliography
Chapter 8 SRP: The Single-Responsibility Principle
A CLASS SHOULD HAVE ONLY ONE REASON TO CHANGE.
SRP: The Single-Responsibility Principle
What Is a Responsibility?
Separating Coupled Responsibilities
Persistence
Conclusion
Bibliography
Chapter 9 OCP: The Open-Closed Principle
SOFTWARE ENTTTIES (CLASSES, MODULES, FUNCTIONS, ETC. ) SHOULD BE OPEN
FOR EXTENSION, BUT CLOSED FOR MODIFICATION.
OCP: The Open-Closed Principle
Description
Abstraction Is the Key
The Shape Application
Violating the OCP
Conforming to the OCP
OK, I Lied
Anticipation and "Natural" Structure
Putting the "Hooks" In
Using Abstraction to Gain Explicit Closure
Using a "Data-Driven" Approach to Achieve Closure
Conclusion
Bibliography
Chapter 10 LSP: The Liskov Substitution Principle
SUBTYPES MUST BE SUBSTITUTABLE FOR THEIR BASE TYPES.
LSP: The Liskov Substitution Principle
A Simple Example of a Violation of the LSP
Square and Rectangle, a More Subtle Violation
The Real Problem
Validity Is Not Intrinsic
ISA Is about Behavior
Design by Contract
Specifying Contracts in Unit Tests
A Real Example
Motivation
Problem
A Solution That Does Not Conform to the LSP
An LSP-Compliant Solution
Factoring Instead of Deriving
Heuristics and Conventions
Degenerate Functions in Derivatives
Throwing Exceptions from Derivatives
Conclusion
Bibliography
Chapter 11 DIP: The Dependency-Inversion Principle
A. HIGH-LEVEL MODULES SHOULD NOT DEPEND UPON LOW-LEVEL MODULES.
BOTH SHOULD DEPEND ON ABSTRACTIONS.
B. ABSTRACTIONS SHOULD NOT DEPEND ON DETAILS. DETAILS SHOULD
DEPEND ON ABSTRACTIONS.
DIP: The Dependency-Inversion Principle
Layering
An Inversion of Ownership
Depend on Abstractions
A Simple Example
Finding the Underlying Abstraction
The Furnace Example
Dynamic v. Static Polymorphism
Conclusion
Bibliography
Chapter 12 ISP: The Interface-Segregation Principle
Interface Pollution
Separate Clients Mean Separate Interfaces
The Backwards Force Applied by Clients Upon Interfaces
CLIENTS SHOULD NOT BE FORCED TO DEPEND ON METHODS THAT THEY DO
NOT USE.
ISP: The Interface-Segregation Principle
Class Interfaces v. Object Interfaces
Separation through Delegation
Separation through Multiple Inheritance
The ATM User Interface Example
The Polyad v. the Monad
Conclusion
Bibliography
Section 3 The Payroll Case Study
Rudimentary Specification of the Payroll System
Exercise
Use Case 1: Add New Employee
Use Case 2: Deleting an Employee
Use Case 3: Post a Time Card
Use Case 4: Posting a Sales Receipt
Use Case 5: Posting a Union Service Charge
Use Case 6: Changing Employee Details
Use Case 7: Run the Payroll for Today
Chapter 13 COMMAND and ACTIVE OBJECT
Simple Commands
Transactions
Physical and Temporal Decoupling
Temporal Decoupling
UNDO
ACTIVE OBJECT
Conclusion
Bibliography
Chapter 14 TEMPLATE METHOD & STRATEGY: Inheritance vs. Delegation
TEMPLATE METHOD
Pattern Abuse
Bubble Sort
STRATEGY
Sorting Again
Conclusion
Bibliography
Chapter 15 FACADE and MEDIATOR
FACADE
MEDIATOR
Conclusion
Bibliography
Chapter 16 SINGLETON and MONOSTATE
SINGLETON
Benefits of the SINGLETON
Costs of the SINGLETON
SINOLETON in Action
MONOSTATE
Benefits of MONOSTATE
Costs of MONOSTATE
MONOSTATE in Action
Conclusion
Bibliography
Chapter 17 NULL OBJECT
Conclusion
Bibliography
Chapter 18 The Payroll Case Study: Iteration One Begins
Introduction
Specification
Analysis by Use Cases
Adding Employees
Deleting Employees
Posting Time Cards
Posting Sales Receipts
Posting a Union Service Charge
Changing Employee Details
Payday
Reflection: What Have We Learned?
Finding the Underlying Abstractions
The Schedule Abstraction
Payment Methods
Affiliations
Conclusion
Bibliography
Chapter 19 The Payroll Case Study: Implementation
Adding Employees
The Payroll Database
Using TEMPLATE METHOD tO Add Employees
Deleting Employees
Global Variables
Time Cards, Sales Receipts, and Service Charges
Changing Employees
Changing Classification
What Was I Smoking?
Paying Employees
Do We Want Developers Making Business Decisions?
Paying Salaried Employees
Paying Hourly Employees
Pay Periods: A Design Problem
Main Program
The Database
Summary of Payroll Design
History
Resources
Bibliography
Section 4 Packaging the Payroll System
Chapter 20 Principles of Package Design
Designing with Packages?
Granularity: The Principles of Package Cohesion
The Reuse-Release Equivalence Principle (REP)
THE GRANULE OF REUSE IS THE GRANULE OF RELEASE.
The Common-Reuse Principle (CUP)
THE CLASSES INA PACKAGE ARE REUSED TOGETHER. IF YOU REUSE ONE OF THE
CLASSES IN A PACKAGE, YOU REUSE THEM ALL.
The Common-Closure Principle (CCP)
THE CLASSES IN A PACKAGE SHOULD BE CLOSED TOGETHER AGAINST THE SAME
KINDS OF CHANGES. A CHANGE THAT AFFECTS A PACKAGE AFFECTS ALL THE
CLASSES IN THAT PACKAGE AND NO OTHER PACKAGES.
Summary of Package Cohesion
Stability: The Principles of Package Coupling
The Acyclic-Dependencies Principle (ADP)
ALLOW NO CYCLES IN THE PACKAGE DEPENDENCY GRAPH.
The Weekly Build
Eliminating Dependency Cycles
The Effect of a Cycle in the Package Dependency Graph
Breaking the Cycle
The "Jitters"
Top-Down Design
The Stable-Dependencies Principle (SDP)
DEPEND IN THE DIRECTION OF STABILITY.
Stability
Stability Metrics
Not All Packages Should Be Stable
Where Do We Put the High-level Design?
The Stable-Abstractions Principle (SAP)
A PACKAGE SHOULD BE AS ABSTRACT AS IT IS STABLE.
Measuring Abstraction
The Main Sequence
Distance from the Main Sequence
Conclusion
Chapter21 FACTORY
A Dependency Cycle
Substitutable Factories
Using Factories for Test Fixtures
How Important Is It to Use Factories?
Conclusion
Bibliography
Chapter22 The Payroll Case Study (Part 2)
Package Structure and Notation
Applying the Common. Closure Principle (CCP)
Applying the Reuse-Release Equivalency Principle (REP)
Coupling and Encapsulation
Metrics
Applying the Metrics to the Payroll Application
Object Factories
The Object Factory for Transactionlmplementation
Initializing the Factories
Rethinking the Cohesion Boundaries
The Final Package Structure
Conclusion
Bibliography
Section 5 The Weather Station Case Study
Chapter23 COMPOSITE
Example: Composite Commands
Multiplicity or Not Multiplicity
Chapter 24 OBSERVER--Backing into a Pattern
The Digital Clock
Conclusion
The Use of Diagrams in this Chapter
The OBSERVER Pattern
How OBSERVER Manages the Principles of OOD
Bibliography
Chapter 25 ABSTRACT SERVER, ADAPTER, and BRIDGE
ABSTRACT SERVER
Who Owns the Interface?
Adapter
The Class Form of ADAPTER
The Modem Problem, ADAPTERS and LSP
BRIDGE
Conclusion
Bibliography
Chapter 26 PROXY and STAIRWAY TO HEAVEN: Managing Third Party APIs
PROXY
Proxifying the Shopping Cart
Summary of PROXY
Dealing with Databases, Middleware, and Other Third Party Interfaces
STAIRWAY TO HEAVEN
Example of STAIRWAY TO HEAVEN
Other Patterns That Can Be Used with Databases
Conclusion
Bibliography
Chapter 27 Case Study: Weather Station
The Cloud Company
The WMS-LC Software
Language Selection
Nimbus-LC Software Design
24-Hour History and Persistence
Implementing the HiLo Algorithms
Conclusion
Bibliography
Nimbus-LC Requirements Overview
Usage Requirements
24-Hour History
User Setup
Administrative Requirements
Nimbus-LC Use Cases
Actors
Use Cases
Measurement History
Setup
Administration
Nimbus-LC Release Plan
Introduction
Release I
Risks
Deliverable(s)
Release II
Use Cases Implemented
Risks
Deliverable(s)
Release III
Use Cases Implemented
Risks
Deliverable(s)
Section 6 The ETS Case Study
Chapter28 VISITOR
The VISITOR Family of Design Patterns
VISITOR
VisrrOR is Like a Matrix
ACYCLIC VISITOR
ACYCLIC VISITOR Is Like a Sparse Matrix
Using VISITOR in Report Generators
Other Uses of VISITOR
DECORATOR
Multiple Decorators
EXTENSION OBJECT
Conclusion
Reminder
Bibliography
Chapter29 STATE
Overview of Finite State Automata
Implementation Techniques
Nested Switch/Case Statements
Interpreting Transition Tables
The STATE Pattern
SMC--The State-Machine Compiler
Where Should State Machines be Used?
High-Level Application Policies for GUIs
GUI Interaction Controllers
Distributed Processing
Conclusion
Listings
Turnstile. java Using Table Interpretation
Turnstile. java Generated by SMC, and Other Support Files
Bibliography
Chapter 30 The ETS Framework
Introduction
Project Overview
Early History 1993-1994
Framework?
Framework!
The 1994 Team
The Deadline
The Strategy
Results
Framework Design
The Common Requirements of the Scoring Applications
The Design of the Scoring Framework
A Case for TEMPLATE METHOD
Write a Loop Once
The Common Requirements of the Delivery Applications
The Design of the Delivery Framework
The Taskmaster Architecture
Conclusion
Bibliography
Appendix A UML Notation I: The CGI Example
Course Enrollment System: Problem Description
Actors
Use Cases
The Domain Model
The Architecture
Abstract Classes and Interfaces in Sequence Diagrams
Summary
Bibliography
Appendix B UML Notation II: The STATMUX
The Statistical Multiplexor Definition
The Software Environment
The Real-time Constraints
The Input Interrupt Service Routine
The Output Service Interrupt Routine
The Communications Protocol
Conclusion
Bibliography
Appendix C A Satire of Two Companies
Rufus, Inc.
Project Kickoff
Rupert Industries
Project: -Alpha-
Appendix D The Source Code Is the Design
What Is Software Design?
Afterword
Index