Jonathan,
On Nov 17, 2006, at 7:45 AM, Jonathan Swartz wrote:
Or perhaps I could use Moose::Policy for this. But then each class
would read
package My::Person;
use Moose::Policy 'My::Moose::Policy';
use Moose;
Yes, this would be the way to go about it (kind of).
Yuck. It seems like a significant blow to the syntactic single-use-
line beauty of Moose, and a violation of DRY.
I agree it is uglier, however, I don't see it as a violation of DRY.
Most class hierarchies are not so shallow that you will have to say
extends 'My::Moose::Object'; more than a handful of times. In my
experience, having to do this helps to delineate the "base" of your
hierarchies, where as use My::Moose would be spread all over your
class hierarchy. This to me is a violation of DRY.
But, personally I am not a fan of base classes anyway, I prefer roles
instead. With roles you get a finer level of re-use and one which
does not place requirements on your class inheritance hierarchy. With
roles you can describe the behaviors of your class (what is "does")
independent from the identity of your class (what is "is"). I see
roles as horizontal re-use, rather than vertical since they can
easily be used in a AOP-style cross-cutting way.
Maybe I'm just saying that I wish project-wide Policies could be
set with a little less syntax, and less room for user error. It
seems like it shouldn't be so hard to make this possible.
Well, Moose::Policy is by no means finished. In fact, while it is
very sane and very usable, it is still very much at the "proof of
concept" level in terms of its design and usefulness. I have always
thought that some kind of Log::Dispatch/Log::Log4Perl style config
would be a nice way to declare policies, and then we could simply add
a hook into Moose itself to check for the existence of this and DWIM.
However, tuits are in short supply at the moment, so I can't do this,
but I would be happy to give you a commit-bit and/or accept patches.
- Stevan