开发者

Disable AND and OR keywords

In VB.net the ANDALSO and ORELSE keywords should basically always be prefered over the AND and OR keywords.

What is the easiest way to disable the AND and OR keywords?

I'm thinking FXCop (maybe somebody has already written this rule).

Maybe just some setting开发者_运维知识库 in VS (we're currently using 2008 and are moving to 2010 end of the summer)

I'm open for all suggestions.


Hehe, I think the solution you are looking for is called C#.

But seriously, using VB, you could go with some kind of blanket policy enforcement using FXCop or similar code analysis tools.

But when it comes to such a basic and fundamental feature as the language's core logic operators, you probably shouldn't mess with them even through policy enforcement. This is a training issue, and would be best addressed by training.

Detecting the accidental mis-use or unintentional use of these operators is best handled via unit testing or peer review. Basic operator behaviors are Chapter 1 stuff in any beginner's guide to VB, and no programmer should be working on real production code if they haven't mastered the basic syntax and operators of the language yet.


The And and Or keywords have other uses besides just boolean operations. Performing bitwise operations is done by these keywords, so unless you can be absolutely certain that you will never need to do bitwise operations, you do not want to disable these keywords.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜