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.



Get this Album

Volume Licensing

Have Any Questions?

Highlights

Instant Critiques: Take a refactoring exercise and get instant feedback from our automated band of experts. Learn more...
Delegation Patterns: Learn a collection of patterns that produce better designs by favoring delegation over inheritance. Learn more...

Expert Videos: Learn tools & techniques by watching short videos from industry experts. Learn more...
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

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

Supported Browsers

  • Latest Firefox
  • Internet Explorer 8+
  • Latest Chrome
  • Latest Safari

Operating Systems

  • Windows
  • Linux
  • Mac OS X

Development Tools

You can use whatever developments tools you prefer. If you do use an IDE (Integrated Development Environment), many (though not all) of our labs come with projects pre-configured for Eclipse, IntelliJ and Visual Studio.

Speakers or headphones are required for our videos.

Flash is required to view charts or watch videos — download for free.