Aug. 7th, 2002

perlmonger: (fnord)
I really do despair sometimes.

I'm updating some APIs (making them consistent with each other and more powerful) which, if I can get away with it, entails a small loss of backwards compatibility in one package. I'm just checking through the entire codebase in CVS to see if there's a problem with this and encounter an example of Somebody Else's code...

# Add the country and operator, and their names.
$data{COUNTRY}= XXX::Network->byId($data{NETWORK})->country->iso_3char;
$data{COUNTRYNAME}= XXX::Network->byId($data{NETWORK})->country->name;
$data{OPERATOR}= XXX::Network->byId($data{NETWORK})->operator->id;
$data{OPERATORNAME}= XXX::Network->byId($data{NETWORK})->operator->name;

(package base hidden to protect the guilty)

Leaving aside the question of why the code (this is a library routine) doesn't just give its caller the Network object or, if it must, the Network, Country and Operator objects, why would anyone sane do four adjacent calls to an identical (database sourced) constructor? And, as a side effect, double up the country and operator lookups as well?

Well, this was somebody who never did get the hang of CVS. I suppose understanding of OO and query optimisation would have been too much to hope for.

Profile

perlmonger: (Default)
perlmonger

July 2013

S M T W T F S
 123456
78910111213
14 151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Powered by Dreamwidth Studios