You're a programmer, you write code to eliminate repetitive tasks. If one of those tasks is writing code then you may well be able to write something to do it for you. Have a look at some of the method maker classes on cpan, figure out how they work and see if you can apply it so that the glue code writes itself.
For example if your glue code is just delegating method calls to some other object you could transform
package Foo;
sub method1
{
my $self = shift;
my $object = $self->{object};
$object->method1(@_);
}
sub method2
{
my $self = shift;
my $object = $self->{object};
$object->method2(@_);
}
sub method3
{
my $self = shift;
my $object = $self->{otherobject};
$object->method3(@_);
}
into
package Foo;
use My::Delegator qw(
method1 => "object",
method2 => "object"
method3 => "otherobject"
);
There are lots of other repetitive coding tasks that can be automated once you know how Perl deals with methods, code references and all that.
One thing is that Perl isn't perfectly suited to automated coding, something like lisp is and you can essentially produce what seems like magical result with lisp macros. So maybe your particular form of repetitive coding is not easily eliminated with Perl.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.