By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,543 Members | 2,037 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,543 IT Pros & Developers. It's quick & easy.

Option Explicit

P: n/a
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.

Nov 20 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
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.

Nov 20 '05 #2

P: n/a
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.

Nov 20 '05 #3

P: n/a
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.

.

Nov 20 '05 #4

P: n/a
"Doug Hill" <an*******@discussions.microsoft.com> wrote in
news:2b*****************************@phx.gbl:
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.


While I agreee that this would be useful, In the meantime, your Jr
programmers should follow best coding practices. They need to be educated.
Perhaps you could create a "coding standards" document and require them to
follow it.

Just a thought,

Chris
Nov 20 '05 #5

P: n/a
* "Doug Hill" <an*******@discussions.microsoft.com> scripsit:
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 would like 'Option Strict Off' blocks:

\\\
..
..
..
Option Strict Off
Nov 20 '05 #6

P: n/a
Hi Herfried,

We'll get them, sort of, in the next release - Partial Types. (But a bit
silly if your O.S.Off block is only a few lines long).

Regards,
Fergus
Nov 20 '05 #7

P: n/a

"Doug Hill" <an*******@discussions.microsoft.com> wrote in message
news:2b*****************************@phx.gbl...
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 guess i would consider myself a "junior programmer", however, I would not be allowed to get away
with this. This is something that is BASIC programming practice. This sounds more like an
employee management issue than an option explicit not functioning correctly issue.

Nov 20 '05 #8

P: n/a
* "Fergus Cooney" <fi******@tesco.net> scripsit:
We'll get them, sort of, in the next release - Partial Types. (But a bit
AFAIk partial types will only be available in C#.
silly if your O.S.Off block is only a few lines long).


I think that's the big advantage of these blocks.

;-)

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #9

P: n/a
Rick and Chris,
You are absolutely right. I couldn't believe a programmer
would not type variables, and I couldn't believe the tool
let them.
In talking with my bosses I mentioned that I have probably
50 rules that I always follow. Now they want me to
document them. ;-)
Thanks

-----Original Message-----
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 programmerscode and the code was full of Dim variables without data
types.

.

Nov 20 '05 #10

P: n/a
In article <bm************@ID-208219.news.uni-berlin.de>, Herfried K. Wagner [MVP] wrote:
* "Fergus Cooney" <fi******@tesco.net> scripsit:
We'll get them, sort of, in the next release - Partial Types. (But a bit


AFAIk partial types will only be available in C#.
silly if your O.S.Off block is only a few lines long).


I think that's the big advantage of these blocks.

;-)

http://msdn.microsoft.com/vstudio/pr...p.aspx#whidbey

Mentions partial types for VB.NET. Also unsigned types, operator
overloading, and XML comments.

Tom Shelton
--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #11

P: n/a
* Tom Shelton <to*@mtogden.com> scripsit:
http://msdn.microsoft.com/vstudio/pr...p.aspx#whidbey

Mentions partial types for VB.NET. Also unsigned types, operator
overloading, and XML comments.


Thanks... I missed the partial types when reading the article some time
ago.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #12

P: n/a
> In talking with my bosses I mentioned that I have probably
50 rules that I always follow. Now they want me to
document them. ;-)


Can you send them to us too? ;)

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.