[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
Re: [FWP] Goal oriented programming
The whole question of whether it is "more better" to put the conditional
before or after the statement
if ($running) { stop(); };
die unless $dead_already;
is one of the (can I say this? :) corner stones of goal-oriented
programming (back to the original subject :-)
See ch. 8 of The Camel under Programming with Style.
The Perl style guide says you should put the important thing on the
left, which is another way of saying you should try to make your goal
clearer to the reader.
- Larry Wall
So (quoting from The Camel, p. 547)
print "Starting analysis\n" if $verbose;
is better than
$verbose && print "Starting analysis\n";
since the main point isn't whether the user typed -v or not.
I'm not sure whether it is arguably "funner" to "put the important thing on
the left", although many programmers have more fun when working with
clearer code. But it's more Perlish. And more Perlish _should_ qualify as
"funner".
-- --
|\ _,,,---,,_ Vicki Brown <vlb@cfcl.com>
ZZZzz /,`.-'`' -. ;-;;,_ Journeyman Sourceror: Scripts & Philtres
|,4- ) )-,_. ,\ ( `'-' P.O. Box 1269 San Bruno CA 94066
'---''(_/--' `-'\_) http://www.cfcl.com/~vlb http://www.macperl.com
==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org