Re: Annouce: DBIx::Class, a.k.a "taking the easy way out"

[prev] [thread] [next] [Date index for 2005/07/26]

From: Matt S Trout
Subject: Re: Annouce: DBIx::Class, a.k.a "taking the easy way out"
Date: 23:13 on 26 Jul 2005
On Tue, Jul 26, 2005 at 11:39:07PM +0100, Tony Bowden wrote:
> On Tue, Jul 26, 2005 at 11:11:46PM +0100, Matt S Trout wrote:
> > Plus, what if you want to plug-and-play with layers of search generation?
> > e.g.
> > 
> > My::Search does the WHERE condition
> > My::OrderBy adds the ORDER BY
> > My::Limit add the LIMIT clause
> > 
> > How can you arrange to drop in and replace any of the three of these without
> > something, somewhere, having explicit knowledge of what to replace where?
> 
>   my $searcher = $self->search_class->new;
>   foreach my $plugin (@plugins) {
>     $plugin->manipulate($searcher);
>   }
>   my @results = $searcher->run;
> 
> No inheritance necessary at all, never mind MI. (For convenience most
> plugins will probably inhertit from a base, just so they can rely on
> certain default behaviour, but duck typing is sufficient really.)
> 
> All the plugins need to know is what they can do with the searcher,
> based on on what's in its API. 

What happens if each one needs to interrupt the search process at a different
stage, and some need to interpose themselves to figure out the results?

e.g. you have Pre, Wrap1, Wrap2, Post

Your calling order goes

Pre { }
Wrap1 {
  Wrap2 {
    Original
  }
}
Post { }

By the time you've added enough delegation hooks to make the whole thing
work, I'd expect you'd end up with an API that's overcomplicated, higher
overhead than my approach and there's probably still a fairly good chance
of a plugin author breaking stuff if they're not careful.

I don't see the point of all that work; I'd rather give developers a single
way to do things where, yes, they have to be careful, but it's always the
same careful - and some compile-time checks to catch the most common
mistakes for them.

        -- 
             Matt S Trout           Website: http://www.shadowcatsystems.co.uk
  Technical Director        E-mail:  mst (at) shadowcatsystems.co.uk
Shadowcat Systems Ltd.

(message missing)

Re: Annouce: DBIx::Class, a.k.a "taking the easy way out"
Matt S Trout 23:13 on 26 Jul 2005

Delegation vs Hooks (was: Annouce: DBIx::Class, a.k.a "taking the easy way out")
=?ISO-8859-1?Q?Ask_Bj=F8rn_Hansen?= 23:27 on 26 Jul 2005

Generated at 16:37 on 28 Jul 2005 by mariachi v0.52