Wednesday, April 18, 2007

I get pissed off when I look at old code like this:

1. No vertical whitespace between the pg_exec and the if.
Alright, the developer was just ignorant and was following the
bad standards in his environment.

$rs=pg_exec($common2_conn,$query);
if (pg_numrows($rs)==0) {
} else { # if (pg_numrows($rs)==0) {

2. WHAT IS THAT EMPTY BLOCK FOR? DID NO ONE TEACH THIS PROGRAMMER
(dammit, I want to change my title because of idiots like this).

DID NO ONE TEACH YOU != OR <> (yech, but at least it does
exist in PHP).

That code is wrogn anyway, pg_numrows will return -1 on error
(e.g., network goes down, db server reboots, db server daemon
dies, connection disconnected because the server restarts because
someone did a kill -9 on a client).

3. I'm sorry. K&R indention is dumb. Yes, it saves lines, but
we're not in the age of teletypes and 300baud modems anymore,
there's no great need to save screen refreshes. vertical space
is valuable, sure, but clarity and maintainability is more
important.

if (pg_numrows($rs)>0)
{
--- read the rows and do something with them
}

and suddenly there's no else to clutter things up.

There are a lot more stupidities in that program, but this scheisse makes me tired. If that developer were still around I'd fire his ass. Yes, I'm looking at you, A.M.

No comments: