RANT: option strict etc

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 a good thing.

i have now been asked to debug a vb2005 web app for 3 weeks and there is no
mention of option strict in it, (there are also no classes defined, just a
couple of structures) everything is define as 'as object', data coming back
from a database call is 'Object' with a string appended to make it a valid
string ...

trying to debug this nightmare is worse than i could possibly imagine

so if you ever are tempted to turn option strict off please consider suicide
first!
 
Guy,

How did you know that Jon Vaughan would sent a message about 25 minutes
after you for which this message can maybe something he has to overthink.

You are completely right in my opinion. Option strict off should only be
used in cases where there is some modeling or testing to be done.

Cor
 
I'm not sure but also it should be "on" by default - when you create a new
project and it should also be difficult to find to switch it off. In fact,
with casting (DirectCast, CType), I can't see ANY reason for making it
optional at all. Only one case I can think of where I needed to switch it
off and that was a workaround for some Interop stuff. I managed to find a
better workaround that didn't require "off" later on.

It's just plain laziness that leads people to code like this.
 
RMT,

It is just off by default because the expected (and probably is seeing this
newsgroup) developers upgrading from VB6 to VBNet 2005. With option strict
on the code would have been only a bunch of errors.

In fact there is in that upgrade than nothing changed in the way the binding
is handled. It is late binding. It runs than still at a speed not comparable
with C# but more like VB6.

VBNet with option Strict on runs at the same speed as C#

Cor
 
RMT said:
Only one case I can think of where I needed to switch it off and that was
a workaround for some Interop stuff. I managed to find a better
workaround that didn't require "off" later on.

Yep, even late binding can be done with Option Strict On using Reflection
instead.

Currently Option Strict can be set only at project or file level. It is a
pity that it can not be set at "code region" level...

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
 
yep, 40-50 errors per control - minimum

Cor Ligthert said:
RMT,

It is just off by default because the expected (and probably is seeing this
newsgroup) developers upgrading from VB6 to VBNet 2005. With option strict
on the code would have been only a bunch of errors.

In fact there is in that upgrade than nothing changed in the way the binding
is handled. It is late binding. It runs than still at a speed not comparable
with C# but more like VB6.

VBNet with option Strict on runs at the same speed as C#

Cor
 
Ahh. Then this is a serious flaw in the conversion process. It's basically
encouraging anyone from a VB6 background to continue on with their dodgy
development ways.
 
definitely.
maybe the problem is that currently you don not need to know of the
existence of option strict to start using vb.net
at least if it was on by default vb6 developers would have to turn it off,
and learn the implications of doing so
 
RMT said:
Ahh. Then this is a serious flaw in the conversion process. It's
basically encouraging anyone from a VB6 background to continue on with
their dodgy development ways.

Fairly bold statements, considering the ~known~ history of VB. If you had
any experience in the former product you'd understand that there can't
possibly be a reliable conversion process, especially with regard to Option
Strict (since the option didn't exist in VB6). Given the options available
in VB6, what would you have recommended a programmer do to prevent the
upgrade errors (remembering that the programmer had to work within the
current technologies at that time and that he had no knowledge that VB would
be completely re-written as a new language in the future)?
It's just plain laziness that leads people to code like this.

Do you honestly believe that "laziness" is a reason to turn off Option
Strict? Ignorance, perhaps, but not laziness.
 
i may be wrong but i read 'conversion' in RMTs comment to mean converting the
developer (retraining) rather than converting the code:)

the app i am working on is not a conversion, it started life as vb2005
 
Fairly bold statements, considering the ~known~ history of VB. If you had
any experience in the former product you'd understand that there can't
possibly be a reliable conversion process, especially with regard to
Option Strict (since the option didn't exist in VB6).

Personally, I think the possibility to upgrade is more of a spec-sheet
feature than something that is actually useful. I cannot see the advantage
of potentially seriously broken code in .NET from developers that may have
been comfortably able to manage it in VB6. What need is there to upgrade,
rather than start over? Medium term, bad VB.NET code or VB 6 code is bad
code period and more costly to maintain and develop. The mapping from VB 6
to .NET is not a natural one.

From my experience, if the plumbing is the most important thing, you can
rapidly re-write this in .NET. If the algorithms are important, then you
can copy/paste and modify those quite easily, within your new and correct
..NET class structure. In effect, I see the upgrade wizard as being for lazy
programmers or managers who don't really understand the difference between
the two paradigms. It was a Microsoft marketing move to gain some
acceptance for .NET from the existing VB 6 base, rather than a useful
technical challenge. Moreover, if you want your VB 6 programmers to become
competent .NET programmers, it is better for them to develop from the ground
up, rather than suddenly being presented with potentially bad coding
practice via. the results of any wizard, which of course will be only the
start of their problems.
Do you honestly believe that "laziness" is a reason to turn off Option
Strict? Ignorance, perhaps, but not laziness.

Well quite frankly often, yes.
 
As a VB 6 developer who has also developed in other strictly typed
languages, the very first thing I did after installing VS 2005 was to go
into the VB settings in the IDE and turn Explicit and Strict On for all all
new files. I also explicitely code them at the start of each file. The
conversion pain is minor compared to having the compiler do a lot of the
type checking grunt work for me.

The should both be on by default when the install is completed!

Mike Ober.
 
I use the upgrade wizard for code snippets, not for entire files or
projects. It's actually useful for upgrading business logic - but that's
about all it's useful for.

Mike Ober.
 
Cor,
| You are completely right in my opinion. Option strict off should only be
| used in cases where there is some modeling or testing to be done.
Option Strict Off is also very useful for COM interop with "untyped" objects
such as CDO 1.2.1

I normally limit any Option Strict Off modules to the smallest Class (or
Partial Class) that I can.

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| Guy,
|
How did you know that Jon Vaughan would sent a message about 25 minutes
| after you for which this message can maybe something he has to overthink.
|
| You are completely right in my opinion. Option strict off should only be
| used in cases where there is some modeling or testing to be done.
|
| Cor
|
| "guy" <[email protected]> schreef in bericht
| | > 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 a good thing.
| >
| > i have now been asked to debug a vb2005 web app for 3 weeks and there is
| > no
| > mention of option strict in it, (there are also no classes defined, just
a
| > couple of structures) everything is define as 'as object', data coming
| > back
| > from a database call is 'Object' with a string appended to make it a
| > valid
| > string ...
| >
| > trying to debug this nightmare is worse than i could possibly imagine
| >
| > so if you ever are tempted to turn option strict off please consider
| > suicide
| > first!
|
|
 
Carlos,
As I responded to Cor:

I use partial classes when I need "code level" Option Strict Off.

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


| "RMT" <[email protected]> escribió en el mensaje
| | > Only one case I can think of where I needed to switch it off and that
was
| > a workaround for some Interop stuff. I managed to find a better
| > workaround that didn't require "off" later on.
|
| Yep, even late binding can be done with Option Strict On using Reflection
| instead.
|
| Currently Option Strict can be set only at project or file level. It is a
| pity that it can not be set at "code region" level...
|
| --
|
| Best regards,
|
| Carlos J. Quintero
|
| MZ-Tools: Productivity add-ins for Visual Studio
| You can code, design and document much faster:
| http://www.mztools.com
|
|
|
|
|
 
Jay,

I was trying yesterday to give the same answer.

But because it was Carlos who had stated the reply I have tried it first.

It did not work.

I will not show you what dump syntax error I made which had nothing to do
with Option Strict off..

I tested it again and it does as I though it should do. (Because I know that
you don't have it in your options and I have, I was first looking in that
direction).

Thanks for replying because I got now the idea it would not go.

Cor
 
Back
Top