- 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. You can leave the code out entirely and wait for a user to complain.
If someone complains, they might (maybe) know what should be there.
If no one complains, then you've won.
Admin
PS If she's male, I don't want to know. PPS Nurse! Has the psychotherapist brought the coggles yet?
Admin
I think it probably did need to be this way, for optimisation reasons. It's not just VB either, but any function which has O(x^16) is going to need every optimisation trick squeezed out of it. Patrick's attempt at making it readable is actually just making the code run slower than it needs to. Even just calculating where x<20, Patricks code takes 8.6 seconds to run on my machine, and the original takes 5.1. But maybe speed isn't the important thing.
Actually, I just looked at the output and Patrick's gives some different results. Also it doesn't work when you have a simple case such below. Obviously for rewriting an old app that many people rely on, it's important to cover regression.
Patrick, try making yours work with this data. For i = 1 To 16: m(i) = 0: Next m(1) = 9 m(4) = 9 m(7) = 9 m(10) = 9
You should get: 01020304 01020305 01020405 01030405 02030405 ... (skipped a bunch) 04070809 05070809 06070809
So perhaps Vladimir has done the right thing to just copy-paste the code. Waste of time trying to understand it.
Admin
Unit tests? Source control? Peer reviews? Are you people still in college or something?!
Admin
Isn't it about time we had a WTF submission written in LOLCODE? Go on, you can invent the surrounding details yourselves. Just add a few 2D cow-orkers into the mix, a headline quote, and some gratuitous spelling or grammar quotes. Alex would be none the wiser.
Of course, it would still make more sense than the abortion under current discussion.
Admin
Yeah, that's what I was thinking. You just replace that whole section with a msgbox() and/or maybe a general error handler (on the assumption that the code's absence might make something blow up). You give the user a message like, "This portion of the program has been disabled because the code made no sense. Please contact the engineers and we'll try to get the code working again just as soon as we can figure out what it's supposed to do."
-- Furry cows moo and decompress.
Admin
Let's not.
Any function which has O(x^16) needs marinading in garlic sauce, a stake through the heart, and a convenient cross-roads for the grave. (Preferably somewhere in the Appalachians, where nobody will find it and dig it up again.)
This is, unfortunately, where impedance mismatch with the PHB steps in.
Me: Can I go down to the store and buy several garlic bulbs and a large pointy stick? Apparently not. Me Can I spend two weeks rewriting this so that it's only O(NlogN)? Why would you want to do that? We'll just buy some more hardware. Me: If I squeeze that point on the top of your head, will your brains spurt out?
Optimisation tricks, two legs. Sanity, four legs.
Admin
OK I admit I occasionally buy a single lottery ticket. If you don't buy a ticket, you can NEVER win. It does amaze me when I see someone buying multiple tickets to improve their odds. That is like climbing as six foot step ladder to get closer to the sun.
Admin
You do know what "peer" means, don't you?
Admin
Admin
Admin
At least there's another company out there that produces code of the same quality that I've had the pleasure of meeting at my current employer. I'm not saying my company wrote such code but our customers are proud of that their work is being used in our work...
Admin
Actually a person that plays the lottery has a much better chance of winning than one that does not. I'll take 1 in a billion over 0.
Admin
Admin
Okay, what the hell, people? This code was obviously generated by a program. The WTF is not this code (which is probably efficient at whatever it does in the context it is used), but the fact that nobody can remember WHAT it does or WHERE the program that generated it is kept.
Have you seriously never seen generated code?
Admin
No, IBM
Admin
No college student is that stupid.
Sounds like somebody's headhunter jazzed up the resume for them.
Admin
Apparently you don't follow baseball.
Admin
That.
Admin
Seriously.
Admin
Wow. This brought me back to when I first learned the GOTO statement. I really miss that little word sometimes.
The author of this beast is not nearly familiar enough with recursive methods. Or, did that version of BASIC even support them?
Admin
No, just work for a shop that sticks closely to the Agile methodology in both deed and spirit.
Unit tests. Ok, so you may not want to, but they're not hard to do when you're writing the code, and they really make a difference in quality.
Source Control. Everyone uses source control. Probably 80% use it wrong, but everyone needs source control.
Peer Reviews. Unless you're a perfect coder (which you're not), then you need peer reviews.
Admin
Oh, I'm sorry. What I actually meant to say is:
"It is possible to write horrible code in any language; not just VB5. It is even easier if you like to spend your free time in the Bronx, watching a bunch of hired millionaires who could care less whether your language is Turing-complete or not."
Yup, that's about it. Eat beans and die.
Admin
No. Your code executes once for 0, twice for 1 and so on. This code executes once for 0, once for 1, twice for 2 and so on.
Admin
On the other hand, you could (a) not hire idiots and (b) fire idiots when you realise that they are idiots. But that would put the Agilistas out of business.
Whatever. That's agile, baby!
Admin
Translate it to VHDL and compile it to a gate array. It might actually be easier to understand.
Admin
While there is a small chance I might win money there is a 100% chance I will have t pay for the lottery ticket, losing that money. By not buying the lottery ticket I give up a small chance of not winning money for a 100% chance of NOT losing money (on buying a losing ticket). Add to that that most lotteries pay out less than they take in (operating expenses, government taxes/etc.) and it's pretty much a lose-lose.
Admin
The sad thing is, for whatever its exact purpose (as long as the number of digits stays the same) this is probably the fastest way to generate what it needs to generate. It's potentially a very slow procedure, so every cpu cycle counts.
Admin
Agreed. The bulk of VB's repuation comes from poor implementations, not the language itself.
CAPTCHA: nobis.
Admin
The lottery is a hidden tax on people who are bad at math.
Admin
What is this "peer review" that you speak of?
Admin
You mean, "... a true evil genius!"
Admin
Do most shops have peer reviews? Sadly I've never worked anywhere that actually did them.
Admin
Looks sort of like a VB bastardization of Duff's Device.
http://en.wikipedia.org/wiki/Duff's_Device
Admin
Unit tests? Source control? Peer review? You are obviously still in college! ;)
Admin
Oops. So how about this? (Depending on what are the values of booleans.) :)
Admin
(1) Find one or more peers (2) ??? (3) Review!
Admin
And what happened next .... !?
Punchline people, did it work? Did it fail ?
Admin
Conjugate worse:
Admin
Admin
When a guy is able (or left) to code this way for few years... finally he has the boss in his pocket, let's ask for pay rise!!
P.s: It looks like an hiigarian mothership for real.
Admin
Perhaps, but it's about the only tax that has even the most remote chance of one day giving me a return...
Admin
Admin
Admin
Is thissimilar to how Java implements 'Contains'?
Admin
It's much more clear if you use recursion:
(In broken VB)
Or not.
Admin
Generate all possible drawings of numbers from jars with m(i) balls (in jar number i), where no two numbers are the same?
Admin
Have ever been in that thing called "real live"?
Regards
Admin
College?
Admin
Yeah, a friend of mine calls the lottery (well, gambling in general) "paying the IQ tax."