>>>>> "SHC" == Shawn H Corey <shawnhco...@gmail.com> writes:

  SHC> Uri Guttman wrote:
  >> 
  >> computers don't hate you. you hate yourself and so you commit bad code
  >> full of bugs. self flagelation programmer style! :)

  SHC> No, it comes from maintaining other people's bad code for too
  SHC> many years.  It means, among other things, that all variables
  SHC> have acceptable values at all times.  By acceptable, I mean a
  SHC> valid value or a pre-determined not-applicable value.

for some value of acceptable. undef is fine if you are going to
autovivify. i rarely seem to need to initialize most scalars to just ''
as if it is a string i will usually be doing .= to it and that
autovivifies to '' without a warning. same for ++ and +=.

  SHC> If I was writing the code in the example, it would be:

  SHC> $station = $Station_for{$cli_station_code} || $NA{station}
  SHC>   or help( 'station', $cli_station_code );

that is way overkill in my book. simple is better even there. i won't go
further since defaulting, validation and error handling are very
application specific. i usually choose a simpler style where you do them
in different phases as needed. all in one statements like are verbose.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to