Traits, r

Matt S Trout dbix-class at
Sat Feb 9 13:13:39 GMT 2008

On Fri, Feb 08, 2008 at 12:44:22PM +0000, nigel at wrote:
> Now trying to get things back on track ... I think roles will be really 
> useful too as I often want to stuff things "sideways" into an OO 
> inheritance hierarchy - but often the "ISA" relationship isn't quite 
> right. Some objects just happen to "DO" the same thing -- which is where I 
> think roles are handy.

"will be really useful" ?

Why future tense? gives you them right
now in straight perl5 ...
> But in relation to plugins I think it's tricky for roles to solve the 
> whole problem. The problem is the plugin may represent only part of what 
> needs to be added to the software - config setting changes may be required 
> as well - also conflicts with other plugins need to be handled.

Well, for single-class plugins MooseX::Object::Pluggable seems to work
fairly well - the role mechanism can already flag conflicts although it
can't resolve them, and adding attributes (which can then be introspected
by MooseX::SimpleConfig or MooseX::Getopt) can be used to declare extra
data requirements.

The point at which it becomes trickier is when you need to subclass
related classes or add complex data as well; IOC can help make this sort
of thing more manageable but the code complexity cost annoys me. Anybody
with a good answer for how to generalise this approach onto a tree of
related classes/objects should speak up and I'll buy them beer as thanks :)

> Is it a pipe dream to imagine plugins slotting together cleanly like lego 
> blocks? [1]
> I was reading about "monkeypatches" the other day [2] - and the idea of 
> modifying running code in-situ offers a somewhat scary (from a security 
> point of view) but different take on the problem of plugins working 
> together. Installing a plugin is less like lego and more like applying a 
> software bandaid --- did it stick? Ok let's put another one on. With the 
> ability to take some off as well.
> NIge
> [1] I think "webmin" has a brilliant module/plugin format
> [2] From wikipedia ... A monkey patch (also spelled monkey-patch, 
> MonkeyPatch) is a way to extend or modify runtime code without altering 
> the original source code for dynamic languages (e.g. Smalltalk, 
> Javascript, Ruby, Perl, and Python).

      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director          
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?  

More information about the mailing list