YAPC::2004::Israel << Previous | Index | Next >> Copyright © 2004 Gaal Yahas

API woes


  • The code to maintain made calls to a library I couldn't change

  • The API wasn't pretty:

     get_customer_status_by_various_parameters(\$status, \$discount,
         $cust_location, $job_location, $cust_id, $phase_of_moon);
  • $status and $discount are OUT variables, but are really the $job->PreferredCustomerStatus and $job->Discount fields.

     {
       my $status   = $job->PreferredCustomerStatus;
       my $discount = $job->Discount;
       get_customer_status_by_various_parameters(\$status, $discount
           $cust_location, $job_location, $cust_id, $phase_of_moon);
       $job->PreferredCustomerStatus($status);
       $job->Discount($discount);
     }
  • I didn't think so, either!