- 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
The WTF is that if the connection hadn't been explicitely opened before the call to daHSB.Fill() then Fill would have opened and closed it automagically. Since they had opened it before the call, it stayed open.
Admin
I'm not sure if I shared this story in the past, but I once got asked to help improve the performance of a ticket handling application for a church. They were selling tickets online for their play, but their site could only handle something silly like 20 purchases per hour, and then their site would just hang.
Being the quick thinker that I am, I quickly realized that 20 transactions per hour is a bit on the slow side. Well, in the process of working out a deal with this church, the sales guy notices a freakin' printer plugged into their webserver. They were printing things on the fly when ticket purchases came in. And when the printer ran out of paper, the programmers simply stopped taking orders online.
Brilliant!
Admin
You gotta love all the nested using statements. This would have been okay, as well:
The efforts to create a logo for sure havent't fell of the radar :)
Admin
Thing is that, no matter how you look at it, this message board software is indeed the biggest WTF of all.
Each using statement was supposed to go on a new line, but no, that was too much to ask :)
Admin
Guess that programmer doesnt understand that DataSets are disconnected objects....how sad. Isnt that one of the first things you learn when you transition to ADO.NET.
Admin
Well hey, learning to put question marks at the end of a question is one of the first things we learn in school. I guess it's possible for everyone to forget things, isn't it?
Admin
Funny one. Perhaps code like this is the source of those "using blocks don't work" rumors?
I can't really blame the coder much for this one. It is sloppy not to free resources as soon as you finish with them. But this looks like just an easy to make mistake.
Admin
Eh, dsReport is a type name? Yikes.
Admin
J-J-J-Javascript!
Admin
You know, reading this code, I think I finally understand what's wrong with modern programming lang -- uh, hang on.
Noun.Person(psnAbstract).AsPronoun(YOU) Verb.Infinitive.Know, Verb.Participle.Continuing("Reading") this->Noun.Abstract.Code, Noun.Person(psnConcrete).AsPronoun(psnI) Verb.Think Noun.Person(psnConcrete).AsPronoun(psnI) Adjective("Final" /* ly */).AsAdverb Verb.Infinitive("Understand")...
Uh, you get the idea.
The real WTF in today's entry is the language. Programming languages are supposed to be less stupid than this.
Admin
What a brilliant comment, I completely agree.
I wonder what it is nowadays with most abundant (or hyped) languages being syntactically C-based (like C++, Java, and C#).
I, for one, value readability over writeability on programming languages, and a language which uses almost all possible special characters from the keyboard simply doesn't cut. I'm not American, but I still believe that the DoD got a lot right in their Strawman-Steelman progression.
(Sorry, I am drunk while writing and I now realize that this reply does not have almost anything to do with the post I'm replying to. Nevertheless, I believe I said something useful [:)] )
Admin
yay, Ada rocks! AFAIK there haven't been any Ada-wtfs posted here ;)
Admin
Give me five minutes to learn Ada, and I'll set one up for you :P
Admin
C, C#, Java and C++ are all quite similar, but they and Ada are all really just Algol dialects - as are Pascal, Perl, JavaScript, and many more. A case could even be made for calling Python an Algol variant. What, when you get down to it, is the difference between:
<font face="Courier New">if ($x =~ m/[^a-zA-Z0-9_]/) {
die "Illegal character in $x";
}
</font>
and:
<font face="Courier New">if RegExp.Matches(X, '[^a-zA-Z0-9_]', []) then
begin
raise Exception.Create('Illegal character in '+X)
end;
</font>They're all the same, give or take a bit of syntactical sugar (like the infix <font face="Courier New">=~</font> operator) and some search-and-replace.
A completely different language - like, say, a well customised version of LISP or Forth, could produce a much more readable bit of code than the parent posting. Granted, you could improve matters in the short term using C macros, but they come back and bite you where extensible languages don't. On the gripping hand, postfix and prefix syntax are bitches.
A language with Algol's operator syntax and LISP's macros or Forth's <font face="Courier New">CREATE ... DOES></font> would be awesome.
: Bat :
Admin
I think that's the first time I've ever seen someone use "on the gripping hand" in an actual discussion...
Admin
Being a mostly VB(.NET) guy, I haven't spent a lot of time in the C syntax derived languages, so I'm curious: do you find that using using makes managing the disposal of resources significantly easier than just disposing of them explicitly or letting them die when they go out of scope (where appropriate)? I'm not asking the question to knock it; it's just that doing it that way never occurred to me and I'm genuinely curious.
Admin
I have gotten into the habit of using using statements, as there is less chance of forgetting to clean up after myself. I'm not experienced enough to know how/if cleanup happens if an exception is thrown by the object created in the using statement, when there are external resources (ie, db connections) involved.
.
Admin
Ya'know, if I had some time to play, I think I could get
<FONT face="Courier New">if (x =~ m/"[^a-zA-Z0-9_]") {
die ("Illegal character in "+x);
}</FONT>
<FONT face="Courier New">compling/working in C++ (I'm assuming "m" in the python script is a regex matching operator, right?)</FONT>
Admin
OK, I had some time.... This compiles & run as expected, as either a stright C++ program or as a .Net app. Ask nicely & i'll post magic.h
<FONT color=#0000ff size=2>#define</FONT><FONT size=2> DOTNET
</FONT><FONT color=#0000ff size=2>#include</FONT><FONT size=2> "magic.h"
</FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> Test(std::string x)
{
</FONT><FONT color=#0000ff size=2> if</FONT><FONT size=2> (x ==~ m/"[^a-zA-Z0-9]")
die("Illegal character in " + x);
}
</FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> _tmain()
{
Test("abcDEF123"); // passes OK
Test("#$%^&"); // Throws exception
</FONT><FONT color=#0000ff size=2> return</FONT><FONT size=2> 0;
}
Not exactly the syntax I was going for, but very close....
</FONT>Admin
OK, I had some time.... This compiles & run as expected, as either a stright C++ program or as a .Net app. Ask nicely & i'll post magic.h
<FONT color=#0000ff size=2>#define</FONT><FONT size=2> DOTNET
</FONT><FONT color=#0000ff size=2>#include</FONT><FONT size=2> "magic.h"
</FONT><FONT color=#0000ff size=2>void</FONT><FONT size=2> Test(std::string x)
{
</FONT><FONT color=#0000ff size=2> if</FONT><FONT size=2> (x ==~ m/"[^a-zA-Z0-9]")
die("Illegal character in " + x);
}
</FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> _tmain()
{
Test("abcDEF123"); // passes OK
Test("#$%^&"); // Throws exception
</FONT><FONT color=#0000ff size=2> return</FONT><FONT size=2> 0;
}
Not exactly the syntax I was going for, but very close....
</FONT>Admin
</font>
<font face="Courier New">That isn't python, judging by the =~ operator and the die keyword, I believe it's perl. In which case x is the variable, =~ is a pattern match operator. </font><font face="Courier New">m/"[^a-zA-Z0-9_]" is a quoted regex pattern with multiline modifier, I think m/</font><font face="Courier New">[^a-zA-Z0-9_]/ would be equivalent - but that isn't a promise.
</font>
Admin
Cool - go looking for "polyglot programming" on $your_search_engine_of_choice. It's the utterly, utterly frivolous art of writing programs that compile in two or more languages. One trick, for example, is starting a line with <font face="Courier New">#if 0</font>, which in C/C++ makes the following lines invisible, but in Perl/Python/etc is merely a comment line. I imagine you can think of more tricks. Then, when you're an expert in polyglottage, try your hand at quines...
Admin
<font face="Georgia">Oh... and
</font>
<font face="Courier New">if ($x =~ m/[^a-zA-Z0-9_]/) {
die "Illegal character in $x";
}
<font face="Georgia">
... is indeed Perl -- and the other version was Delphi, a Windows-based object-oriented Pascal. It basically says "Fail with an error message if even one character in the variable is illegal", where "illegal" means anything other than a letter, a digit or an underscore. You might use logic like it in a "register as a new user" script on a forum like this one (and then ignore the screams of users who want to sign up as <font face="Courier New">François</font> or <font face="Courier New">André</font></font></font><font face="Courier New"><font face="Georgia">... but it was only an example).</font></font><font face="Courier New">
</font>