in reply to Re: What is code readability?
in thread What is code readability?
Refactoring error? Is it determine_maximum_fee() or determine_total_fee? And that name that is overly verbose.$fee = determine_maximum_fee(); sub determine_total_fee {
...what in the world is this doing? If I had to guess, I'd say it is a hack to misuse floating point numbers, instead of using something like Math::Currency, although I'd expect to see some calls to int(). And it diddles with global variable $foo.$fee = ($tfee / 100 + $sfee/100 + 0.0000001) * 100
...refers to global variables $mfee and $fee. And $mfee is non-descript. And we should at least have a comment explaining the magic numbers 100 and 200.$mfee = 200 if ($fee >= 100);
...this is seems like it is probably a horrible hack to avoid warnings about undef.$fee = $mfee if $mfee;
I'd probably not refactor into a subroutine, instead using a proper data type and something like...return $fee; }
use constant BREAK_POINT => 100; use constant BONUS_FEE => 200; my $total_fee = $tfee+$rfee >= BREAK_POINT ? BONUS_FEE : $tfee+$rfee;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: What is code readability?
by Herkum (Parson) on Jan 03, 2007 at 06:21 UTC | |
by Anonymous Monk on Jan 03, 2007 at 16:10 UTC |
In Section
Meditations