Design Patterns Vol. 2

Producing Simpler Designs with Object Composition — Java Edition

Art for Design Patterns Vol. 2 Check Out A Preview

By Joshua Kerievsky, Brian Foote

Our second volume of Design Patterns focuses on important variations on a classic object-oriented theme: how to best delegate or forward to cooperating objects, rather than using brute-force inheritance, to get things done. We explore a common theme in object-oriented design: favoring delegation over inheritance. The album draws from the Gang-of-Four's Structural and Behavioral patterns and uses them as a starting point.

Highlights

Instant Critiques
Instant Critiques: Take a refactoring exercise and get instant feedback from our automated band of experts. Learn more...
Delegation Patterns
Delegation Patterns: Learn a collection of patterns that produce better designs by favoring delegation over inheritance. Learn more...
Expert Videos
Expert Videos: Learn tools & techniques by watching short videos from industry experts. Learn more...
Integrated Forums
Integrated Forums: Ask questions, get expert replies and read fascinating discussions. Learn more...

Includes

  • 4-6 hours of content
  • 138 pages of content
  • 5 Exercises
  • 11 Quizzes
  • 8 Patterns
  • 12 Videos
  • Support for Eclipse
  • Support for IntelliJ

Contents

Inside Volume Two ← Click to Preview 3
The Duh Test 4
What's in a Name? 5
Composite 7
Essence of the Composite Pattern ← Click to Preview 8
The One/Many Distinction 9
Refactoring A One/Many Distinction 10
Composite Players 11
JUnit: A Classic Composite 12
XML: A Natural Composite 13
Know Your Composites 14
HTML is a Natural Composite 16
Download, Build & Test Instructions 17
Unnecessary Conditional Logic 18
Part One 19
Part Two 20
Solution 21
Builder 23
Why Do We Love Builders? 24
Complicated, Repetitive and Verbose Composite Construction 25
TagNode: What Needs Improvement? 26
Which TagBuilder Is Better? 27
Understanding TagBuilder 28
Building Different Products Using Identical Construction Steps 29
Builder: The Players 30
Decoupling Construction Logic With A Builder 31
Builder Quiz 32
Interpreter 34
Interpreter: The Essence 35
The Interpreter Pattern is Not About Parsing 36
Interpreter: The Players 37
Introduction ← Click to Preview 39
Search Expressions 40
Example Expression 41
Your Challenge 42
Problem Code 43
Critiquing Your Performance 44
Download and Setup Instructions 45
Upload Your Exercise 46
A Graph of Your Refactoring & Testing Activity 47
Your Critique Results 48
Your Customized Feedback 49
Solution 50
Lambda Solution 51
Expression Interpreter Problem 53
How to Construct Expressions 54
Test First 55
Extra Credit 56
Things to Test 57
Starter Code 58
Download and Setup Instructions 59
Expression Interpreter Solution 60
Pretty Printer Solution 61
Chain of Responsibility 63
Essence of the Chain of Responsibility 64
Tough Ticket 65
Mike to the Rescue 66
Meet Mike the Scalper ← Click to Preview 67
Mike's Supply Chain 68
The Buck Stops Here 69
The Players 70
What Could Go Wrong 71
Null Anchor Example 72
Null Object 74
Too Many Null Checks! 75
Null Object To The Rescue! 76
When Is A Null Object Unnecessary? 77
Null Object Players ← Click to Preview 78
Much Ado About Nothing 79
Bridge 81
Abstract Windowing Toolkit Example of Bridge 82
MFC Example of Bridge ← Click to Preview 83
Adapter 85
Adapter: The Essence 86
Adapter: The Players 87
Adapter Example 88
Two-Way Adapters 89
Adapter: The Quiz 90
In Need Of An Adapter ← Click to Preview 92
Choosing A Preferred Interface 93
Problem Source Code 94
Refactoring Guidance 95
Critiquing Your Performance 96
Download, Build & Test Instructions 97
Upload Your Exercise 98
A Graph of Your Refactoring & Testing Activity 99
Your Critique Results 100
Your Customized Feedback 101
Solution Video Step 1: Extract Interface ← Click to Preview 102
Solution Video Step 2: Extract Class 103
Solution Video Step 3: Move Method 104
Solution Video Step 4: Implement Interface 105
Solution Video Step 5: Pull Up Fields & Methods 106
Solution 107
Decorator 109
Bloated Objects 110
Avoiding Bloat 111
Decorator: The Players 112
How JUnit Avoided Featuritis 113
Patterns and Players Quiz 114
A Problem to Solve 116
Decoding Character References 117
Problem Source Code 118
Refactoring Guidance 119
Download, Build & Test Instructions 120
Solution 121
Solution Source Code 122
Proxy 124
Proxy: A Stand-In for Another Object 125
Proxy: The Players 126
Proxies Do Computational Chores 127
Chaining Proxies 128
Caching Proxy 129
Protection Proxy 130
Dynamic Proxy 131
A Problem to Solve 133
Problem Source Code 134
Refactoring Guidance 135
Download, Build & Test Instructions 136
Solution Source Code 137
Alternative Solution Source Code 138

Related Items

Volume Licensing

Have Any Questions?

Highlights

Instant Critiques
Instant Critiques: Take a refactoring exercise and get instant feedback from our automated band of experts. Learn more...
Delegation Patterns
Delegation Patterns: Learn a collection of patterns that produce better designs by favoring delegation over inheritance. Learn more...
Expert Videos
Expert Videos: Learn tools & techniques by watching short videos from industry experts. Learn more...
Integrated Forums
Integrated Forums: Ask questions, get expert replies and read fascinating discussions. Learn more...

Includes

  • 4-6 hours of content
  • 138 pages of content
  • 5 Exercises
  • 11 Quizzes
  • 8 Patterns
  • 12 Videos
  • Support for Eclipse
  • Support for IntelliJ

Contents

Inside Volume Two ← Click to Preview 3
The Duh Test 4
What's in a Name? 5
Composite 7
Essence of the Composite Pattern ← Click to Preview 8
The One/Many Distinction 9
Refactoring A One/Many Distinction 10
Composite Players 11
JUnit: A Classic Composite 12
XML: A Natural Composite 13
Know Your Composites 14
HTML is a Natural Composite 16
Download, Build & Test Instructions 17
Unnecessary Conditional Logic 18
Part One 19
Part Two 20
Solution 21
Builder 23
Why Do We Love Builders? 24
Complicated, Repetitive and Verbose Composite Construction 25
TagNode: What Needs Improvement? 26
Which TagBuilder Is Better? 27
Understanding TagBuilder 28
Building Different Products Using Identical Construction Steps 29
Builder: The Players 30
Decoupling Construction Logic With A Builder 31
Builder Quiz 32
Interpreter 34
Interpreter: The Essence 35
The Interpreter Pattern is Not About Parsing 36
Interpreter: The Players 37
Introduction ← Click to Preview 39
Search Expressions 40
Example Expression 41
Your Challenge 42
Problem Code 43
Critiquing Your Performance 44
Download and Setup Instructions 45
Upload Your Exercise 46
A Graph of Your Refactoring & Testing Activity 47
Your Critique Results 48
Your Customized Feedback 49
Solution 50
Lambda Solution 51
Expression Interpreter Problem 53
How to Construct Expressions 54
Test First 55
Extra Credit 56
Things to Test 57
Starter Code 58
Download and Setup Instructions 59
Expression Interpreter Solution 60
Pretty Printer Solution 61
Chain of Responsibility 63
Essence of the Chain of Responsibility 64
Tough Ticket 65
Mike to the Rescue 66
Meet Mike the Scalper ← Click to Preview 67
Mike's Supply Chain 68
The Buck Stops Here 69
The Players 70
What Could Go Wrong 71
Null Anchor Example 72
Null Object 74
Too Many Null Checks! 75
Null Object To The Rescue! 76
When Is A Null Object Unnecessary? 77
Null Object Players ← Click to Preview 78
Much Ado About Nothing 79
Bridge 81
Abstract Windowing Toolkit Example of Bridge 82
MFC Example of Bridge ← Click to Preview 83
Adapter 85
Adapter: The Essence 86
Adapter: The Players 87
Adapter Example 88
Two-Way Adapters 89
Adapter: The Quiz 90
In Need Of An Adapter ← Click to Preview 92
Choosing A Preferred Interface 93
Problem Source Code 94
Refactoring Guidance 95
Critiquing Your Performance 96
Download, Build & Test Instructions 97
Upload Your Exercise 98
A Graph of Your Refactoring & Testing Activity 99
Your Critique Results 100
Your Customized Feedback 101
Solution Video Step 1: Extract Interface ← Click to Preview 102
Solution Video Step 2: Extract Class 103
Solution Video Step 3: Move Method 104
Solution Video Step 4: Implement Interface 105
Solution Video Step 5: Pull Up Fields & Methods 106
Solution 107
Decorator 109
Bloated Objects 110
Avoiding Bloat 111
Decorator: The Players 112
How JUnit Avoided Featuritis 113
Patterns and Players Quiz 114
A Problem to Solve 116
Decoding Character References 117
Problem Source Code 118
Refactoring Guidance 119
Download, Build & Test Instructions 120
Solution 121
Solution Source Code 122
Proxy 124
Proxy: A Stand-In for Another Object 125
Proxy: The Players 126
Proxies Do Computational Chores 127
Chaining Proxies 128
Caching Proxy 129
Protection Proxy 130
Dynamic Proxy 131
A Problem to Solve 133
Problem Source Code 134
Refactoring Guidance 135
Download, Build & Test Instructions 136
Solution Source Code 137
Alternative Solution Source Code 138

Related Items