473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Option Strict

Should I have it ON or OFF
//Kenneth
Jul 21 '05 #1
7 1415
Kenneth <ke*****@sagdalen.a.se> wrote:
Should I have it ON or OFF


On for both performance and type safety; off for lazy type checking
(which can be useful very occasionally).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Hi Kenneth

I know I am going to regret this but here goes ...

In my personal opinion, Option Strict should always be ON. I have read a lot
of replies from people in these newsgroups that suggest that there are times
when it should/could be turned off. I have yet to be convinced that there is
such an occasion but I am open to other views, and examples.

HTH

Charles
[To everyone reading this, please feel free to suggest examples that
contradict me, and I will concede gracefully. But please, don't let's have a
slanging match that disappears off the end of my screen - it just makes my
head hurt]
"Kenneth" <ke*****@sagdalen.a.se> wrote in message
news:et**************@TK2MSFTNGP12.phx.gbl...
Should I have it ON or OFF
//Kenneth

Jul 21 '05 #3
Kenneth,
As Charles & Jon have stated, you should always use Option Strict On at the
top of each of your source files.

I normally include it at the top of each source file along with Option
Explicit On, so other developers know that this file requires that setting.
For if you attempt to rely on project settings, and copy the source file to
another project junior developers may get confused.

The only real time you need Option Strict Off is when you are using Late
Binding. If I need to Late Binding I would isolate it to one or two source
files in the far corner of my app. As Charles suggested, I have yet to need
to use Late Binding.

Word of caution, Late Binding uses reflection under the covers which can be
expensive at execution time. I normally dynamically load assemblies and
early bind to an interface. The objects that I dynamically load adhere to a
specific interface, allowing me to avoid Late Binding.

Hope this helps
Jay

"Kenneth" <ke*****@sagdalen.a.se> wrote in message
news:et**************@TK2MSFTNGP12.phx.gbl...
Should I have it ON or OFF
//Kenneth

Jul 21 '05 #4
Ditto, that it should be on ALL the time. If you are
having challenges with it being on, then that means
generally you don't have enough understanding about what
you are doing and that is all the more reason to leave it
on. All you are doing by leaving it off is pushing dirt
under the rug and which may appear later and cause more
problems and possible a lot of clean up.

Carol
-----Original Message-----
Should I have it ON or OFF
//Kenneth
.

Jul 21 '05 #5
I am a rookie on asp.net. I always use option strict on, but I am wonder how
you avoid late binding on say getting the command argument of a link button.
I have been using DirectCast because I get the late binding error without
it, but how else can I get the command argument of the button?

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:ez**************@TK2MSFTNGP12.phx.gbl...
Kenneth,
As Charles & Jon have stated, you should always use Option Strict On at the top of each of your source files.

I normally include it at the top of each source file along with Option
Explicit On, so other developers know that this file requires that setting. For if you attempt to rely on project settings, and copy the source file to another project junior developers may get confused.

The only real time you need Option Strict Off is when you are using Late
Binding. If I need to Late Binding I would isolate it to one or two source
files in the far corner of my app. As Charles suggested, I have yet to need to use Late Binding.

Word of caution, Late Binding uses reflection under the covers which can be expensive at execution time. I normally dynamically load assemblies and
early bind to an interface. The objects that I dynamically load adhere to a specific interface, allowing me to avoid Late Binding.

Hope this helps
Jay

"Kenneth" <ke*****@sagdalen.a.se> wrote in message
news:et**************@TK2MSFTNGP12.phx.gbl...
Should I have it ON or OFF
//Kenneth


Jul 21 '05 #6
vMike,
If I am following your question, you avoid the error by using DirectCast. As
soon as you use DirectCast the compiler knows what type it is, as you just
told it, so it is able to early bind to the type you give in the DirectCast.

Hope this helps
Jay

"vMike" <Mi************@nospam.gewarren.com.delete> wrote in message
news:bn**********@ngspool-d02.news.aol.com...
I am a rookie on asp.net. I always use option strict on, but I am wonder how you avoid late binding on say getting the command argument of a link button. I have been using DirectCast because I get the late binding error without
it, but how else can I get the command argument of the button?

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:ez**************@TK2MSFTNGP12.phx.gbl...
Kenneth,
As Charles & Jon have stated, you should always use Option Strict On at the
top of each of your source files.

I normally include it at the top of each source file along with Option
Explicit On, so other developers know that this file requires that

setting.
For if you attempt to rely on project settings, and copy the source file

to
another project junior developers may get confused.

The only real time you need Option Strict Off is when you are using Late
Binding. If I need to Late Binding I would isolate it to one or two source files in the far corner of my app. As Charles suggested, I have yet to

need
to use Late Binding.

Word of caution, Late Binding uses reflection under the covers which can

be
expensive at execution time. I normally dynamically load assemblies and
early bind to an interface. The objects that I dynamically load adhere

to a
specific interface, allowing me to avoid Late Binding.

Hope this helps
Jay

"Kenneth" <ke*****@sagdalen.a.se> wrote in message
news:et**************@TK2MSFTNGP12.phx.gbl...
Should I have it ON or OFF
//Kenneth



Jul 21 '05 #7
Ah, I see. I thought that there was something different I should be doing.
Thank you.
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:up**************@TK2MSFTNGP11.phx.gbl...
vMike,
If I am following your question, you avoid the error by using DirectCast. As soon as you use DirectCast the compiler knows what type it is, as you just
told it, so it is able to early bind to the type you give in the DirectCast.
Hope this helps
Jay

"vMike" <Mi************@nospam.gewarren.com.delete> wrote in message
news:bn**********@ngspool-d02.news.aol.com...
I am a rookie on asp.net. I always use option strict on, but I am wonder

how
you avoid late binding on say getting the command argument of a link

button.
I have been using DirectCast because I get the late binding error without
it, but how else can I get the command argument of the button?

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in

message
news:ez**************@TK2MSFTNGP12.phx.gbl...
Kenneth,
As Charles & Jon have stated, you should always use Option Strict On at
the
top of each of your source files.

I normally include it at the top of each source file along with Option
Explicit On, so other developers know that this file requires that

setting.
For if you attempt to rely on project settings, and copy the source
file to
another project junior developers may get confused.

The only real time you need Option Strict Off is when you are using
Late Binding. If I need to Late Binding I would isolate it to one or two

source files in the far corner of my app. As Charles suggested, I have yet to

need
to use Late Binding.

Word of caution, Late Binding uses reflection under the covers which can be
expensive at execution time. I normally dynamically load assemblies

and early bind to an interface. The objects that I dynamically load adhere

to
a
specific interface, allowing me to avoid Late Binding.

Hope this helps
Jay

"Kenneth" <ke*****@sagdalen.a.se> wrote in message
news:et**************@TK2MSFTNGP12.phx.gbl...
> Should I have it ON or OFF
>
>
> //Kenneth
>
>



Jul 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care...
11
by: Daylor | last post by:
hi. im using option strict on. im doing in ,from the simple reason ,to be warn when there are implict conversion like string to int ,int to string. BUT. the price ,(now i see ), is very bad....
8
by: Rich | last post by:
Hello, If I leave Option Strict Off I can use the following syntax to read data from a Lotus Notes application (a NotesViewEntry object represents a row of data from a Lotus Notes View - like a...
17
by: David | last post by:
Hi all, I have the following problem: my program works fine, but when I add option strict at the top of the form, the following sub fails with an error that option strict does not allow late...
15
by: guy | last post by:
when i first started using .net (beta 1) i came across option strict and thought hey this could be really good, and since then have always turned it on, most people here seem to agree that this is...
13
by: C. Moya | last post by:
I fully expected the lack of a way to set Option Strict globally to be fixed in SP1. I can't seem to figure out if it has been fixed or not. It still seems we have to add the declaration at the top...
1
by: Jerad Rose | last post by:
I believe this issue is specific to ASP.NET. Why does VB.NET (2.0) ignore the project-level setting for Option Strict? I have the setting turned on in web.config: <compilation debug="true"...
18
by: Poldie | last post by:
How do I turn it on? I'm using vb 2005 in visual studio 2005 sp1. In my web.config I have: <compilation debug="true" strict="true" /> In my Tools/Options/Projects and solutions/vb defaults...
8
by: Rory Becker | last post by:
A wise man once said: "Never put off until runtime what you can fix at compile time." Actually I think he said it about 10 minutes before I started this post. I am a firm believer, like the...
8
by: =?Utf-8?B?R3JlZw==?= | last post by:
We have an application in our office that has the Option Strict option set to off right now. I do understand it should be set to ON, but right now, I'm just going to continue with it this way since...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.