note
Juerd
<div class="pmsig"><div class="pmsig-132236">
<p><blockquote><em>
I hate dealing with code where methods only do one or two lines of action and there are many many such methods and subs.
</em></blockquote></p>
<p>
So do I, so do I. I like short methods, not tiny ones :) I think screen page (24 lines) size is a good size for subs (methods or non-methods) and anything much larger should be taken apart.
</p>
<p>
Subs with only one or two meaningful lines are not what I was talking about when I meant short subs. They're a little too short :)
</p>
<p>
I do prefer one-line subs to five-line subs when it comes to often repeated code.
<code>
sub property1 {
my ($self, $value) = @_;
@_ >= 2 and $self->{property1} = $value; # update: s/>/>=/
$self->{property1}; # update: s/property/property1/
}
sub property2 {
my ($self, $value) = @_;
@_ >= 2 and $self->{property2} = $value; # update: s/>/>=/
$self->{property2}; # update: s/property/property2/
}
</code>
versus
<code>
sub property1 : Property;
sub property2 : Property;
</code>
<p><font color="#800000">
Juerd
# { site => '<a href="http://juerd.nl/" target="_blank"><font color="#800000">juerd.nl</font></a>', plp_site => '<a href="http://plp.juerd.nl/" target="_blank"><font color="#800000">plp.juerd.nl</font></a>', do_not_use => '<a href="mailto:spamcollector_perlmonks@juerd.nl" target="_blank"><font color="#800000">spamtrap</font></a>' }
</font></p>
</div></div>
298755
298949