Cool Code with Brackets
May 31st, 2006[ General ]
I recently switched bracket styles in code. Here’s what I used to do:
string sql = “update bug set ixbugeventlatest….”;
reader.writeOut(sql);
int rowsAffected = cmd.ExecuteNonQuery();
}
It’s clean and doesn’t take up a lot of lines. What I’ve never explicitly done is strived for a code style that makes errors, bad code etc easier to spot. I’ve made the simple switch to this style, which is most likely the more common of the two:
string sql = “update bug set ixbugeventlatest….”;
reader.writeOut(sql);
int rowsAffected = cmd.ExecuteNonQuery();
}
The result is easier to scan and see the opening and closing braces. Actually I really don’t even have to scan, I can just see them. Technically I like the look of the other style better but I agree the latter is easier to work with so I’ve given up on cool and made the switch.