From: dave.burt@... Date: 2005-08-12T12:41:11+09:00 Subject: Re: Head First Design Patterns - Strategy Pattern [was: Java/C# "interface" in Ruby ?] > Although Peter's demo didn't illustrate it, the key to the strategy pattern is > that the strategy can be dynamically chosen (and changed) at runtime. While the solution I gave is able to do that, thanks to Ruby's ease of reflection, if that's the case, maybe you do want to use delegation like I did above. If a Strategy is a single function, I'd probably do it more like this, though: Quack = proc do puts "Quack!" end DaffyQuack = proc do puts "Consequences, schmonsequences, as long as I'm rich!" end Class Duck def initialize() @quacker = Quack end def quack(*args, &block) @quacker.call(*args, &block) end def attr_writer :quacker end daffy = Duck.new daffy.quack #=> "Quack" daffy.quacker = DaffyQuack daffy.quack #=> "Consequences, schmonsequences, as long as I'm rich!" For multi-function/method strategies, you might consider using Forwardable to delegate specific methods to modules or objects in instance variables. Cheers, Dave