• (cs) in reply to Baggy McBagster
    Baggy McBagster:
    Unless 'n' is a class member var, which I refuse to believe can be the case, this won't compile because there's no 'n' defined for if "(spotvalue[n] == 0)"

    I suspect therefore that anonymization may be distorting this wtf a bit?

    Unless n IS a member variable, with the meaning 'square we are currently looking at'... no, no I can't believe that.

    Believe it. I was a pseudo-TA (I got to help students and such but didn't have to grade) for our second-semester C++ class. Putting iterators and such into the class as members was a VERY common style blunder. A few people had actual bugs caused by this, like they'd have a loop that modifies 'iter' or whatever that in the body calls a function that also has a loop modifying iter. Oops.

    I gave a couple lectures at the very end of class with material I created for the purpose, mostly to talk about style things and some mode advanced stuff the class didn't have time to cover, and I spent some time on this sort of style mistake and why it's bad.

  • (cs) in reply to fanguad

    One more point: I had people who towards the end of this SECOND programming class (meaning they presumably passed the first) didn't know how to construct loops.

    fanguad:
    Finally, I think there should be a rule that you can't use student code on TDWTF. OF COURSE a lot of that code is bad. That's like making fun of my lack of ability to run a marathon or something.

    You can't run a marathon? Points Bwahahahahaha!

    Oh wait... I get winded after a couple hundred yards. Oops...

    (Sorry)

  • Mizchief (unregistered)

    I think we need to upgrade this from a WTF to a OMFG!

  • Mayday (unregistered) in reply to Anonymous

    My university had these things called 'prerequisites' for the higher computer science elective courses.

    Logic design, descrete math, a basic programming class (at the time in Pascal - later in C), structured computer design, and an algorithms and datastructures class were the prerequisites for many of the higher level courses.

    At the same token, I don't think filling several semesters with classroom theory would be good either. Sometimes having hands-on (albeit clearly directed/guided) interactive sessions with the computer helps solidify concepts.

    This is exactly how my first computer science professor worked -- the first half of the class was working out the details of a given function/concept on the board. The second half of class he would give us specifications to build a little noddy app to illustrate the concept -- even if we didn't finish in class - we at least got oriented in the right direction by the teacher - so we could continue on our own in the lab until the next class - when the project was due.

    I know this helped many students 'get it' - and I believe they would be better programmers for it. I had been programming for many years when I went into the university - so for me it was more about polishing the rock.

    Captcha - Alarm - what should happen when your CS teacher is less interested in really teaching the subject at hand than making their lunch date.

  • WTF Batman (unregistered) in reply to Longwang
    Longwang:
    When I began learning programming (in BASIC), I didn't now about arrays. My code must have looked something like this:

    ...

    and so on ...

    Heh -- I remember beginning programming on a CP/M with MBASIC when I was 9 or 10 years old. I didn't know how to use variables as accumulators ( $a = $a + 1 ), and I was trying to write a game using a combination of flags and if statements to set the player's score. Needless to say, I wasn't getting very far. (IOW in pseudocode: IF ($q1correct=1 and $q2correct=1 then $score = 2), etc...)

    The Real WTF was that my dad, a professional mainframe programmer, tried to tell me that, while he didn't know BASIC, he knew accumulators must be possible somehow, I got angry and told him that he was wrong and didn't know what he was talking about. Damn kids. I still think about that sometimes and cringe.

  • (cs) in reply to Anonymous
    Anonymous:
    1% because they don't try to do too many things on one line, rendering it unreadable.

    I am glad you said that. I have been looking at some code lately that I thought was just over my head. Glad to know I am not the only one who finds 10 operations on one line to be a bit too much. Especially without comments.

  • Cornered (unregistered) in reply to Jackal von ÖRF
    Jackal von ÖRF:
    At least the student understood that comments are apologies.

    No they're not.

  • Corporate Cog (unregistered) in reply to fanguad
    fanguad:
    Finally, I think there should be a rule that you can't use student code on TDWTF. OF COURSE a lot of that code is bad. That's like making fun of my lack of ability to run a marathon or something.

    I thought there was such a rule.

  • GeneS (unregistered)

    This guy is going to make a great contractor (see Contractor's Note WTF)

  • anon (unregistered) in reply to Anonymous

    o ya, this completely readable.

  • Mark (unregistered)

    OMG! I just got an e-mail from this guy! (or his brother):

    http://www.e-hand.com/dup/dupeval.js

    I write a bunch of online js articles and people always e-mail me asking for help...

    captcha: WAFFLES!

  • Mark (unregistered)

    OMG! I just got an e-mail from this guy! (or his brother):

    http://www.e-hand.com/dup/dupeval.js

    I write a bunch of online js articles and people always e-mail me asking for help...

    captcha: WAFFLES!

  • 2cynical (unregistered)

    OK My son is a freshman comp sci major who has just finished his intro to Java course at a major private engineering institute.

    Can we at least get the name of the school so I can find out if my money is going to waste?

  • Anon (unregistered) in reply to 2cynical
    2cynical:
    OK My son is a freshman comp sci major who has just finished his intro to Java course at a major private engineering institute.

    Can we at least get the name of the school so I can find out if my money is going to waste?

    WTF?

    Captcha: eatmysnorts

  • Anon (unregistered) in reply to GeneS
    GeneS:
    This guy is going to make a great contractor (see Contractor's Note WTF)

    No, I don't think he will.

    Captcha: crudonwheels

  • Anon (unregistered) in reply to anon
    anon:
    o ya, this _completely_ readable.

    WTF? Errrrr.... no it's not.

    Captcha: sweetnessandlight

  • Anon (unregistered) in reply to Mark
    Mark:
    OMG! I just got an e-mail from this guy! (or his brother):

    http://www.e-hand.com/dup/dupeval.js

    I write a bunch of online js articles and people always e-mail me asking for help...

    captcha: WAFFLES!

    Mark:
    OMG! I just got an e-mail from this guy! (or his brother):

    http://www.e-hand.com/dup/dupeval.js

    I write a bunch of online js articles and people always e-mail me asking for help...

    captcha: WAFFLES!

    WTF? Double post??? Did you double click the submit button or something???

    I see more WTFs in the comments than in the actual articles on the site.

    Captcha: bugfuxingphase

  • Anon (unregistered) in reply to daves561
    daves561:
    The real WTF is that the author of this site keeps writing "Java" in ALL CAPS.

    It's not an acronym.

    Yep, that's the real WTF alright.... hahahahahahahahahahahahahahahahahahahhhahhahahahahhaa.

    Captcha: runny

  • Dustin_00 (unregistered)

    "School assignments shouldn't be allowed on The Daily WTF. Students cannot be held to the same standards as professionals."

    Ah, but what about holding them to the standards of their peers that leaned for loops?

    If a couple of students perform far below par of the rest of the class, would public humiliation prove motivational?

  • whateveritshowmuch yourparentspay (unregistered)

    There are some colleges/universities, though, that won't allow a student to flunk. The one I'm thinking of contains the letters C and M and U. The instructors get rated by the students, for crying out loud, to earn their keep. How WTF is THAT compared to just doing what this kid did? Granted, he didn't learn anything, but maybe this was a non-related class to his major. I've seen it a hundred times and more, even the exact copying of other class mates work. But...flunk them, and you might not be teaching the next year. It's freaking stupid.

  • John Connor (unregistered) in reply to Grant

    I actually obtained permission to use the code from the professor and student. So it's fine.

  • (cs) in reply to whateveritshowmuch yourparentspay
    whateveritshowmuch yourparentspay:
    The instructors get rated by the students, for crying out loud, to earn their keep.

    Isn't that pretty common? Perhaps there's more emphasis on the evaluations there, but at both my undergrad and graduate institutions we do instructor reviews.

  • noname (unregistered) in reply to Okayyy, hes in school ffs.
    Okayyy:
    Ive seen far worse. By people not knowing that its bad.

    This guy didnt know loops, so what? Think back to when you first encountered loops. You probably stopped for at least a second and wondered what was up there. Or you had that moment later during your programming life. Perhaps when you saw your first recursive algorithm. Especially one that only almost worked as it should.

    I have a buddy thats trying his best to put together a program atm, his private project. He's not programmer material, but he's sure putting in the effort, so Im helping him, giving him pointers and good advice. His code is awful, but who knows, he might some day actually get the hang of it. HAve that small appiphany most of us had one time or the other. I know I did. ;)

    While I agree with the sentiment to a point, I'd just like to point out that a loop is the 2nd thing I (and I suspect many others) learned.

    1st program: 100 PRINT "Hello"

    2nd program: 100 PRINT "My Sister Stinks" 200 GOTO 100

  • jack (unregistered)

    This wasn't such a bad article, but I like it that this column usually features professional screwups, as opposed to the infinite number of ways someone who obviously doesn't know what they are doing yet can fail. I hate using this phrase, but it "doesn't seem like a WTF" because the system is working - this student will fail, as he should. He'll try again next semester and learn from mistakes or choose some other profession. It's no mystery why this person doesn't know what he's doing. You just don't know until you learn, and this person never learned. We've had articles from schools before, but usually it focused on a bad teacher or a system used at a school.

  • (cs) in reply to Grant
    Grant:
    Don't you guys have a policy on posting student code?
    Most of the posts here are about students--in the sense that they still have some learning to do--like testing their db access speed with a db with more than ten entries in it.
  • Sauron (unregistered)

    Okay, being a frosh CS major at a major engineering university (major by quality and rankings, not by size!), I desperately want to give this guy the benefit of the doubt. By the time I got to the end of the required basic CS course, I had accrued a high enough score that I could have completely bombed the last assignment and still pass very highly. If the final assignment hadn't been something I had never done before, I totally would have made the most atrocious code I could muster, though I'd make sure it would at least fully solve the problem!

  • hallo.amt (unregistered)

    he learned his lesson of coding for lines

  • (cs)

    I think any grader from any into to scheme class gets 5 or 6 submissions that put this to shame for every assignment. :)

    Scheme is the perfect intro to CS language. There is little chance of an idiot lucking their way through recursion or closures. And it makes it perfectly clear that if you want to spend all your time in an IDE writing practical code, you should transfer to the school of business.

  • Joshua (unregistered)

    It wasn't last time, either. . . .

    And using words for CAPTCHA is just silly; it only increases the chance that an automated system could fake the test, because they can use dictionaries to check validity. With random text, they can't.

  • operagost (unregistered) in reply to J Random Hacker

    It's too bad he wasn't Dr. Dyson, then Skynet would have been too exhausted to become self-aware.

  • (cs)

    there's two WTF. The first is the amount of comments that think this code is fine for an undergraduate student.

    When I started my TAFE diploma (don't want to have to use hex), I would see other people fail (didn't actually fail the subject, just had to resubmit) if they handed there assignment even though it would be 10 times better than this. In fact our teacher would make that stuff variable (e.g. size of the board), So it was impossible to do that stuff.

    Second WTF, is the actual code. some of the thing wrong are

    • no loops
    • uses global variables(probably the wrong term)
    • commenting
    • no helper functions
  • (cs) in reply to Jackal von ÖRF

    True enough, but he opted for documenting his comments (assuming he knew the javadoc API).

    Or maybe he didn't know ;-)

  • (cs) in reply to ssprencel
    ssprencel:
    I remember writing a Tic-Tac-Toe game in intro to VB. For the computer's <flinch>A.I.</flinch>, I used a giant Select Case statement. Yep, after 38 pages of copy-cut-paste code, I finaly said, "There has to be a better way."
    I still have my first game that I programmed on my own in 8th grade using Turbo Pascal (the compiler choice would be okay if I were older than 21). I have a similar situation to yours, however:
    1. I didn't know how to use multi-dimensional arrays, so the board was a 9 length array.

    2. To figure out whether someone had won, I used an "if" statement for every possible win condition, "goto"-ing to the end of the function if I found a match...

    3. The first part of the computer's AI is if statements describing every possible two-out-of-three in a line that the player could have. The second half was every possible two-out-of-three in a line the computer could have. The third was a random number. I again would use a goto statement to skip down to the end of the function once I had found the match.

    4. I didn't understand scope, so I thought I had to name all my variables differently, even in functions. This led to names such as: board, bord, bored, huhwin, didplayerwin, did compwin, one, two, three, uno, dos, tres. (All variations of "board" were based on the fact that I passed in the global board array to every function, which then proceeded to access it locally using one of the name bastardizations...shudder)

    Surprisingly, I saw it through 'til the end, and the game can still beat me if I'm not paying attention. I had rounded it out with a small text-animation and PC speaker sound effects in the beginning =)

  • Oliver (unregistered) in reply to akatherder
    akatherder:
    Zonkers:
    Wow, no way this is the least amount of thinking and time. The student must have spent way more time on this than was expected.

    Copy and paste! Doing it statically (without loops) allows you to evaluate each case manually. Since the points on the corners, top edge, bottom edge, left edge, right edge, and middle are all different he could just look at where the point is and act on it. He doesn't have the programmers mindset to dynamically figure out where the point is and what to do with it.

    Just my best guess.

    Agreed. It is actually a good strategy to use when you are faced with a problem you can't fully grasp in you head, but you can slowly figure out how to handle each special case. So you can at least get it to work first.

    Of course, after all the cases are handled, you should clean up the mess by slowing merging the different cases together. Ideally, after figuring out all the special cases, you should come up with the logic to properly dealt with the boundary as you hit upon them in the loop.

    Apparently, the programmer did not have time to even finish the first step.

  • ano (unregistered) in reply to steven22
    steven22:
    reminds me of my first programming attempts in 7th grade using basic
    Same here... I wrote stuff like this when I was 11 years old.
  • Ted (unregistered)

    Perhaps he is looking forward to one of those "paid by the line" jobs, after he graduates... :)

  • Mark (unregistered)

    Instead of bashing this guy’s code, we should give him a call to teach him the “efficient” way of coding Java. Please note I emphasize the word “efficient”… The fact is that we all been there, perhaps not turning in a piece of Java code to an instructor or client but maybe writing an assay or trying to translate something in Spanish. All I know is that I don’t know everything.

  • Banker (unregistered) in reply to muttonchop
    muttonchop:
    OK the apology was funny, but like so many people have said above this is a student assignment in an Intro to Programming course. In my first University programming course, a friend of mine wrote a simple "coin jar" app (you could add or remove pennies, nickels, dimes, and quarters and it would tell you how much money remained) that worked like this:

    balance: $0 add 2 quarters, 1 nickel, 8 pennies remove 1 nickel, 5 pennies balance: $1354578490.98

    That's right, it only performed simple arithmetic and yet you could put in a handful of change and suddenly you'd have several billion dollars.

    Guess what? He passed the course, and graduated with a degree in engineering. People do some crazy things when they're first learning to program, but it doesn't mean they're stupid.

    captcha: Pirates. Yarr! This story should be keelhauled!

    Hey, I need that source code! I want to run my bank transactions through there... ;)

    captcha: onomatopoeia ... yes... sure. ...

  • (cs) in reply to sir_flexalot
    sir_flexalot:
    I hear the 'no student code' thing. However, he threw something together at the last minute and had a lame excuse for it. That is something everyone should un-learn immediately from reading articles on this site, be it for professional code or a student assignment. If he wanted to learn how to do it, why not go to office hours, ask someone, etc... anything but this!

    True. Because, not all school code stays in school. I've seen C code born in college that would make Dennis Ritchie cringe. And that code then gets used on "practical" projects, so it ends up in some random business.

    And lots of CS students where I graduated think that "VB + Access DB" is a winning combination.

    And don't care about validation, OR security (plaintext passwords on the DB). Hell, I've seen them put password "validation" in Javascript... with the password inside the JavaScript itself!!!

    Students with ugly habits will keep them if not corrected during college.

    Addendum (2007-02-03 14:49): OH, and by the way ... now I know why John Connor was able to beat SkyNet in the future ... he uploaded this code with a recursive call!!!

    hehe....

  • bert (unregistered)

    And the next assignment...

    The customer called and said that they now have a new video screen that supports 40x40 resolution.

    Update your program from 20x20 to 40x40 and turn it in TOMORROW by 8:00 AM!

    Good Luck, Professor Zadist

    Background noise: 199 students whispering "piece of cake." 1 student in the back sliding out of his seat and sobbing in a heap on the floor. "No, no, no, ... It's not fair. I don't even have time to type it in..."

  • woohoo (unregistered)

    Ah, that reminds me of a GW-Basic program that I once "refactored". This must have been around 1984 or '85, I was around 16, still in school and on my first summer job ever for a plant engineering company - but I already had at least a firm grasp of Assembler, Basic and Pascal thanks to my trusty C64 ;o)

    I was told that there were "usability problems" with a self-developed application that was used for some extensive calculations, which required the manual input of approx. 250 parameters and couldn't I have a quick look into it after my usual duties. I looked at the code and saw roughly the following (forgive any syntax glitches or typos, I haven't touched GW-Basic since then ;o)

    10 INPUT "Enter foo: ",A1$ 20 INPUT "Enter bar: ",A2$ ... etc. for all the other ~250 parameter values 5000 INPUT "Was everything ok?",Q$ 5005 IF Q$="Y" THEN GOTO 10000 5010 INPUT "Enter foo: ",A1$ 5020 INPUT "Enter bar: ",A2$ ... again (!), copied from above, for all the other ~250 parameter values 10000 REM Start of calculation ...

    Yes, you are seeing this right: Either enter the 250 values correct the first time or - as the last ressort - all of them again on the second attempt (without even getting a display of the previously entered values or any possibility to just confirm those which were correct already...)

    What I did was writing an input procedure that was able to display a previously entered value or a default value taken from a file, which could then be edited by simple means (cursor left/right, insert, delete) or just accepted immediately (all of which was quite a hassle in GW-Basic as far as I remember ;o), then putting the whole input shebang into a loop and the confirming question at the end of said loop. Took me around 2 days I think (I hadn't seen GW-Basic before, just C64- and "Simon's Basic") and they were absolutely thrilled with the brand-new convenience and deemed me the master programmer of all times ggg

    The summer job description had originally only included "auxiliary work" like carrying around paperwork and putting stuff into the copy machine, but from that day on I was reassigned to "refactor" and program applications and continued doing so for the following summers (progressing to Turbo Basic later on).

    And that was basically the start of my career in the software development industry :o)

    captcha: dreadlocks (the only thing that I fear are DEADlocks, though ;o))

  • woohoo (unregistered) in reply to daves561
    daves561:
    The real WTF is that the author of this site keeps writing "Java" in ALL CAPS.

    It's not an acronym.

    Don't be so harsh - granted, strictly speaking this is better reserved for acronyms, but many people are doing this with other technical terms like PASCAL or SMALLTALK as well, just to distinguish them from the rest of the text.

  • woohoo (unregistered) in reply to SomeCoder
    SomeCoder:
    I would tend to agree with the comments about not showing student code. If this guy is truely a first year student, we shouldn't mock.

    However, if he's a 4th year student or something, then I think mocking is allowed. I'm about to embark on a project for one of my senior level classes in college. One of our group members is bound to have a variety of WTFs in his code and I think that once you're a semester away from graduating, you shouldn't be writing WTFs. I'm sure that I'll be submitting some of his code when I get to see it and after I've spent all night rewriting it.

    Names for for suckers:
    I don't know, this almost looks like a combination of drunk and hungover programming.

    I don't know... one time I had to write a complicated C (yes, straight C) application for Unix, that did some threading stuff for a class. I had put it off all week and finally ended up working on it all day Sunday. Too bad that all night Saturday I had been drinking...

    Surprisingly, I got it done pretty quickly without too many problems. I guess I'm just a master programmer when hung-over/drunk. Now when sober... well that's debatable :)

    I once forgot about an assignment for a lecture about LISP and was extremely hungover (I mean "extremely" as in "mentally incapacitated for anything more than standing upright") on the day it was due. I nearly couldn't see the characters on the screen (it was a green-on-black VAX terminal, BTW ;o) We hadn't heard about built-in functions so far, only about basic operations (car, cdr, atom ...) The assignment read: "Reverse the following list: 1,2,3,4,5,6" Of course the intent was to force the students to think about a recursive algorithm for that, something that my brain-on-the-brink-of-explosion was simply not capable of doing. So I just took a wild guess and managed to hack into the editor: (reverse '(1,2,3,4,5,6)) Luckily, "reverse" is in fact a built-in function in LISP :o)

    I got the full credit, because I solved the problem ;o)

    captcha: pointer - nah, not in LISP...

  • woohoo (unregistered) in reply to KingNetSurfer
    KingNetSurfer:
    mkb:
    ssprencel:

    if (male == female) { return( NO_THANKS_IM_NOT_THAT_HARD_UP_FOR_IT ); }

    No, I think it's time to : NoThanksException up = new NoThanksException(); throw(up);

    :D

    Now this is cute throw(up);

    very cute

    even nicer without the (unnecessary) parentheses:

    throw up;

    ;o)

  • (cs) in reply to Grant
    Grant:
    Don't you guys have a policy on posting student code?

    Second that. Students are learning. One of the best ways to learn is by making mistakes. In learning, mistakes by the student are expected - they have a license to make mistakes - that is why they are students. Sure, mistakes need to be corrected (and graded - in this case, severely so) - but not being exposed/ridiculed in public.

    Alex, this should not have been posted.

  • (cs) in reply to Michael Buschbeck
    Michael Buschbeck:
    daves561:
    The real WTF is that the author of this site keeps writing "Java" in ALL CAPS.

    It's not an acronym.

    Indeed. I'm still trying to figure out why some people do that with random nouns.

    Somebody sent me a "LOG" file just yesterday, asked about a certain "CONFIG" interface today, and somebody else referred me to a "TCPDUMP" in an email this morning.

    Perhaps it is some kind of emphasis. "This is important and technical and there are a lot of important technical acronyms, so I'll just all-caps this word too."

    Maybe it is done to emphasize the salient points of a message/document/post ...

  • Java (unregistered)

    The problem is that he didnt use the Goto statement because not available in Java. He definitly should have used Qbasic.

  • Matt (unregistered)

    Wow, I think this one was out of line. I hope you're all happy when this poor bastard reads all the scathing comments here and gives up on programming, all because so many of you seem to think that someone who makes a mistake in an intro course in college clearly has no future.

    I'm gonna boycott TDWTF for awhile, I think. As so many pointed out, I thought we were against humiliating students. No funny (or not so funny as it were) story is worth doing that to someone who hasn't had the years of professional experience that you have.

    captcha: smile (sorry, not this time, guys)

  • Jon (unregistered)

    OMG ... OMG ... OMG... OMG ... OMG.. change majors NOWWW PLEASE DON'T JOIN MY INDUSTRY!!!!!!! ... once I wrote code that i wrote an apology for. It was terrible by my standards, but no worse then the standards I was asked to used to implement it. When the VP came down and said "have this done by 12 pm" I got the point of "get this done ASAP ... up until that point i had done everything to "company" standards (biztalk is one big WTF) and it wasn't working. Mind you I hadn't been trained in biztalk, but I have grips with anything where someone who is very familiar with a project or technology (my senior developer expert biztalk guy) opts to completely rewrite something instead of debug it. So I started off on my own path coded quickly and got the job to production in 4 days. (the senior developer and I worked on the project at the same time) ... When I got my program to production it was barely maintainable (I later rewrote it entirely again before putting it into "company" standards) and It took the senior developer 4 days to get where I got in 6 hours. the reason my dev cycle took 4 days was because of a bunch of business wtfs... Later I implemented it in "company standards" and looked back at what I had done the first time I had to effectively change 1 setting and my old original project worked as it was suppose too.

  • Jon (unregistered) in reply to Jon

    the senior and I worked on the same project, but completely independently from one another. Me in code, he in biztalk. And when I say old original project I mean my first ever biztalk project.

Leave a comment on “So Bad It Needs An Apology”

Log In or post as a guest

Replying to comment #115843:

« Return to Article