in reply to Data structures drive logic! (was Re3: Passing / evaluating / dieing on one line...)
in thread Passing / evaluating / dieing on one line...
i like your first example of maintainable code. it could be extended further by variablizing the constant values, like
sub colNOEXISTS () {-1} # and, then, in the for statement... $Columns{$col_name}{exists} == colNOEXISTS and die "your error here: $!";
what i don't like is your second example. i think it is difficult for a maintainer to understand that you're evaluating code references using a default variable, as in $_->() for \&do_A;.
secondly, the do_A; do_B; ... example could have been expressions or blocks, but your example limits do_C, do_D, and do_E to only evaluating code blocks. for instance,
(which is a somewhat contrived example) cannot easily fit into your method.$i=1; $j=2; $k=3; $l = $i++ * $j++ for 1..$k; $i=1; $j=2; $k=3; $m = $j++ * $k++ for 1..$i; $i=1; $j=2; $k=3; $k=3;
my point: zengargoyle suggested a formatting change to improve maintainability, while you suggested a functionality change. the formatting change is easy to implement and maintain, while your suggestion involves a deeper understanding of the underlying code, and the limitations of the construct which you impose upon it. i believe this has the potential to make code more difficult to maintain and extend, and has a higher potential to be misunderstood.
~Particle ;Þ
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re2: Data structures drive logic!
by dragonchild (Archbishop) on Apr 05, 2002 at 18:59 UTC |