Contents
Foreword
Preface
Acknowledgments
About the Authors
Section I: Agile Development
Chapter 1: Agile Practices
The Agile Alliance
Individuals and Interactions over Processes and Tools
Working Software over Comprehensive Documentation
Customer Collaboration over Contract Negotiation
Responding to Change over Following a Plan
Principles
Conclusion
Bibliography
Chapter 2: Overview of Extreme Programming
The Practices of Extreme Programming
Whole Team
User Stories
Short Cycles
Acceptance Tests
Pair Programming
Test-Driven Development (TDD)
Collective Ownership
Continuous Integration
Sustainable Pace
Open Workspace
The Planning Game
Simple Design
Refactoring
Metaphor
Conclusion
Bibliography
Chapter 3: Planning
Initial Exploration
Spiking, Splitting, and Velocity
Release Planning
Iteration Planning
Defining “Done”
Task Planning
Iterating
Tracking
Conclusion
Bibliography
Chapter 4: Testing
Test-Driven Development
Example of Test-First Design
Test Isolation
Serendipitous Decoupling
Acceptance Tests
Serendipitous Architecture
Conclusion
Bibliography
Chapter 5: Refactoring
A Simple Example of Refactoring: Generating Primes
Unit Testing
Refactoring
The Final Reread
Conclusion
Bibliography
Chapter 6: A Programming Episode
The Bowling Game
Conclusion
Overview of the Rules of Bowling
Section II: Agile Design
Chapter 7: What Is Agile Design?
Design Smells
Design Smells—The Odors of Rotting Software
Rigidity
Fragility
Immobility
Viscosity
Needless Complexity
Needless Repetition
Opacity
Why Software Rots
The Copy
Program
A Familiar Scenario
Agile Design of the Copy
Program
Conclusion
Bibliography
Chapter 8: The Single-Responsibility Principle (SRP)
Defining a Responsibility
Separating Coupled Responsibilities
Persistence
Conclusion
Bibliography
Chapter 9: The Open/Closed Principle (OCP)
Description of OCP
The Shape
Application
Violating OCP
Conforming to OCP
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: The Liskov Substitution Principle (LSP)
Violations of LSP
A Simple Example
A More Subtle Violation
A Real-World Example
Factoring Instead of Deriving
Heuristics and Conventions
Conclusion
Bibliography
Chapter 11: The Dependency-Inversion Principle (DIP)
Layering
Ownership Inversion
Dependence on Abstractions
A Simple DIP Example
Finding the Underlying Abstraction
The Furnace
Example
Conclusion
Bibliography
Chapter 12: The Interface Segregation Principle (ISP)
Interface Pollution
Separate Clients Mean Separate Interfaces
Class Interfaces versus Object Interfaces
Separation Through Delegation
Separation Through Multiple Inheritance
The ATM User Interface Example
Conclusion
Bibliography
Chapter 13: Overview of UML for C# Programmers
Class Diagrams
Object Diagrams
Sequence Diagrams
Collaboration Diagrams
State Diagrams
Conclusion
Bibliography
Chapter 14: Working with Diagrams
Why Model?
Why Build Models of Software?
Should We Build Comprehensive Designs Before Coding?
Making Effective Use of UML
Communicating with Others
Road Maps
Back-End Documentation
What to Keep and What to Throw Away
Iterative Refinement
Behavior First
Check the Structure
Envisioning the Code
Evolution of Diagrams
When and How to Draw Diagrams
When to Draw Diagrams and When to Stop
CASE Tools
But What About Documentation?
Conclusion
Chapter 15: State Diagrams
The Basics
Special Events
Superstates
Initial and Final Pseudostates
Using FSM Diagrams
Conclusion
Chapter 16: Object Diagrams
A Snapshot in Time
Active Objects
Conclusion
Chapter 17: Use Cases
Writing Use Cases
Alternate Courses
What Else?
Diagramming Use Cases
Conclusion
Bibliography
Chapter 18: Sequence Diagrams
The Basics
Objects, Lifelines, Messages, and Other Odds and Ends
Creation and Destruction
Simple Loops
Cases and Scenarios
Advanced Concepts
Loops and Conditions
Messages That Take Time
Asynchronous Messages
Multiple Threads
Active Objects
Sending Messages to Interfaces
Conclusion
Chapter 19: Class Diagrams
The Basics
Classes
Association
Inheritance
An Example Class Diagram
The Details
Class Stereotypes
Abstract Classes
Properties
Aggregation
Composition
Multiplicity
Association Stereotypes
Nested Classes
Association Classes
Association Qualifiers
Conclusion
Bibliography
Chapter 20: Heuristics and Coffee
The Mark IV Special Coffee Maker
Specification
A Common but Hideous Solution
Imaginary Abstraction
An Improved Solution
Implementing the Abstract Model
The Benefits of This Design
OOverkill
Bibliography
Section III: 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 21: Command and Active Object: Versatility and Multitasking
Simple Commands
Transactions
Physical and Temporal Decoupling
Temporal Decoupling
Undo
Method
Active Object
Conclusion
Bibliography
Chapter 22: Template Method and Strategy: Inheritance versus Delegation
Template Method
Pattern Abuse
Bubble Sort
Strategy
Conclusion
Bibliography
Chapter 23: Facade and Mediator
Facade
Mediator
Conclusion
Bibliography
Chapter 24: Singleton and Monostate
Singleton
Benefits
Costs
Singleton in Action
Monostate
Benefits
Costs
Monostate in Action
Conclusion
Bibliography
Chapter 25: Null Object
Description
Conclusion
Bibliography
Chapter 26: The Payroll Case Study: Iteration 1
Rudimentary 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: Finding the Underlying Abstractions
Employee Payment
Payment Schedule
Payment Methods
Affiliations
Conclusion
Bibliography
Chapter 27: The Payroll Case Study: Implementation
Transactions
Adding Employees
Deleting Employees
Time Cards, Sales Receipts, and Service Charges
Changing Employees
What Was I Smoking?
Paying Employees
Paying Salaried Employees
Paying Hourly Employees
Main Program
The Database
Conclusion
About This Chapter
Bibliography
Section IV: Packaging the Payroll System
Chapter 28: Principles of Package and Component Design
Packages and Components
Principles of Component Cohesion: Granularity
The Reuse/Release Equivalence Principle (REP)
The Common Reuse Principle (CRP)
The Common Closure Principle (CCP)
Summary of Component Cohesion
Principles of Component Coupling: Stability
The Acyclic Dependencies Principle (ADP)
The Stable-Dependencies Principle (SDP)
The Stable-Abstractions Principle (SAP)
Conclusion
Chapter 29: Factory
A Dependency Problem
Static versus Dynamic Typing
Substitutable Factories
Using Factories for Test Fixtures
Importance of Factories
Conclusion
Bibliography
Chapter 30: The Payroll Case Study: Package Analysis
Component Structure and Notation
Applying the Common Closure Principle (CCP)
Applying the Reuse/Release Equivalence Principle (REP)
Coupling and Encapsulation
Metrics
Applying the Metrics to the Payroll Application
Object Factories
Rethinking the Cohesion Boundaries
The Final Packaging Structure
Conclusion
Bibliography
Chapter 31: Composite
Composite Commands
Multiplicity or No Multiplicity
Conclusion
Chapter 32: Observer: Evolving into a Pattern
The Digital Clock
The Observer Pattern
Models
Management of OOD Principles
Conclusion
Bibliography
Chapter 33: Abstract Server, Adapter, and Bridge
Abstract Server
Adapter
The Class Form of Adapter
The Modem Problem, Adapters, and LSP
Bridge
Conclusion
Bibliography
Chapter 34: Proxy and Gateway: Managing Third-Party APIs
Proxy
Implementing Proxy
Summary
Databases, Middleware, and Other Third-Party Interfaces
Table Data Gateway
Testing and In-Memory TDGs
Testing the DB
Gateways
Using Other Patterns with Databases
Conclusion
Bibliography
Chapter 35: Visitor
Visitor
Acyclic Visitor
Uses of Visitor
Decorator
Extension Object
Conclusion
Bibliography
Chapter 36: State
Nested Switch/Case
Statements
The Internal Scope State Variable
Testing the Actions
Costs and Benefits
Transition Tables
Using Table Interpretation
Costs and Benefits
The State Pattern
State versus Strategy
Costs and Benefits
The State Machine Compiler (SMC)
Turnstile.cs
Generated by SMC, and Other Support Files
Classes of State Machine Application
High-Level Application Policies for GUIs
GUI Interaction Controllers
Distributed Processing
Conclusion
Bibliography
Chapter 37: The Payroll Case Study: The Database
Building the Database
A Flaw in the Code Design
Adding an Employee
Transactions
Loading an Employee
What Remains?
Chapter 38: The Payroll User Interface: Model View Presenter
The Interface
Implementation
Building a Window
The Payroll Window
The Unveiling
Conclusion
Bibliography
Appendix A: A Satire of Two Companies
Rufus Inc.: Project Kickoff
Rupert Industries: Project Alpha
Appendix B: What Is Software?
Index