[Catalyst] Re: Shoot out -- Catalyst / RoR / Other MVC apps --

A. Pagaltzis pagaltzis at gmx.de
Wed May 9 16:34:19 GMT 2007


* Dave Rolsky <autarch at urth.org> [2007-05-09 16:05]:
> "All problems in computer science can be solved by another
> level of indirection" (Butler Lampson)
> 
> ... except the problem of having too many levels of
> indirection.

The funny thing is: that’s wrong!

You can add a layer of abstraction on top of an overly-indirected
system that lets you use the underlying system without knowing
about the indirections in it. :-)


* Dave Rolsky <autarch at urth.org> [2007-05-09 17:15]:
> I have a very minimal Response subclass that simply adds some
> accessors:
> 
>  package VegGuide::Response;
> 
>  use base 'Catalyst::Response';
>  __PACKAGE__->mk_accessors( 'alternate_links', 'breadcrumbs', 'keywords' );
> 
> That's the subclassing piece. The delegation is that rather
> than implement the functionality of breadcrumbs in the response
> object, the breadcrumbs accessor simply returns a
> VegGuide::Breadcrumbs object.

Delegation means that the caller communicates only with the
object that delegates and doesn’t know which object does the
actual work. That’s not what’s happening in your example.

Something like this would be delegation:

    sub trail_length {
        my $self = shift;
        $self->breadcrumbs->trail_length;
    }

Here the caller talks only to VegGuide::Response and doesn’t even
know that there’s a VegGuide::Breadcrumbs object behind the scene.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>



More information about the Catalyst mailing list