|
As I always say, it ain't the tool that is used, it's the tool that uses it that's the problem.
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Spot on!
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
You missed one: it converts int_var (which is presumably a Long ) to a String , and then relies on VB's implicit conversion to convert it back to a Long .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Well spotted - I left that one deliberately to ensure folk are paying attention
Actually, most of the real horrors in this particular code base are more subtle and hard to illustrate in short snippets and more to do with putting too much business logic in event handlers for controls. When a form loads, info from the database is written to a control, which fires an event handler, which writes to another control, which fires an event handler, which... I think you get the picture. Business logic is totally interspersed with UI logic - often broken out into separate modules the contents of which have no logical relation. Global variables are used for all sorts of purposes. "Option Strict" has not been used, and frequently variables are not declared anywhere at all... GoTo's and even GoSub's are used liberally.
I'm just glad I'm tasked with rewriting it rather than maintaining it, but it can be software archaeology trying to determine what the heck the original logic was intended to accomplish.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Rob Grainger wrote: "Option Strict" has not been used
I didn't think VB6 had Option Strict ? From my hazy memory, it only had Option Explicit , Option Compare and Option Base .
MSDN also lists Option Private [^], but I don't think I ever saw that used.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
What happens, if you pass cond as False and Result as 0 (or anything < 1)? Does the function return a Null value and cause an Exception in the If?
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
It should return null, but no exception. it will just be evaluated as false, because null != "YES"
|
|
|
|
|
Rob Grainger wrote: The real real WTF is that people who produce such garbage are still employed.
And quite possibly one of the 23 million surveyed![^]
Say it's not true!
Marc
|
|
|
|
|
My co-worker was struggling with a bug in an old C++ program.
SomeWork();
}
SomeWork() was called regardless of the value of flag . It took her a few hours to find a backslash at the end of the comment.
|
|
|
|
|
ouch
|
|
|
|
|
An interesting way to hide intentiously introduced errors from being discovered...
By the way, how does it come that compilation did not fail?
|
|
|
|
|
Oops! It was like this:
if (flag)
{
SomeWork();
}
|
|
|
|
|
Ah, then it's an interesting variant of
if (flag and some more long conditions filling more than the width of the screen);
{
SomeWork();
}
|
|
|
|
|
That's a reason more to use K&R style (or a variation of it)!! 
|
|
|
|
|
That's a lousy attempt at obfuscation.
Here's a real professional at work: IOCCC[^].
(That is a full hardware emulation of a 1980's PC hardware (much more info in the other files in this folder[^].
Some top aspects:
It is 4043 bytes long (half an 8086).
"It manages to implement most of the hardware in a 1980’s era IBM-PC using a few hundred fewer bits than the total number of transistors used to implement the original 8086 CPU."
(edited for spelling)
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
Whoa... [^].
Greetings - Jacek
|
|
|
|
|
In this case the
if (flag) would be colored in green showing that its part of the comment and it wont be read by the compiler. This should be enough of hint why SomeWork() is executed no matter the flag's value
Microsoft ... the only place where VARIANT_TRUE != true
|
|
|
|
|
That's assuming that the coder was using an IDE that supports colourisation. I know many C++ coders who work almost exclusively in Notepad++.
|
|
|
|
|
Nodepad++ supports coloring. I just tested and it changed the color of the if statement to green.
Note: you need to save the file with the proper extension to enable the coloring of the text.
Edit : Even with Borland c++ and djgpp compilers under dos you still have the proper coloring
Microsoft ... the only place where VARIANT_TRUE != true
modified 15-Jan-14 3:59am.
|
|
|
|
|
And what about those hard core devs who swear by (instead of at) vi? My point wasn't that Notepad++ supports or does not support colourisation. It's that you can't rely on colourisation to indicate problems.
|
|
|
|
|
You can if you're not masochist 
|
|
|
|
|
Hey, I like vi. There are parts of it that I wish were available in Visual Studio. dd for instance. Or 10dd to delete 10 lines. Yes, you can do this using other means in an IDE, but they are all more cumbersome.
|
|
|
|
|
I have some exp with vi. I didn't see any particular bonuses which will make me change the compiler, but q! has his advantages
syntax coloring in vi and vim
Microsoft ... the only place where VARIANT_TRUE != true
|
|
|
|
|
That is pretty cool. I didn't know you could do that.
|
|
|
|