On Jan 22, 2008 11:28 AM, Ted Zlatanov <[EMAIL PROTECTED]> wrote:
> On Mon, 21 Jan 2008 13:24:49 -0500 "John Siracusa" <[EMAIL PROTECTED]> wrote:
> JS> When I need a mix-in, I just "make one" by manually importing methods
> JS> as needed.  Writing a helper for this isn't too hard.  Look around
> JS> line 560 of this file for an example:
>
> JS> 
> http://search.cpan.org/src/JSIRACUSA/Rose-HTML-Objects-0.552/lib/Rose/HTML/Object.pm
>
> That's a pretty nasty hack.  Really, I think this should be a standard
> mixin

Mixins are "a pretty nasty hack."  That code is just automating them
:)  Anyway, when building a single super-base class, I don't think
it's particularly ugly to set up your class hierarchy and then yank in
a particular method (say, init_db()) from another specific class.  Or
like I said before, you could go the Class::C3 route and avoid all
this.

> instead of forcing users to derive from a different class when
> all that's changing is one small piece of the overall behavior.  What
> methods are different in RDBO::Cached (I can look it up myself, but let
> me know if there are any gotchas)?  I'll write the mixin code myself and
> you can put it in RDBO::Helpers or I'll make a new CPAN module for it.

If you look at the code you'll get an idea of why it's in its own
package. Yeah, it certainly could be made as a series of helpers with
some modification, but doing it as a class allows for introspection
("is this a cached object?") and better isolates any potential
ugliness or complexity of the caching implementation.

> JS> IMO, all such things are fair in super-wide-usage base classes.  Do
> JS> the complicated stuff in a very few well-defined places and reap the
> JS> benefits broadly.
>
> Agreed.  I'd like that place to be RDBO::Helpers, not My::DB::BaseObject :)

It'd be unlike other helpers in that it'd have its own significant
data structures off to the side (the cache itself) and it'd modify
existing methods rather than adding new ones.  It sure seems like a
subclass to me.  (Actually, it's perhaps more like a Perl 6 "role" but
you know... :)

-John

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to