Using Option Strict

  • Thread starter Thread starter Clark Stevens
  • Start date Start date
C

Clark Stevens

I've always used Option Strict in my code. However, I was wondering if it
is really necessary. Coding seems a lot easier when you don't use it, but
does it really make a difference? What are the advantages of having Option
Strict set to on? Are there situations were you could run into big problems
leaving it off?
 
Clark,

When you use Option Strict Off you use often late binding. When that cannot
be done you get an error.

As well important it is that you can compare
C++ (6) was much faster than VB6
C# is much faster than VBNet with Option Strict Off
C# has the same performance as VBNet with Option Strict On.

Makes that sense?

Cor
 
Clark,
Coding seems a lot easier when you don't use it, but
does it really make a difference? What are the advantages of having Option
Strict set to on?

The big advantage with strict typing is that more errors can be found
at compile time.



Mattias
 
Okay, thanks. That makes sense.

When you start a new WinForms project, is there a way to have Option Strict
automatically set to on by default just like Option Explicit is On by
default?
 
For the reasons mentioned in the previous responses to your post, some
people call Option Strict the "Good Programmer Switch".

Regards,
Tom Dacon
Dacon Software Consulting
 
Further to the response below, note that this does not insert Option Strict
into your source code. It simply establishes the default for code modules
where the setting is not explicitly set. The setting can still be overridden
in each code module.

I prefer to explicitly type it at the top of each module (as well as have
the default set), and then there is no danger of having the wrong setting.

HTH

Charles
 
I prefer to explicitly type it at the top of each module (as well as have
the default set), and then there is no danger of having the wrong setting.

I would prefer when that would matter to set them explicitly off.
That shows direct that it is not by accident.

Just to give a different opinion.

Cor
 
Back
Top