in reply to Re: Re: Re: Re: OOP - Sharing class methods
in thread OOP - Sharing class methods
At the very least you should wrap the Utility classname in a method, so your code becomes:
Et voila! you'll only have to change the utility class name at two points in your subclass; no need to override.package Foo; use UtilityClass; sub helper { 'UtilityClass' } sub bubbles { ... $self->helper->buttercup(); ... }
Actually, I wonder if you couldn't use the Exporter to implement something like a ruby mixin.
You know, I'm not sure whether that's a good idea, or a barking mad one...package UtilityClass; use base 'Exporter'; @EXPORT = qw/buttercup/; sub buttercup { my $self = shift; # $self is *not* a 'UtilityClass'; ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
hard-coding class names
by perrin (Chancellor) on Aug 15, 2002 at 22:11 UTC | |
by pdcawley (Hermit) on Aug 16, 2002 at 09:38 UTC |