Planning for debugging Ed Freyfogle London Perl Workshop 28 Nov. 2008
Nestoria?
What could go wrong? datasources Nestoria output Lots of data, many sources, 4 languges ETL, geocoding, deduplication …. HTML, whitelabels, API, widgets, FBML …. All with very few developers Internal tools, reporting, invoicing …
 
Developers, not firefighters Bad Good
Obvious first steps Version Control svn, trac Build enviroment local, staging, live Tests nightly, prelaunch, postlaunch
Documentation Bad: no documentation  Worse: incorrect documentation
Who do you trust? You make mistakes. Computers don’t.
>./connect_to_database.pl --help Prints command needed to access database Usage: ./connect_to_database.pl --database [listings|searchindex] --country  no default, (de|es|it|uk) --database  type of DB --help --product_type  default=realestate --type  no default, (failover)  --verbose Umm, the backup DB is on server 3, right? Don’t guess. Know
Logging Make it easy to turn on/off Log4Perl Have cleanup strategy
Measure twice, cut once
my $script = ‘~/somescript.pl’; my $procs  = determine_procs();  my $groups = some_test() ? 2 : 3; my $cmd  =  $script  . ’ --groups ’ . $groups . ’ --procs ’  . $procs; system($cmd); Rome is burning. You have 10 seconds. What does this code do?
my $script = ‘~/somescript.pl’; my $procs  = determine_procs();  my $groups = some_test() ? 2 : 3; my $cmd  =  $script  . ’ --groups ’ . $groups . ’ --procs ’  . $procs; execute_cmd($cmd); sub execute_cmd{ my $cmd = shift; if ($dryrun){ print STDERR “would have run $cmd \n”; } else { system($cmd);  } } Better:
Don’t make me think --help, --dryrun, --verbose  Getopt::Long Term::ProgressBar
Invest now schedule code review/learning “ upgrade day” keep an easy to edit list of ideas (wiki) have an email/alerts strategy CPAN is your friend Perl::Metrics::Simple
Get help To: Nestoria team From:  [email_address] Subject: Bug I think there is a bug.  The page doesn’t seem to wrk. Pls fix.
Better To: Nestoria team From:  [email_address] Subject: Bug I think there is a bug.  The page doesn’t seem to wrk. Pls fix.   HTTP_X_FORWARDED_FOR     81.136 .*.* SERVER_ADDR      10.10.*.* HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 7.0; …  Cookie        MjEwREhQZ1JzeEl1NDAxMjIzNTY4MjE4A5A
Get help  (cont.)
Help me to help you
Shameless plug Join us!  You’ll love our API….
Questions? http://www.nestoria.co.uk   http://blog.nestoria.co.uk

Planning for Debugging

  • 1.
    Planning for debuggingEd Freyfogle London Perl Workshop 28 Nov. 2008
  • 2.
  • 3.
    What could gowrong? datasources Nestoria output Lots of data, many sources, 4 languges ETL, geocoding, deduplication …. HTML, whitelabels, API, widgets, FBML …. All with very few developers Internal tools, reporting, invoicing …
  • 4.
  • 5.
  • 6.
    Obvious first stepsVersion Control svn, trac Build enviroment local, staging, live Tests nightly, prelaunch, postlaunch
  • 7.
    Documentation Bad: nodocumentation Worse: incorrect documentation
  • 8.
    Who do youtrust? You make mistakes. Computers don’t.
  • 9.
    >./connect_to_database.pl --help Printscommand needed to access database Usage: ./connect_to_database.pl --database [listings|searchindex] --country no default, (de|es|it|uk) --database type of DB --help --product_type default=realestate --type no default, (failover) --verbose Umm, the backup DB is on server 3, right? Don’t guess. Know
  • 10.
    Logging Make iteasy to turn on/off Log4Perl Have cleanup strategy
  • 11.
  • 12.
    my $script =‘~/somescript.pl’; my $procs = determine_procs(); my $groups = some_test() ? 2 : 3; my $cmd = $script . ’ --groups ’ . $groups . ’ --procs ’ . $procs; system($cmd); Rome is burning. You have 10 seconds. What does this code do?
  • 13.
    my $script =‘~/somescript.pl’; my $procs = determine_procs(); my $groups = some_test() ? 2 : 3; my $cmd = $script . ’ --groups ’ . $groups . ’ --procs ’ . $procs; execute_cmd($cmd); sub execute_cmd{ my $cmd = shift; if ($dryrun){ print STDERR “would have run $cmd \n”; } else { system($cmd); } } Better:
  • 14.
    Don’t make methink --help, --dryrun, --verbose Getopt::Long Term::ProgressBar
  • 15.
    Invest now schedulecode review/learning “ upgrade day” keep an easy to edit list of ideas (wiki) have an email/alerts strategy CPAN is your friend Perl::Metrics::Simple
  • 16.
    Get help To:Nestoria team From: [email_address] Subject: Bug I think there is a bug. The page doesn’t seem to wrk. Pls fix.
  • 17.
    Better To: Nestoriateam From: [email_address] Subject: Bug I think there is a bug. The page doesn’t seem to wrk. Pls fix. HTTP_X_FORWARDED_FOR     81.136 .*.* SERVER_ADDR     10.10.*.* HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 7.0; … Cookie        MjEwREhQZ1JzeEl1NDAxMjIzNTY4MjE4A5A
  • 18.
    Get help (cont.)
  • 19.
    Help me tohelp you
  • 20.
    Shameless plug Joinus! You’ll love our API….
  • 21.
    Questions? http://www.nestoria.co.uk http://blog.nestoria.co.uk