note
Herkum
<p>I think one of the most important concepts to take from programming is replacing abstract code with a function name that describe the work it is supposed to do. For example, I came across this code,</p>
<code>
$fee = ($tfee / 100 + $sfee/100 + 0.0000001) * 100
$mfee = 200 if ($fee >= 100);
$fee = $mfee if $mfee;
</code>
<p>I don't even know what this does or why it is doing it. If they had done something like this, I would have a basic understanding of the what they are trying to accomplish.</p>
<code>
$fee = determine_maximum_fee();
sub determine_maximum_fee {
$fee = ($tfee / 100 + $sfee/100 + 0.0000001) * 100
$mfee = 200 if ($fee >= 100);
$fee = $mfee if $mfee;
return $fee;
}
</code>
<p>To me, the difference between a good developer and a bad developer is being able to break code into functions that explain what the program is supposed to be doing. Something most beginning programmers do not understand.</p>
<p><b>Update:</b> Changed <i>sub determine_total_fee</i> to <i>sub determine_maximum_fee()</i>, thanks to the Anonymous Monk for pointing out the error</p>
592616
592616