Re: changing the default base class

[email protected] (Jonathan Swartz)
Newsgroups perl.moose
Message-ID <[email protected]>
> 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.
>

Sure, the number of classes that inherit directly from the base class  
might make up a minority. But by that same logic, why wouldn't you  
require people to inherit explicitly from Moose::Object? :)

It isn't so much the tedium of adding the 'extends' statement as the  
consequence of someone *forgetting* to add it for some random class.  
In that case, we'll have the wrong base class in one part of the  
hierarchy, leading to obscure bugs.

More generally, this isn't just about default base class - that was  
just the initial motivating factor. I want to prepare for the  
possibility that I'll want to tweak some other Moose behavior or  
policy (in a perfectly external, API-respecting way) for the entire  
project, after hundreds of classes have been created, and I don't  
want to have to insert a new policy statement in all those classes.

Though I suppose one could argue that most languages with strong OO  
support never give you this much ability to control meta-OO behavior,  
and people seem to do okay. And that allowing mass-customization of  
Moose will tend to make classes less portable.

Jon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.