【发布时间】:2010-10-05 16:04:31
【问题描述】:
我正在努力遏制自称“高级程序员”的一些坏习惯。他坚持写这样的 If 块:
if (expression) {}
else {
statements
}
或者就像他通常用经典的 ASP VBScript 编写的那样:
If expression Then
Else
statements
End If
表达式可以很容易被否定:
if (x == 0) {}
else {
statements
}
除了清晰的编码风格,我还能提供哪些其他理由来证明我认为以下是首选?
if (x != 0) {
statements
}
甚至更一般的情况(同样在 VBScript 中):
If Not expression Then
statements
End If
【问题讨论】:
标签: coding-style