|
|
It was a long process of giving him a roll kick to the nadgers every time he checked in a file without Option Explicit . We needed to have a rota.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Jörgen Andersson wrote: If it's not the highest priority your company has problems. If we make it our highest priority we'll be fixing software that 'works' as far as the customer is concerned. We won't be able to make new software anytime soon. We won't have any revenues for the coming months, just fixes that might not fix all they were supposed to fix. And lots of angry customers.
No, if we made it our top priority THEN we have a problem... I might not be happy with it, my boss might not be happy with it, but that's just the way it is.
Luckily, any new software we built is built with option strict on
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
Jörgen Andersson wrote:
Naerling wrote:
Our company has a product where turning Option Strict On results in probably 1000's of errors
Then you need to start fixring now.
...snip...
If it's not the highest priority your company has problems.
FTFY
|
|
|
|
|
The Law of Missing Parentheses: Keep adding closing parenthesis at the end till the compiler stops complaining about them.

|
|
|
|
|
This is why it's good to always explcitly define your intentions with the proper parenthesis.
It makes it easier to detect mistakes like that and for someone else to read and deduce your intent. You can easily produce similar errors in logical grouping in C# or other languages. Even if not with that particular syntax. 
|
|
|
|
|
Option strict FTW! Option strict all the way!
Option strict is the first thing I turn on when anyone hands me a VB.Net project. I'll say it a million times: I would rather get a compile time error than a runtime error. Option strict won't flag every possible runtime error, but it will flag most of the boneheaded ones.
|
|
|
|
|
I can develop in more than 10 language (actually, I don't know exactly how much languages I now, I always forgot some) and I have no preference for the best language.
Almost all the time I use C#, but I use others as needed if the moment needs and it pays my bills.
But, I really don't like VB at all. I know VB since VB 5.0 (or 3.0, I don't remember, the year was 98) and these syntax flaws are really annoying. The VB (also VB .net) rounding is also terribly, all languages that I know truncate integer division and VB round it.
The backwards compatibility of VB .net with VB 6 projects made VB .net a horrible language.
I'm really experienced with VB (and VB .net) and it's a pain to correct legacy code in this language, so good luck!
|
|
|
|
|
You Remind me my Old company. Joining them I started developing with VB6. In my Project I did the entire project keeping Option Explicit on. Then I gave that entire project to my Senior.
Then he complained: Hey I cannot program, its making error.
??????????????????
what ????
I know I am coward since the day I know that fortune favors the brave
|
|
|
|
|
Before people start... The horror is NOT that this is VB code... Now with that out of the way...
A bit of weird code a colleague found recently...
If code.Length < 5 Or code.Length = 6 Or code.Length = 7 Then
Throw New Exception("Code should be 5 characters long.")
End If My guess is that the programmer assumed it would be 5 characters long or less. Then it turned out it could be 6 too so the Or code.length = 6 part was added, then the code was 7 at some occurrence... The users weren't stupid enough to enter an 8 character code so that one hasn't been added (yet)
Why not simply check if code.Length <> 5 ?
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
At least the programmer added a comment stating what the code should do. 
|
|
|
|
|
If only the code did what was commented... Perhaps requirements changed and the comment is wrong?
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
}
|
|
|
|
|
Maybe the comment and the error message should have been
' This code should always be 5 characters or more than 7 characters.
|
|
|
|
|
Then he should correct the exception too:
"Code should be 5 characters long OR longer than 7."
Giraffes are not real.
|
|
|
|
|
OMG ... I can't look at it. I'm feeling sick. Thank you for ruining my day! 
|
|
|
|
|
or simply set the max lenght of the textbox = 5
|
|
|
|
|
In order to write secure code... whatever how important is your input, do Not trust the client, validate input data even @ back-end
think about client Validation just like good interface, to ease user life, to reduce hits on the server... no more
Last Egyptian Physicist
www.ameen.rr.nu
|
|
|
|
|
What? That's all you got!? I've seen this s**tstuff for years! 
|
|
|
|
|
What's so bad about being explicit about what you don't accept as a valid value?
Besides that, we also have a lot of literal values here. Checking the length against a constant or some configuration entry can be helpful, especially because the code's valid length may have changed over time. Throwing a plain vanilla exception with a literal message also is sloppy. It's not that hard to derive custom exeption classes for your application and would help in avoiding Pokemon exception handling.
I'm invincible, I can't be vinced
|
|
|
|
|
My fix
If IsPrime(90*code.Length+61) Then
Throw New Exception("Code should be 5 or anything above 7 characters long.")
End If
modified 27-Jan-12 10:13am.
|
|
|
|
|
Are you a member of Obfuscators Anonymous.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Yeah, at the Novice rank. I hope to go up to Apprentice this year.
|
|
|
|
|
Hey, VB is great. It is much easier than C#. I do everything in C# but don't hate on VB.
|
|
|
|
|
Difference between VB or C# is a syntax, thanks to the .net framework. But if you ask what do I think is that C# is better. But ultimately it comes toward preference.
|
|
|
|
|
Just goes to show that some programmers haven't got a clue!
A perpetual holiday is a good working definition of hell.
|
|
|
|