Disable AND and OR keywords
In VB.net the ANDALSO
and ORELSE
keywords should basically always be prefered over the AND
and OR
keywords.
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.
精彩评论