Wow, Jim, Dave, Thank you for your advice.

It has been truly enjoyable reading you converse about the
implementation variations of Strategy Pattern.

I am a mere grasshopper.  I will post more on my quest and hope to learn
more from you, gurus.

Regards, 


Peter J. Fitzgibbons
Applications Manager
Lakewood Homes - "The American Dream Builder"(r)
Peter.Fitzgibbons / Lakewoodhomes.net
(847) 884-8800 


-----Original Message-----
From: Dave Burt [mailto:dave / burt.id.au] 
Sent: Friday, August 12, 2005 2:36 AM
To: ruby-talk ML
Subject: Re: Head First Design Patterns - Strategy Pattern [was: Java/C#
"interface" in Ruby ?]

Jim Weirich wrote:
> On Thursday 11 August 2005 11:41 pm, dave.burt / gmail.com wrote:
>> If a Strategy is a single function, I'd probably do it more like 
>> this,
>> though:
> [... proc based solution elided ...]
>
> Agreed, unless the strategy object requires state.  E.g.
> ...
>  class HourlyStrategy
>    def initialize(hourly_rate, timecards) ...

You can put state in procs, too - using local variables rather than
instance variables. (I'm sorry, I'm learning Haskell.)

Of course, the following way is more stupid than Jim's way in the parent
post, which allows not only state, but also private helper methods.

HourlyStrategy = proc do |hourly_rate, timecards|
  proc do
    timecards.inject(0.0) { |s, tc| s + tc.calculate_pay(hourly_rate) }
  end
end

I was going to say that this is more stupid than Jim's way, and his is
definitely more Java-ish, but I kind of like the look of that.

Cheers,
Dave