- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Well there's certainly a problem with a programmer.
Admin
if you really are being serious, why would you do this:
instead of this
Admin
BEST...
COMMENT...
EVERRRRRR!!!!
Admin
We use Dynamics GP as our accounting software. It does crap like this all the time... I especially love running a trace trying to find some data to find that the data I want comes from a stored procedure that is created on the fly and then exec'd.
Argh...
Admin
Maybe that was just a poor example (I can only read VB slowly and cannot speak it), but x = x + 1 is not stupid. Some prefer it because it is more readable (I don't).
The examples in the article would have taken the idea of x += 1 and said in psuedocode ...
if x == 0 x = 1 else if x == 1 x = 2 else if x == 2 x = 3 ... you get the idea
Now that IS stupid in any language and more like the article.
Admin
And how is this an improvement? It does the same thing, with the added advantage of requiring a half-second of additional mental 'parsing' time?
Admin
You were a dolt, but only for not understanding the syntax of the language you were working in. <g>
VB prior to .NET (not sure about VB.NET changing this) doesn't support the operation-assignment syntax. If you want to be able to use that, use a language that includes it; some of those are C/C++, Java, Clipper, etc.
I doubt anybody that saw it after you wrote it that way thought you were a dolt, however, because they probably knew that VB didn't support the += operation-assignment, and that 'x = x + 1' was indeed the proper way to do it.
Admin
Do tell, which of these examples even SLIGHTLY makes sense or looks like a workaround for language "features"?
Admin
Admin
TRWTF is variants - the "= True" part will only succeed if "True" has been assigned to the variant bGroup.
Turn in your geek card, and slap yourself with a wet haddock.
Admin
FTFY.
Admin
Here are the problems (in no particular order): A) bGroup1 (bad variable naming choice)
B) Values of bGroup1 other than 0,1,2 are not handled, but maybe that isn't so bad (See part C)
C) Assuming the hungarian notation is used properly, bGroup1 is a boolean type. Comparing it to 0 or 1 is almost forgiveable (but strange in VB), but comparing it to 2?
D) It could be written a lot more tersely and in a way that is MUCH easier to follow. For example the entire block could have been written as: bGroup = (bGroup1=1 or bGroup1=2)
Admin
I think... this wtf... might... have been submitted... by William... Shatner.
Admin
Because you end up with new people here who have no idea of what has transpired in the time before they arrived, and they jump right in posting to show off how smart they are.
Of course, they don't realize that they're not smart at all, as sebbb so brillantly demonstrated. By jumping into a post made by everyone's favorite troll and correcting him, he didn't realize he had just shown people how smart he's not.
Perhaps sebbb will be smart enough, however, to learn from his mistake and to STFU until he knows the forums and people here better.
Admin
Admin
The scouter is saying "File Not Found" for some damn reason!
Admin
Admin
It must be frustrating to use the = as a comparison operator and assignment operator in the same block of code.
Admin
Optimized!
Admin
I was assuming that bGroup1 is maybe a Nullable type ("undefined"). Of course it's not a real improvement, I was just working around the previous statement, without giving it up, which is not really a good idea.
And ppl, pardon for feeding the troll I did not see :|
Admin
Maybe the original developer didn't have access to edit the queries? Maybe somehow there were hundreds of thousands of encrypted files that included different versions of "WHERE AND" logic? Maybe there's... Nevermind, there's no excuse.
Admin
The apocalypse has arrived; now what do you?
Admin
I'm thinking it's a lazy correction for code like this:
Admin
IT'S OVER NaN!!!
Admin
This is one real WTF
Admin
Not to mention stored procedures are compiled, thereby improving performance. That the dynamic sql would be compiled, however, seems doubtful. The only reasonable use of dynamic sql inside a stored procedure that I've seen is a stored proc that conditionally connects to different databases, but even if you're doing that, it seems likely that there is a better architectural solution to that problem.
Admin
Leeroy Jenkins!!!
Admin
THE obj.value IS OVER 9000!!!!!
Admin
Wait, what? I didn't post this. Nice try.
Admin
The other time I've seen dynamic SQL in a stored proc was when the query had to conditionally run on different TABLES.
Given this very, very poorly designed scenario, is there any other way to do it? I mean besides shooting the guy who designed the database and starting over.
Admin
would be to easy?
Admin
So I have the following, a list of tables, a list of fields that are displayed for each table, predefined queries from the UI how do I handle this?
The list of tables is not the same from user to user, nor the list of fields. The list of tables changes, and the list of fields changes. The user can choose a few different where clauses. How do I do this without dynamic sql?
Admin
Fire your architect and get someone that knows how to design a database.
Admin
I agree! I always code with my business analysts (who also do the QA work) in mind. They want to make sure that we've covered as many bases as possible including ones that no-one has asked for or even though of. This keeps us all on out toes but its worth it since we are hardly ever get caught off guard by feature creep. Our development meetings can last hours as we try to figure out what our user's requirements might be under all kinds of scenarios.
We are also endeavoring to write a table driven code generation application that can assist us in this. The tables and code generation bits are driven by various configuration files; we just start a new one when the one we are currently using becomes too big). We hope to build this to a point where we can write applications using hand written client requests that we scan or photograph.
Captcha = facilisi (Something easy to do in Italy)
Admin
Admin
It must have been one of your team. You taught them well.
Admin
The complicated SQL query is missing a few essential lines:
Admin
Admin
I think I'm guilty of creating a function with too many parameters where a class would have been a better choice. My function requires 13 parameters and returns a structure in order to return 6 variables. Not only that, I set the value of 2 session variables that didn't fit in my structure.
Admin
However, it's not in VBA. I attempted it as recently as last week (at least in Office 2003; YMMV for Office 2007 but I doubt it works there either). That's probably more likely than VB6, at least.
Admin
Actually in VB you False is defined as 0 and True is non-zero.
So the code could even be easier...
bGroup = bGroup1
Admin
Woops I meant "in VB False" and probably since it's a var you should really force that value to boolean, well then nevermind...
Admin
I found this article via an English Grammar and Punctuation WTF web site... where it was the WTF of the day... for its abuse... of the ellipse...
Admin
+= and similar shortcuts were implemented in .NET 2.0 (VS2005), along with a lot of other improvements that makes VB pretty robust (yeah, I said it). But back in the old days, x = x + 1 was the way you had to do it.
Assignment and comparison is still the same (=) but it's always perfectly clear which is which, at least to me. If it's used in a logical statement (if, case, etc.) it will never assign a value. Why would you ever want to assign a value in a logical comparison anyway? if(x=0) print('WTF?');
BTW before you flame me for being a VB lover, I can code in C# just as well...but Intellisense is better in VB which makes coding in VB faster.
Admin
Ha ha sucker, you just got TopCod3d! I hope he's back to stay!
Admin
Hey — it works as documented, that means it's not broken.
Admin
Nope: 1.1 & 2003, respectively.
Admin
Assume nothing. It is not hungarian notation. Well, if it is hungarian notation, the 'b' doesn't stand for 'boolean'.
;)
Admin
First of all, it's TOO not TO and second, for the third time, that is not doing the same thing that the function does.
When did everyone around here become terrible programmers.
Admin
It's always worked well for me, but it seems to be taking FOREVER to handle this Double variable!