- 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
Admin
This looks as creepy as the INSERT-generating SELECTs I've seen in some apps. Moreso that the "trick" could've been done with pure C#, even if it would still look like a cheap hack. Which it is.
Admin
Mine look like
x += 1 # Add 1 to x
Obviously I'm using the better programming language.
Also: CS's code highlighter cannot recognize an escaped backslash at the end of a string. Or was that some other highlighter?
Admin
First day on the internet? Don't worry, you'll get used to it.
Admin
Well, I could have done:
x += 1;
or even
x++;
But, I like to write it out in full to make it clear what I'm adding one to (and then reinforce in the comments).
On the other hand, using # for comments is just plain silly. # belongs in the names of programming languages.
Admin
I prefer to eliminate confusion altogether...
x = x + 1; // add 1 to x (so x is one bigger (or much, much smaller))
Admin
It's better than --.
Admin
You must have made a mistake. I get 0.
Admin
We are paid by the line of code and therefore it is much demanded that we document our code as thoroughly as possible to provide the greatest value to our customer, therefore we document each line similar as follows
x = x + 1; // take the value represented by the variable x and add 1 to it so that it becomes one larger, though possibly much, much smaller if an overflow occurs, then assign this new, possibly incorrect, value back to the variable x
Admin
Rahim, you are fired. I tell you time and time again that comments must stand out separate from our code so customer can follow them. The proper format is followed:
// Comment for next line of code starts below: // take the value represented by the variable // x and add 1 to it so that it becomes one // larger, though possibly much, much smaller // if an overflow occurs, then assign this new, // possibly incorrect, value back to the variable x x = x + 1;
Admin
Store it in /dev/null and we're done.
Admin
Admin
Admin
Aaah, finally, a good old-fashioned WTF. No silly made-up story. Just painful code. Code that even (probably?) works, but leaves you scratching your head and wondering why any sane individual would think that was a good idea. Thank you, Mark, for a quite enjoyable post.
Admin
Admin
At least the summary isn't larger than the full article.
Admin
Or made use of the #import statement in VC++ and skipped VBS entirely.
Admin
Admin
It should now be:
// add 1 to x // [2009-09-09] Added a semicolon to resolve compiler error 0x22c (see ticket 87654334) x = x + 1;
Admin
Admin
Oops, you're using Windows. Sorry. You have my sympathies.
Admin
The DoD has used ADA for years without nuking us yet!
Admin
You're just too cheap to buy a quantum computer, aren't you?
(Strictly speaking, a singularity would be a 0-bit file. Gets a bit hairy at the boundaries though. Now, what was I saying about a quantum computer?)
Admin
By all means, stay unregistered. An occasional brain scan for lesions might be advisable, however.
Admin
Yer gettin' old and weak: your WTForce is waning, old man. I mean, what extra goodies did you expect?
Admin
Admin
To be honest in this case again the original developer is more genius than the poor guy who is trying to "maintain" the code and unfortunately do not have a clue.
My questions: why to send this one to thedailywtf in the first place? And even more the question to Alex: what is really the WTF? Comma in wrong place, wrong indentation or something more catastrophic in horizon? The code is beautiful hack when management says that no 3rd party software allowed. MS full stop.
As a teaser to the original poster and to the others : how you will implement the same functionality?
And please put the timer on and let me know.
</clue>-- Jeesh - I am getting old.
Admin
What on Earth does "producing shit language output" mean?
I'd be the first to admit that <insert Sturgeon percentage here/> of projects written in C++ are crap. I'm not aware of any statistics that report this as either a higher or lower figure than Java (which I think is a fair comparison) or even COBOL (which I suppose might be considered to lie in a different application domain).
Bottom line is, it's trivially easy to spot a crap C++ programmer -- and that's about 95% of applicants who claim they've got 2+ years' of C++ experience. It's nowhere near as easy to spot a crap programmer in Perl or in <insert Web framework of choice>.
Of course, that leaves you with an awkward choice:
(1) It's completely the wrong language for the job, but it works, and I can pretty much avoid retards. (2) It's absolutely the correct language, framework, platform, and indeed burn-scented-offerings-to-the-agile-god-of-my-ancestors choice, but I'm gonna be pestered by retards from half past eight in the morning until I shut my mobile off at 3:30 am on Sunday morning.
A tricky choice, that. But we're all computer scientists here. We can all do the Boolean.
("I was working in a Data Center, late one night, when my eyes beheld a hideous sight ...")
Admin
All Grammar Nazis imbibe, with their Mother's Milk, the indisputable fact that it is permissible in the English Language (American Deviation) for one to Verb Nouns.
It is Inadvisable to Verb Adjectives, because an Adjective might accidentally be a Gerundive, which has therefore already become an Adjectavili[s|z]ed Verb.
There is, however, no rule in the Grammar Nazi Handbook to forbid, or even to deprecate, the Verbing of Adverbs. Clearly, an Adverb without a Verb is the grammatical equivalent of a deserted single mother: without its partner, it is responsible for doing the best job that it can.
Do not, however, attempt to Conjunctivise a Preposition. This is possible, but very dangerous indeed. (Usually, it takes an Awful Lot of Squinting.) It is best left to Experts.
As for Hanging Prepositions -- well, I'm not alone in saying that hanging's too good for 'em. I'd quote Leviticus on this, but I'm sure we're all Good People here.
Now, if you'll excuse me, I'm off to get Stoned.
Admin
;-)
Admin
Where exactly do the Matryoshka Dolls come in to this?
Admin
Well, as pointed out upthread the overall code quality is pretty terrible. But I'd say the WTF is the use of a complicated hack involving using one language to output another, when there must be a simpler way. Creating the empty zip file could have been done from C. And I'm not a windows programmer, but I find it hard to belive that if there's a VB copyHere() function there isn't an equivalent in the C windows API. Indeed, a look at MSDN yields http://msdn.microsoft.com/en-us/library/bb787866.aspx although it's not clear to me from this documentation if it can be accessed from C.
Admin
Sorry, I did not find it, even though I really read all the posts. I suggest that you do same for my post. Try again. I think I gave some carrot.
And your point after all is?
Ditto.
</clue>-- Jeesh - I am getting old.
Admin
He should have used BARF compression, guaranteed to compress any file down to zero bytes in size.
Admin
[quote user="dkf]But goodness me, it's a fragile lash-up; if only there were zip tools that could be driven directly from the command line... [/quote]
Time to clear all the red tape required to get a third party zip tool installed on the system: 5 months (and lose your sanity in the process).
Time to hack together a nasty but workable solution in a mess of C# and command line VBS - 1 hour (at the cost of other people's sanity).
Admin
Thank you David, you got it. Wo/ any technical BS. It is after all question of money and not the beauty of the code.
BTW, to all you wannabe hackers, it is always question of the money what ever you are going to do.
</clue>-- Jeesh - I am getting old.
Admin
TRWTF is around this line: strcat(lpPathBuffer1,"\syswow64\"); Someone's syntax highlighter fails miserably here.
ADDIU $A0, $A0, 0001 ;add 1 to $A0Admin
Admin
Admin
Admin
C#...
Sometimes a simple bit of code needs a comment.
Admin
Sure but would you have figured out that dwBufSize was the buffer LENGTH? Or that lpPathBuffer1 was the path buffer? That stuff is HARD to figure out.
Admin
Why post it to TheDailyWTF? Because it is WTF code. A few people have already pointed out some of the problems with it.
I don't know how I would have done it. I don't know the requirements. I probably would have created a folder, placed the files in the folder. Then called zip on the folder.
Or perhaps do most of the work in C/C++. Create the folder, even send the copy commands. Why create a VBS script then execute the script?
Admin
TRWTF is how many people keep saying this code is C#.
Admin
In case there was no third party library available for free I'd say:
IF SOMETHING IS STUPID AND IT WORKS, IT AIN'T STUPID.
Admin
Admin
Minimum requirement is to have .NET Framework 2.0
Addendum (2009-02-10 03:45): And even better is System.IO.Packaging if you have .NET 3.0 or higher
Admin
The complicated crap of VBS generation and execution just isn't necessary. Not unless the original developer of it is one of those who'd be better off staying in Programmers' Kindergarten.
Admin
A short while ago I needed to satisfy very similar requirements - enable ZIP compression/decompression without using any third party tools. I created a ZIP compressor in .NET using the GZipStream class (System.IO.Compression, since .NET 2.0). All in, it took about 30 minutes. The problem was that files compressed with this utility actually came out LARGER than the original source files. I've never gone back to GZipStream.
Admin
What makes me WTF is how someone could come up with such a clever (albeit kludgy) hack and implement it in a way that's just plain 100% clueless.