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...
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.
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.(package base hidden to protect the guilty)
$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;
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.