Comment On It doesn't just happen in Basic ...

Sorry for the late post today ... I've been real swamped and in my final (thank goodness) meeting with a favorite client. In any case, I've see the point made quite often that a lot of the bad programming is done in Basic (VB, VB.Net, etc). You know, implying that us Basic programmers are bad coders ... Well, here's a code snippet from a production system (approved by Mike Strom) that proves a there's at least one more Java programmers not deserving of his/her title ... [expand full text]
« PrevPage 1Next »

re: It doesn't just happen in Basic ...

2004-08-25 16:09 • by David Cumps
What is the (supposed) purpose of this? :)

re: It doesn't just happen in Basic ...

2004-08-25 16:14 • by Randy
Ugh.

I especially love the default part - just in case FOR should increment i beyond its bounds.

re: It doesn't just happen in Basic ...

2004-08-25 16:16 • by brodi
??? Looks like a Basic programmer turned Java to me...

re: It doesn't just happen in Basic ...

2004-08-25 16:18 • by Richard Dudley
Just goes to show Java people have no class.

What is "Waight" (case 11)?

re: It doesn't just happen in Basic ...

2004-08-25 16:39 • by Paul Shields
you're missing the final closing brace on this... is there some hidden snippet of code that would give it more meaning?

RE: It doesn't just happen in Basic ...

2004-08-25 16:40 • by Ralph
Wow! Just wow!

re: It doesn't just happen in Basic ...

2004-08-25 17:02 • by Black
All i can say is.. WTF!.. ofcourse the wtf is purely related to "WHAT THE FUCK WAS HE SMOKING, WHEN HE CODED THIS"

I can only guess that the switch (i) was once user specific, or atleast i would hope it to be, since I'dd only write shit like this if i had lost all controll of my bladder and proceeded to urinate vigorousely everywhere..

things that make you go WTF!

re: It doesn't just happen in Basic ...

2004-08-25 17:09 • by Hassan Voyeau
I agree with Paul, we can only see the start of the loop, and as such I can't say anything besides the spelling of weight (productWaight)...

re: It doesn't just happen in Basic ...

2004-08-25 17:17 • by Frijoles
Since his switch statement is on 'i' from the for loop, wouldn't case 11 always be the last item called, and thus his list always equal to the productWaight? His debug would be full of stuff, too.

That's provided there's nothing below it.

re: It doesn't just happen in Basic ...

2004-08-25 17:21 • by Hassan Voyeau
That would be true if only there was a } at the end of the code we see...

re: It doesn't just happen in Basic ...

2004-08-25 17:21 • by Mike Strom
Paul just a cut and paste error nothing gives this more meaning.

Also a small correction on the approved part. We only do the review someone else digests it and approves it. Our report was delivered with over 500 pages of suggested changes. But this was not one of them as stated this part did pass. And the purpose of this seems clearly to inflate the line count.

re: It doesn't just happen in Basic ...

2004-08-25 17:30 • by Jake Vinson
I like surrounding every line in a try/catch block.

Then I put all of the try/catch blocks in a case statement, where each one is a numbered line in a for loop.

Then I put a default value at the end that will never ever possibly EVER execute.

And then I wait for the day that some entry-level programmer has to maintain my code.

re: It doesn't just happen in Basic ...

2004-08-25 18:11 • by Ron
The interesting thing to me is that all the concepts that are alluded to by the variable names for some reason are handled via a List reference.

re: It doesn't just happen in Basic ...

2004-08-25 18:33 • by Patrick Sullivan
gotta love the productWaight array list, i'm guessing it involves some matrix where depending on the wEight of a product you have to wait a certain amount of time before you can get it...

re: It doesn't just happen in Basic ...

2004-08-25 18:34 • by Patrick Sullivan
hence the productWaight

re: It doesn't just happen in Basic ...

2004-08-25 20:06 • by Don Newman
I have to agree with Paul on this one. This could just be iterating through debugging tests. Without knowing what code is between this and the closing } for the loop there is nothing to bash but a typo on the variable.

It wouldn't be the first time I saw somebody spell a variable wrong that made it into production. Somebody does a typo and checks in their code, another person doesn't correct the other person's code and just follows the typo so they can keep working, the first person can't correct their code without breaking the second person's code.

re: It doesn't just happen in Basic ...

2004-08-25 20:09 • by Don Newman
Oh, and lets not forget to pick on the typo for "catagory". Sometimes code is screwed and sometimes it is just nit picking on something out of context.

re: It doesn't just happen in Basic ...

2004-08-25 21:00 • by Thomas Goyne
Don> "Paul just a cut and paste error nothing gives this more meaning."

I assume that means that there is nothing between the end of the snippet and the end of the loop.

re: It doesn't just happen in Basic ...

2004-08-25 21:42 • by fogelman
This is such a common post on this board - we should make it into a pattern!
Then we can both write a book about this pattern and when it is good to use patterns like this.

re: It doesn't just happen in Basic ...

2004-08-25 21:59 • by mork
I think the developer would've been better off removing the 'break's and just putting an i=12; in the default block.

re: It doesn't just happen in Basic ...

2004-08-25 22:38 • by That Guy
Mike, as a QA guy you're not the bitch who has the spec, are you?

Better Code is here

2004-08-26 02:16 • by setthesun
i=1, while (i){
logger.debug("WTF, is this Payment logger ?")
}

re: It doesn't just happen in Basic ...

2004-08-26 02:21 • by AIM48
Even without knowing what comes after the } the code is still wrong. Why in the world do you need a loop when you know the sequence of operations you are going to be performing.

Something like this would be much more sane

SetListToSomething(paymentMethod,"Payment Method Set");
etc....

re: It doesn't just happen in Basic ...

2004-08-26 06:36 • by bh
What if there is some code missing at the end of this function. It might even make some sense.
e.g.
case 1...default

do_something_for_current_iteration()

Listed code is probaby better than:
case 1 code
do_something_for_current_iteration()
case 2 code
do_something_for_current_iteration()

etc.

re: It doesn't just happen in Basic ...

2004-08-26 08:30 • by pd
The code missing is probably just adding to a counter or something that would make no sense.

re: It doesn't just happen in Basic ...

2004-08-26 09:38 • by Mike Strom
Again there is no missing code other than the } in question.
Also I should get the Spec but sense I do security code reviews no one but no one cares what I say or request. I produce a document the document is then summarily ignored and I report the same problem the next time I review the code.
By the way due to tight deadlines these reviews are normally done on code already in production or so close to being released that the review can’t be implemented.

re: It doesn't just happen in Basic ...

2004-08-26 13:03 • by Ben Hutchings
That Guy: How could QA do its job *without* having the spec (or whatever documentation expresses what the program is supposed to do)?

re: It doesn't just happen in Basic ...

2004-08-26 13:41 • by Mike Strom
I ask the same question all the time.

Re: It doesn't just happen in Basic ...

2007-03-13 04:03 • by ruijoel
I think it makes sense. He's unit testing the Java 'for' loop. You know, just in case it breaks and nobody notices.

Re: It doesn't just happen in Basic ...

2011-01-11 10:10 • by cindy (unregistered)

Re: It doesn't just happen in Basic ...

2011-03-02 08:54 • by cindy (unregistered)

Re: It doesn't just happen in Basic ...

2012-03-13 09:23 • by Kryptus (unregistered)
Anyway, a .Net programmer would never have done such a stupid thing.
« PrevPage 1Next »

Add Comment