Next | Program Repair Shop | 212 |
Returning to the each_file example of three slides ago:
sub each_file { return unless -T $_;
if ( open F, "< $_" ) { my $s = <F>; close F; if ( open F, "> $_" ) { $s =~ s/COLUMN1/COLUMN1/ig; print F $s; close F; } else { print "Error opening file for write: $!\n"; } } else { print "Error opening file for read: $!\n"; } }
These if blocks are all quite top-heavy
The normal flow of the function is 1-2 levels deep
(2-3 before we banished the Condition that Ate Michigan)
Normal flow should be close to the margin
It's hard to see which else goes with which if
Next | Copyright © 2002 M. J. Dominus |