2009/10/15 Stephen Eley <[email protected]>
> On Thu, Oct 15, 2009 at 3:59 AM, Andrew Premdas <[email protected]>
> wrote:
> >
> > You can take this further and state that no public method should ever do
> > anything, it should just contain calls to private methods which document
> how
> > the public method works. I expect most would consider that going to far
> ...
> > sigh
>
> Once complexity has been managed, what's the value of that strategy?
>
> I wrote a bit more about this in a blog article some time ago (
http://blog.andrew.premdas.org/articles/2009/04/07/writing-classes-why-its-so-easy-to-do-it-wrong-in-ruby).
I'm afraid my blog is fundamentally anti-social, and can be a bit flakey on
up time so apologies if article is hard to access.
Fundamentally the reason for following this approach is to have code you can
come back to and work on easily. If the public methods of a class document
essentially the algorithm of how the class fulfils it function, and hide the
detail then its much easier to come back to the code and work on it.
class Car
def start
turn_the_key
pump_fuel_into_engine
spark
end
of course that was all well and good in the eighties, but in the late
oughties we need to update
class Car
def start
check_the_key_security_code
boot_the_engine_management
pump_fuel_into_engine
spark
Not the greatest example I'm afraid (especially as I don't drive and now
nothing about cars), but hopefully you get the idea
All best
Andrew
> --
> Have Fun,
> Steve Eley ([email protected])
> ESCAPE POD - The Science Fiction Podcast Magazine
> http://www.escapepod.org
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users