选项明确 [英] Option Explicit
问题描述
请微软,更新选项明确
选项在绑定后期严格咆哮。我们最近很喜欢
绑定。所以Option Strict标记太多东西。
选项显式有误导性。
允许
Dim LastName
而不是强迫
Dim LastName as string
Option Explicit应强制数据类型。
Option Explicit也应该强制函数使用返回数据类型来确定
。
我正在努力的原因是我刚刚审阅了一个Jr程序员
代码和代码充满了没有数据的Dim变量
类型。
我同意Option Explicit应该强制执行数据类型。
虽然后期绑定很方便但是效率极低,所以
Option Strict = On (顺便说一下,注意到MS默认为关闭)更多的是痛苦,你最终会减少类型不匹配的机会,并且更好地表现出来。
表现。 />
恕我直言:)
" Doug Hill <一个******* @ discussions.microsoft.com>在消息中写道
news:2b ***************************** @ phx.gbl ...请Microsoft,更新Option Explicit
选项严格咆哮后期绑定。我们喜欢迟到
绑定。所以Option Strict标记了太多东西。
选项明确是误导性的。
它允许
Dim LastName
而不是强迫
Dim LastName作为字符串
选项显式应该强制数据类型。
选项显式也应强制函数用返回数据类型延迟。
我正在努力的原因我刚刚审查了一个Jr程序员代码,代码中充满了没有数据类型的Dim变量。
Doug,
看来你的请求与自己不一致! :-)
Option Explicit On要求你定义变量:Dim LastName
Option Strict Off允许(默认)该变量或函数是一个
对象,因为你可以使用后期绑定。
Dim LastName As Object
就个人而言,这种行为是有道理的。
您是否要求编译器强制您包含''作为对象''
所以你可以做晚期绑定吗?
你可以使用MS Wish网站向MS提交你的建议。
http://register.microsoft。 com / mswish ... = EN-US& gssnb = 1
一般来说我避免使用Late Binding,因为它太容易引入太多了
许多运行时错误。当我确实需要使用Late Binding时,我将它隔离在一个或者
我应用程序的一个角落的两个模块中。
但是选择很好!
您是否考虑过获得代码批评或代码分析器,您的Jr
程序员可以运行代码来识别隐含的变量>
定义为对象?
http: //www.fmsinc.com/dotnet/analyzer/
注意我实际上并没有使用上述内容,我只看到了Code Critics的价值。
正如你要问的那样。
希望这会有所帮助
Jay
" Doug Hill" ; <一个******* @ discussions.microsoft.com>在消息中写道
news:2b ***************************** @ phx.gbl ...请微软更新Option Explicit
选项严格咆哮后期绑定。我们喜欢迟到
绑定。所以Option Strict标记了太多东西。
选项明确是误导性的。
它允许
Dim LastName
而不是强迫
Dim LastName作为字符串
选项显式应该强制数据类型。
选项显式也应强制函数用返回数据类型延迟。
我正在努力的原因我刚刚审查了一个Jr程序员代码,代码中充满了没有数据类型的Dim变量。
谢谢杰伊和斯科特-----原帖-----
道格,
看来你的请求与自己不一致! :-)
Option Explicit On要求你定义变量:Dim LastName
Option Strict Off允许(默认)该变量或
函数是anObject,因为你可以在它上面使用后期绑定。
Dim LastName As Object
个人行为是有道理的。
你问你想让编译器强迫你
包含''As Object''你可以做后期绑定吗?/ >
您可以使用MS Wish网站向MS提交您的建议
。
http://register.microsoft.com/mswish/suggestion.asp?
& SD = GN& LN = EN-US& gssnb = 1
一般来说我避免使用Late Binding,因为它很容易引入远程tomany运行时错误。当我确实需要使用Late Binding时,I
将它隔离在我应用程序远角的一个或多个模块中。
但是选择很好!
你有没有看过你的JrProgram可以在代码上运行代码批评或代码分析器
来识别隐式定义为Object的变量
?
http://www.fmsinc.com/dotnet/analyzer/
>注意我实际上没有使用上面的内容,我只看到代码评论家的价值
。正如你所要求的那样。
希望这有帮助
Jay
道格希尔 <一个******* @ discussions.microsoft.com>在messagenews中写了
:2b ***************************** @ phx.gbl ...请,微软,更新Option Explicit
选项严格咆哮后期绑定。我们喜欢迟到
绑定。所以Option Strict标记了太多东西。
选项明确是误导性的。
它允许
Dim LastName
而不是强迫
Dim LastName作为字符串
选项显式应该强制数据类型。
选项显式也应强制函数用返回数据类型延迟。
我正在努力的原因我刚刚审查了一个Jr
程序员代码,代码中充满了没有数据类型的Dim变量。
。
Please, Microsoft, update Option Explicit
Option Strict barks at late binding. We love late
binding. So Option Strict flags too many things.
Option Explicit is misleading.
It allows
Dim LastName
rather than forcing
Dim LastName as string
Option Explicit should force the data type.
Option Explicit should also force functions to be
delared with a return data type.
The reason I''m harping is I just reviewed a Jr programmers
code and the code was full of Dim variables without data
types.
I agree that Option Explicit should enforce a data type.
While late binding is convenient it is extremely inefficient, so while
Option Strict = On (by the way, notice that MS defaults this to Off) is more
of a pain, you wind up with less opportunity for type mismatches and better
performance.
IMHO :)
"Doug Hill" <an*******@discussions.microsoft.com> wrote in message
news:2b*****************************@phx.gbl...Please, Microsoft, update Option Explicit
Option Strict barks at late binding. We love late
binding. So Option Strict flags too many things.
Option Explicit is misleading.
It allows
Dim LastName
rather than forcing
Dim LastName as string
Option Explicit should force the data type.
Option Explicit should also force functions to be
delared with a return data type.
The reason I''m harping is I just reviewed a Jr programmers
code and the code was full of Dim variables without data
types.
Doug,
It seems your request is at odds with itself! :-)
Option Explicit On requires you to define the variable:Dim LastName
Option Strict Off is allowing (defaults) that variable or function to be an
Object, as you are allowed to use late binding on it.
Dim LastName As Object
Personally the behavior makes sense.
Are you asking you want the compiler to force you to include the ''As Object''
so you can do the late binding?
You could use the MS Wish site to submit your suggestion to MS.
http://register.microsoft.com/mswish...=EN-US&gssnb=1
Generally I avoid Late Binding as it is far too easy to introduce far too
many runtime bugs. When I do need to use Late Binding I isolate it in one or
two modules in a far corner of my application.
However having the option is nice!
Have you looked at getting a Code Critic or Code Analyzer that your Jr
Programmers can run on the code to identify variables that are implicitly
defined as Object?
http://www.fmsinc.com/dotnet/analyzer/
Note I have not actually used the above, I just see value of Code Critics.
For just what you are asking.
Hope this helps
Jay
"Doug Hill" <an*******@discussions.microsoft.com> wrote in message
news:2b*****************************@phx.gbl... Please, Microsoft, update Option Explicit
Option Strict barks at late binding. We love late
binding. So Option Strict flags too many things.
Option Explicit is misleading.
It allows
Dim LastName
rather than forcing
Dim LastName as string
Option Explicit should force the data type.
Option Explicit should also force functions to be
delared with a return data type.
The reason I''m harping is I just reviewed a Jr programmers
code and the code was full of Dim variables without data
types.
Thank you Jay and Scott-----Original Message-----
Doug,
It seems your request is at odds with itself! :-)
Option Explicit On requires you to define the variable:Dim LastName
Option Strict Off is allowing (defaults) that variable or
function to be anObject, as you are allowed to use late binding on it.Dim LastName As Object
Personally the behavior makes sense.
Are you asking you want the compiler to force you to
include the ''As Object''so you can do the late binding?
You could use the MS Wish site to submit your suggestion to MS.
http://register.microsoft.com/mswish/suggestion.asp? &SD=GN&LN=EN-US&gssnb=1
Generally I avoid Late Binding as it is far too easy to introduce far toomany runtime bugs. When I do need to use Late Binding I isolate it in one ortwo modules in a far corner of my application.
However having the option is nice!
Have you looked at getting a Code Critic or Code Analyzer that your JrProgrammers can run on the code to identify variables that are implicitlydefined as Object?
http://www.fmsinc.com/dotnet/analyzer/
Note I have not actually used the above, I just see value of Code Critics.For just what you are asking.
Hope this helps
Jay
"Doug Hill" <an*******@discussions.microsoft.com> wrote in messagenews:2b*****************************@phx.gbl...Please, Microsoft, update Option Explicit
Option Strict barks at late binding. We love late
binding. So Option Strict flags too many things.
Option Explicit is misleading.
It allows
Dim LastName
rather than forcing
Dim LastName as string
Option Explicit should force the data type.
Option Explicit should also force functions to be
delared with a return data type.
The reason I''m harping is I just reviewed a Jr programmers code and the code was full of Dim variables without data
types.
.
这篇关于选项明确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!