tags:

views:

21

answers:

1

I'm trying to curb some of the bad habits of a self-proclaimed "senior programmer." He insists on writing If blocks like this:

if (expression) {}
else {
    statements
}

Or as he usually writes it in classic ASP VBScript:

If expression Then
Else
    statements
End If

The expression could be something as easily negated as:

if (x == 0) {}
else {
    statements
}

Other than clarity of coding style, what other reasons can I provide for my opinion that the following is preferred?

if (x != 0) {
    statements
}

Or even the more general case (again in VBScript):

If Not expression Then
    statements
End If
+2  A: 

Reasons that come to my mind for supporting your opinion (which I agree with BTW) are:

  1. Easier to read (which implies easier to understand)
  2. Easier to maintain (because of point #1)
  3. Consistent with 'established' coding styles in most major programming languages

I have NEVER come across the coding-style/form that your co-worker insists on using.

ssahmed555
Yeah, he has a unique way of doing just about everything.
Chris Judge