Subject: Shlomif's Tenth Law of Perl OOP and Test-Run



Hi all!

Shlomif's Tenth Law of Perl OOP: "Every sufficiently complex Class::Accessor
program contains contains an ad hoc, informally-specified, bug-ridden, slow
implementation of half of Moose."

(see http://en.wikipedia.org/wiki/Greenspun's_Tenth_Rule ).

I used Class::Accessor for Test-Run ( see
http://freshmeat.net/projects/test-run/ ), because that's what I was used to
using, and found the easiest solution, but ended up implementing a lot of
extra Object Orientation logic (and not-so-OO logic) in Test-Run-Base and in
other classes, and wonder if I can use Moose (possibly with some extra MooseX
plugins, to replace it. I can possibly write some of my own plugins.

Here goes. The files in question are at:

http://xrl.us/bka2c - Test::Run::Base:

# Contains an abstraction above Text::Sprintf::Named, that allows a class to
format strings using Python-like "%(attribute)s" escapes. Useful as a
mini-templating language. I might mostly ditch it completely in favour of
Template Toolkit.

In turn I maintain a set of compiled formatters as an object-based property,
and can format according them.

# Has a silly copy_from() method to copy a list of attributes from another
object using the accessors.

# accum_array():

<<<<<<<<<<<
This is a more simplistic version of the :CUMULATIVE functionality
in Class::Std. It was done to make sure that one can collect all the
members of array refs out of methods defined in each class into one big
array ref, that can later be used.
>>>>>>>>>>>

# $self->_run_sequence(\@params)

<<<<<<<<<<<<
Runs the sequence of commands specified using
C<_calc__${calling_sub}__callbacks> while passing @params to
each one. Generates a list of all the callbacks return values.
>>>>>>>>>>>>

# package->delegate_methods($field, \@methods)

I think this would be trivial to do using Moose.

# http://xrl.us/bka67 - Test::Run::Base::Struct

These are classes whose constructors (the ->new() subroutines) can only be
passed proper pre-defined fields. It's very hacky and ad-hoc at the moment,
so I'm open for better Moose-based solutions.

# http://xrl.us/bkba3 - Test::Run::Base::Plugger
# http://xrl.us/bkba5 - Test::Run::Base::PlugHelpers

Two plugin-abstractions. For more information see:

http://use.perl.org/~Shlomi+Fish/journal/33492

I also have some other OO and other abstractions stuff there spread around the
code, but I think that's the main thing.

I'd appreciate any pointers to how I can implement these things using Moose so
I can convert Test-Run to it.

Regards,

Shlomi Fish

-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
The Case for File Swapping - http://xrl.us/bjn7i

The bad thing about hardware is that it sometimes work and sometimes doesn't.
The good thing about software is that it's consistent: it always does not
work, and it always does not work in exactly the same way.





Programming list archiving by: Enterprise Git Hosting