[Dbix-class] Using Class::Std under-the-hood

Adam Jacob adam at stalecoffee.org
Thu Aug 11 09:56:13 CEST 2005


I can't vouch for whether this belongs in the internals of  
DBIx::Class, but thanks for bringing it up!  Class::Std, and inside- 
out objects, look cool as hell. :)

Adam

On Aug 10, 2005, at 11:36 PM, Dan Kubb wrote:

> Via IRC some of us have been discussing converting DBIx::Class to
> using Class::Std under-the-hood.  If you're not familiar with
> Class::Std, you can find more about it here:
>
>   http://search.cpan.org/dist/Class-Std/
>
> About a week ago I sent a message to the list about  
> DBIx::Class::Field,
> which will be rolled into DBIx::Class shortly.   I used Class::Std
> for everything underneath, more as an experiment than anything, but  
> I'm
> really happy with the results.   So much so that we're considering
> switching from using blessed hash objects to inside-out objects, and
> using Class::Std as a base.
>
> A few of the benefits to using Class::Std are:  (there's more, read  
> the docs)
>
>   - Relatively simple to switch.  I did it in about 10 to 15 minutes
>     per perl module.  Granted, the code-base was relatively small, but
>     it was fairly painless and only took a couple of hours overall.
>
>   - It had the nice side effect of cutting out about 15% of my code  
> too;
>     since much of the standard boilerplate stuff is handled by  
> Class::Std.
>
>   - Strong encapsulation.  It is impossible to access the underlying
>     data, except through a well defined interface which you control
>     completely.
>
>   - Automatic accessor/mutator creation.  Can be controlled though to
>     provide both, either, or no external access.
>
>   - Automatic constructor creation.
>
>   - Mark any method as protected/private to prevent access to specific
>     methods from outside your inheritance tree.
>
>   - Handled multiple inheritance dispatching, similar in result to
>     NEXT, but simpler.  Its easier to get things right.  Check out
>     the CUMULATIVE tag to see more.
>
>   - A clean way to specify overload behavior for objects.  Much
>     nicer than overload.pm.
>
>   - Simple ways to dump the underlying data structure should you
>     need it for debugging.  One of the biggest complaints with
>     inside-out objects is that the data is so hidden you can't see
>     it when you're initially writing and debugging.  With Class::Std
>     objects its easy -- you just do:
>
>        warn $self->_DUMP;
>
>     This will return a string representation of the internal state
>     of the object.
>
>   - Written by Damian Conway ;)  He said the module had gotten a lot
>     of interest as OS Con.  I presume this is partly because he  
> features
>     it in two chapters of his new book, Perl Best Practices.
>
>   - A very perl6-like syntax.
>
> Anyway, its a pretty nice module and I recommend checking it out.
> I could include more sample code, but the documentation is a better
> than anything I could write at the moment ;)
>
> We're looking to get some feedback before making any decisions.  If
> you've got anything pro or con to add, now's the time to speak up..
>
> --
>
> Thanks,
>
> Dan Kubb
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
>
>




More information about the Dbix-class mailing list