Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Breaking up a big module

by tobyink (Abbot)
on Apr 25, 2019 at 13:55 UTC ( #1232991=note: print w/replies, xml ) Need Help??


in reply to Breaking up a big module

I've already answered this question, but now I'm typing a second solution.

Foo.pm

package Foo; use Role::Tiny::With; with "Foo::Bar"; sub aa { my ( $self, $args ) = @_; my $val = $self->_aa ( $args->{'bar'} ); } sub bb { my ( $self, $args ) = @_; my $val = $self->_bb ( $args->{'foo'} ); } 1;

Foo/Bar.pm

package Foo::Bar; use Role::Tiny; sub _aa { my $self, $quux ) = @_; } sub _bb { my $self, $fazoo ) = @_; } 1;

This has the advantage that the methods defined in Foo::Bar are no longer coupled to Foo. If you define a new class called Foo2, and want to have _aa and _bb defined in Foo2 as well, you can just do:

package Foo2; use Role::Tiny::With; with "Foo::Bar"; ...; 1;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1232991]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2019-08-20 10:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?