- 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
or even, for added obscurity: For i1 = sgn(m(1)) to m(1)
Admin
This reminds me of the day that Dennis (the project manager) came to me asking what some obscurely written code did. I walked him through the logic and that led to some related code, I explained that too.
Nigel asked about the very different styles of code I'd used. Then I explained the first bit was written by Robb and the second bit by Rob (yes that did cause confusion - they were both still on the team).
He looked confused - "but Robb sent me to you because he didn't understand the first bit!"...
Admin
Admin
Jeez, I feel sorry for all you rubes who are limited by your recursive-descent language parsers that get hung up over a detail like a repeated word.
I, with my full natural language parser, didn't even notice the problem until attention was called to it!
Admin
Admin
Admin
YEah, also, using TTD you have to think things through before you start hacking away, so less patchwork programming. Hopefully.
Admin
Admin
Then they don't really understand TDD. I find it quicker to write something TDD than to not.
Admin
On the other hand, shitty developers can claim to be using TDD, ergo their must be "bug-free", and they've got the coverage reports to prove it. Don't laugh, I see it all the time. There's 2 ways to raise test coverage, pushing it up and pulling it up. But all a manager wants to see is a high figure, he doesn't give a toss that it's completely artificial. I'm much more likely to trust code with 80% coverage than something that claims to have 95% coverage.
Admin
Sensible software practice ~ either. Maybe.
Sip that kool-aid, stop yawning, and explain why this drivel never claimed to be doing anything new. Then explain to me what point I've missed.
You're due for a libel suit if you claim once more that I've "simultaneously been claiming to do it all along." I claimed no such thing. XP is a ludicrous cult. Agile is a slippery eel that redefines itself whenever a practitioner feels the need.
You're evidently too close-minded to save, but for anybody else: download Mr Ed.
It's always helpful to prepare your position against these dimwits.
Admin
Just the WTF programmers.
In fact, this gives credence on why VB is a bad idea. :)
Admin
something tells me Jasmine has never worked in any kind of fly-by-night startup or dealt with much legacy code before. sure, all those controls (you forgot documentation) are great. even better, they're generally put in place...eventually.
Admin
and here I thought I was the only one who was busy watching the pretty boat go by!
Admin
Wouldn't this code need to be converted to C++ first? VB5 code won't compile in a C++ compiler...
Admin
That isn't particularly complicated or difficult to understand. It's actually really simple: each index is a pair in a numeric sequence, each loop simply increments the pair until the higher order pair is equal to its lower neighbors or some predetermined maximum per value. so if all the m values were 16 then:
Combination: 00000000000000000000000000000001 00000000000000000000000000000002 00000000000000000000000000000102 00000000000000000000000000000003 00000000000000000000000000000103 00000000000000000000000000000203 00000000000000000000000000010203 00000000000000000000000000000004 00000000000000000000000000000104 00000000000000000000000000000204 00000000000000000000000000010204 00000000000000000000000000000304 00000000000000000000000000010304 00000000000000000000000000020304 00000000000000000000000001020304 etc...
This gives a list of all possible combinations of values with less 16 or less unique values with 2 or less digits each. Now why you'd want to do that I have no idea.
Admin
Of course if the & in vb5 is a logical AND and not concatenation and if Format just pads with 0s then this generates the logical AND of each pair with is then 1,2,3,3,4,5,6,4,5,6,7,7,8,9,10,5, etc... which i guess could be useful for something maybe?
Admin
I pasted the code into VB6 and ran it with "gaps" in the m() values. The output does not include "00" for each of the ix variables corresponding to an m(x) that equals zero.
(It scares me that the last sentence actually makes sense.)
This is because the code - as posted - did not include any variable declaration or initializiation which may have existed in the original. VB can run in a mode that does not require variables to be declared or initialized. In this case, all variables are of the variant data type and have a default value of "" (empty string). So, Format(ix, "00") will produce an empty string when ix is an empty string.
If, however, the "i" variables were declared as integers, then the output would include "00" for each m(x) equal to zero.
Admin
It looks kinda cool, kinda like the mothership from Homeworld.
Admin
Iiitttt... I... it's... so beautiful... grandp-- head explodes
Admin
OK I'll respond to that... my post before was a joke. However, it would not be funny if it didn't have an element of truth. I have been coding for 30 years, and have worked in many shops, from small start-ups to multi-billion dollar international companies. I've seen it all.
We all know that best practices are so named for a reason. However, what I see in most companies is a feeble attempt at a proper development process, and a heavy focus on "just get it the hell done already" - and surprisingly, this does not always lead to major problems.
In the places where I've seen TDD and SC systems used properly, and a good attempt at peer reviews, I've only seen a marginal increase in the quality of code. I could name names... there is a vendor I'm working with right now - on their web site they claim to use Agile, claim to use "best practices", claim this and that - but their code quality is some of the worst I've ever seen. Their product costs over 1 million dollars, without customizations... it isn't worth $39.95. There are snippets of code in their product which resemble the WTF in the article. On the other hand, I've also seen products that cost $20, developed by one guy, using no practices anywhere near best, which were done very well and worth way more than the $20.
I am often on the phone with this vendor discussing their code, and I'm known to say things like "why don't you pull that from source control" or "just send me the documentation for this code, and I'll figure it out from that" - and I fully know that their source control is out of date and there is no documentation.
Certainly there are places where good practices are followed, but they are fewer than you might think... and in many cases, simply using the process doesn't result in a better product.
So that's why the joke is funny... and also why it's a joke.
Admin
As much as I am an advocate for practices such as TDD yada yada, I godda agree.. I've seen some really bad code that 'obeys the practice', but comes short of being anything near 'ok'.. (though I have noticed when you see bad tests (with 95% coverage or whatever) you tend to see bad code under it..
in short, no practice, pattern or language results in better code if the developer is crap.
Admin
Screw you all thats my code and it is great just because you don't uhnderstand it your all useless coders anyway
Admin
what except reviews has to do anything with that code snippet ?! are you people still in undergraduate management course or something ?! :D
Admin
This WTF has now been cited on an University paper as an example of Bad Code. Thanks.
Admin
Please could everybody try to be as acidically witty as this poster? Thanks so much.
Admin
I agree, with crap developers you get crap code. If a crap developer writes the code, and a crap developer reviews it, its gonna pass the review. Gotta have a good dev that doesnt mind stepping on toes doing code review. Its completely wasted otherwise. No process ever will make bad devs good, thats what experience is for. (And yeah, some people are immune to experience). I had a friend that wanted to be a programmer, but his code was downright awful. He asked me for help with a private project once and in a weak moment I said I'd help. He sent me the code and it was just a big clusterfuck. Indentation was wrong all over. He had 2 methods or something of some seriously retarded code. I looked at the code, sa what it was supposed to do and rewrote it from scratch and sent it back to him. He couldnt understand what my code did. I did things like break it up into classes and, ooh, methods! And separate things in a decentish way. Anyway, he is one of those that cant write good code if his life depended on it. And he never learned.
Admin
Now go and watch the simpsons episode with Bart as fallout boy.
Admin
Well... some parts of those anti-VB rants are justified, because any decent structured language simply does not have a "goto"-statement and does not allow for such WTFs in the first place... which does not mean that you can't create massive WTFs in such a language, but a whole class of them simply isn't possible.
Captcha: inhibeo. indeed, indeed... ;o)
Admin
I wrote that. What part of it do you not understand?
Admin
Just wondering what you classify as a decent structured programming language. A large number of mainstream languages have 'goto'.
Not that a I like goto or use it (other than in batch files, SQL error handling, and having to touch some VB6 a couple of years ago)
Admin
This is probably used in e-voting software to steal votes, and its ingeniously obfuscated to create plausble deniability. Just watch. If Sarah Palin is elected in 2012, we'll all know why.
Admin
At least the code's indented...
Admin
O yes, I was there back in 1999 when uNIT tests were invented. Before then we had to use tNIT tests (VB5), and pNIT tests (UCSD Pascal). I even worked on DEC FORTRAN accounting system that was built and tested using only fNIT tests. Used to get the NITs out of computer programs (We didn't call them 'Bugs' back then).
Of course, at the beginning computers were only for hobbyests, so testing wasn't important.
Admin
The use should be obvious, it's a GUID generator that takes the last GUID in a DB as the input and generates a random, larger GUID.
Admin
It appears to be that the writer of this code figured out how to remove null entries in an array by drinking vanilla extract and staring at his clothes in the washing machine at the laundromat.
Admin
Whoa man! That's beardy!
Admin
These are not real stories, they're just creative writing.
Admin
CAPTCHA: fiction (everything)
Admin
The real WTF is that almost everyone in this thread (and of course submitter Vladimir) has jumped on the bandwagon of 'this has a lot of if statements, it must be bad code'. It is not so difficult to understand why it's not implemented as a recursive function. No one actually gave a correctly working example of how to perform the same computation more elegantly, and if they had I would expect it would either run at half the speed, or be significantly more complex.
Admin
Now this would make a really good programming praxis.
Admin
best quote ever! you win teh prize
Admin
Yikes! Now we know why TRWTF is VB 5, I guess.
It also just makes this example that much more bad. I'm not going to try to refine my version until I can guess exactly wtf this code is supposed to do. Sure, it generates unique combinations of an obscure sort in a way that will guarantee it a sort of immortality. But WHAT IN THE WORLD is this list going to do for us?
Admin
The code snippet puts me in mind of those infamous tests that end with : ##) Ignore all of the above instructions except for the first one.
The main problem is the "Exit For" clauses. If more than one of the "m" array terms is non-zero then you may get either few results or garbage. If the "Exit For" clauses were "Continue For" clauses then you might get something useful. Then there is the problem of the excessive nesting. My FORTRAN teachers would hang those who exceed three levels by their thumbs.
"Continue For" a la Python
Admin
Code works in mysterious ways.