Pluggable BehaviorThe book has now been published and the content of this chapter has likely changed substanstially.
Add a variable that will be used to trigger different behavior.
Using Pluggable Behavior is a much better solution than creating a hundred different subclasses, each differing from each other in only one or two methods.
Pluggable Behavior lets us specify the behavior of an object at runtime. There are two common ways to implement Pluggable Behavior. Pluggable (Method) Selector lets us choose which existing method of the class to run while Pluggable Block lets the creator of the object specify an arbitrary block of code to run.
Further ReadingParaphrased from Kent Beck's book "Smalltalk Best Practice Patterns" [SBPP].
Copyright © 2003-2008 Gerard Meszaros all rights reserved