Connecting Tech Pros Worldwide Forums | Help | Site Map

Using Option Strict

Clark Stevens
Guest
 
Posts: n/a
#1: Nov 20 '05
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?



Cor Ligthert
Guest
 
Posts: n/a
#2: Nov 20 '05

re: Using Option Strict


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


Mattias Sjögren
Guest
 
Posts: n/a
#3: Nov 20 '05

re: Using Option Strict


Clark,
[color=blue]
>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?[/color]

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



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Clark Stevens
Guest
 
Posts: n/a
#4: Nov 20 '05

re: Using Option Strict


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?

"Cor Ligthert" <notfirstname@planet.nl> wrote in message
news:Od1tekAeEHA.3916@TK2MSFTNGP11.phx.gbl...[color=blue]
> Clark,
>
> When you use Option Strict Off you use often late binding. When that[/color]
cannot[color=blue]
> 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
>
>[/color]


Tom Dacon
Guest
 
Posts: n/a
#5: Nov 20 '05

re: Using Option Strict


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

"Clark Stevens" <cyberbeat03@hotmail.com> wrote in message
news:rvcPc.5777$Qp.5705@twister.nyroc.rr.com...[color=blue]
> 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[/color]
Option[color=blue]
> Strict set to on? Are there situations were you could run into big[/color]
problems[color=blue]
> leaving it off?
>
>[/color]


Brian Davis
Guest
 
Posts: n/a
#6: Nov 20 '05

re: Using Option Strict


A global setting for this is located under Tools->Options->Projects->VB
Defaults.

Brian Davis
http://www.knowdotnet.com



"Clark Stevens" <cyberbeat03@hotmail.com> wrote in message
news:kbePc.82825$yd5.30326@twister.nyroc.rr.com...[color=blue]
> Okay, thanks. That makes sense.
>
> When you start a new WinForms project, is there a way to have Option[/color]
Strict[color=blue]
> automatically set to on by default just like Option Explicit is On by
> default?
>
> "Cor Ligthert" <notfirstname@planet.nl> wrote in message
> news:Od1tekAeEHA.3916@TK2MSFTNGP11.phx.gbl...[color=green]
> > Clark,
> >
> > When you use Option Strict Off you use often late binding. When that[/color]
> cannot[color=green]
> > 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
> >
> >[/color]
>
>[/color]


Clark Stevens
Guest
 
Posts: n/a
#7: Nov 20 '05

re: Using Option Strict


Thanks. That's exactly what I was looking for.

"Brian Davis" <brian@knowdotnet.nospam.com> wrote in message
news:eSqYIKEeEHA.3612@TK2MSFTNGP09.phx.gbl...[color=blue]
> A global setting for this is located under Tools->Options->Projects->VB
> Defaults.
>
> Brian Davis
> http://www.knowdotnet.com
>
>
>
> "Clark Stevens" <cyberbeat03@hotmail.com> wrote in message
> news:kbePc.82825$yd5.30326@twister.nyroc.rr.com...[color=green]
> > Okay, thanks. That makes sense.
> >
> > When you start a new WinForms project, is there a way to have Option[/color]
> Strict[color=green]
> > automatically set to on by default just like Option Explicit is On by
> > default?
> >
> > "Cor Ligthert" <notfirstname@planet.nl> wrote in message
> > news:Od1tekAeEHA.3916@TK2MSFTNGP11.phx.gbl...[color=darkred]
> > > Clark,
> > >
> > > When you use Option Strict Off you use often late binding. When that[/color]
> > cannot[color=darkred]
> > > 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
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Charles Law
Guest
 
Posts: n/a
#8: Nov 20 '05

re: Using Option Strict


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


"Brian Davis" <brian@knowdotnet.nospam.com> wrote in message
news:eSqYIKEeEHA.3612@TK2MSFTNGP09.phx.gbl...[color=blue]
> A global setting for this is located under Tools->Options->Projects->VB
> Defaults.
>
> Brian Davis
> http://www.knowdotnet.com
>
>
>
> "Clark Stevens" <cyberbeat03@hotmail.com> wrote in message
> news:kbePc.82825$yd5.30326@twister.nyroc.rr.com...[color=green]
> > Okay, thanks. That makes sense.
> >
> > When you start a new WinForms project, is there a way to have Option[/color]
> Strict[color=green]
> > automatically set to on by default just like Option Explicit is On by
> > default?
> >
> > "Cor Ligthert" <notfirstname@planet.nl> wrote in message
> > news:Od1tekAeEHA.3916@TK2MSFTNGP11.phx.gbl...[color=darkred]
> > > Clark,
> > >
> > > When you use Option Strict Off you use often late binding. When that[/color]
> > cannot[color=darkred]
> > > 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
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Cor Ligthert
Guest
 
Posts: n/a
#9: Nov 20 '05

re: Using Option Strict


>[color=blue]
> 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.
>[/color]

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


Closed Thread