By Joshua Kerievsky, Brian Foote

Broaden your knowledge with State, Observer, Null Object, and more. Our final volume of Design Patterns features some of the most elaborate and exotic patterns. You'll find mainstays like State and Observer, along with patterns with more challenging reputations, like Command and Visitor.

Get this Album

Volume Licensing

Have Any Questions?


Advanced Patterns: Learn advanced patterns like State, Null Object, Command and Visitor. 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...


  • 6-8 hours of content
  • 89 pages of content
  • 6 Patterns
  • 4 Exercises
  • 5 Quizzes
  • 9 Videos
  • Support for Eclipse
  • Support for IntelliJ


State 5
Vehicle State Transitions 6
State Vehicle Example 7
State Vehicle Enum Example 8
Simple Vehicle 9
Who Controls State Transitions? 10
Which State Design Do You Like Best? 11
State: The Players 12
Introduction ← Click to Preview 14
What Needs To Be Refactored? 15
SystemPermission Using The State Pattern 16
Problem Code 17
Critiquing Your Performance 18
Download and Setup Instructions 19
Upload Your Exercise 20
A Graph of Your Refactoring & Testing Activity 21
Your Critique Results 22
Your Customized Feedback 23
Solution Code 24
Command 26
Command Essence ← Click to Preview 27
A Classic Example 28
Command: The Players 29
Executing and Unexecuting Commands 30
Observer 32
Observer The Essence 33
Observer Players ← Click to Preview 34
Bad or Good? 35
A Problem to Solve 37
Problem Source Code 38
Refactoring Guidance 39
Download, Build & Test Instructions 40
Solution 41
Solution Source Code 42
Dependency Injection 44
What is Dependency? 45
What is a Service Locator? 46
What is Dependency Injection? ← Click to Preview 47
What is Inversion of Control? 48
How Does the Injector Know What to Inject? 49
Ravioli Code 50
Casting 51
Stunt Doubles 52
The A-List 53
Iterator 55
Iterator Players ← Click to Preview 56
Iterator Benefits 57
Concurrent Modification? 58
Iterator Loan Quiz ← Click to Preview 59
Identifying Iterators and Other Patterns… 60
A Problem to Solve 62
Problem Source Code 63
Refactoring Guidance 64
Critiquing Your Performance 65
Download, Build & Test Instructions 66
Upload Your Exercise 67
A Graph of Your Refactoring & Testing Activity 68
Your Critique Results 69
Your Customized Feedback 70
Solution Source Code 71
Visitor is Confusing at First 76
Start with an Interpreter 77
Evaluating Expression Visitor 78
Extra Credit 79
Refactoring to Visitor Solution 80
Downcast Solution 81
Overloaded Solution 82
Generic Solution 83
Stack Solution 84
Alternate Solution 85
Visitor Spreadsheet Exercise: Groundwork 86
Visitor Spreadsheet Exercise: Preliminaries 87
Visitor Spreadsheet Exercise: Solution 88
Visitor Spreadsheet Exercise: Clean Up 89

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.