• (cs)

    not surprised I spent a couple hours sitting next to some guy who insisted that using loops in a Sudoku-like game he was writing would have taken too long.

    He was a bit bothered by the length of the code, though, and wanted suggestions on how to shorten it (whilst resisting any suggestions of using a loop, or an array for that matter).

  • Joe (unregistered) in reply to fanguad

    Maybe it's because of the teacher that the code looks so bad... maybe the class clown was treated like one in the first place, instead of giving the tools and the knowledge to get out of the class clownlyness... maybe

  • Steve (unregistered)

    This item reminds me indirectly of an assignment I had in the very first programming class I took in college way back in 1966. Yes, they had computers back then. Steam powered and lowly freshman undergraduates such as myself were often pressganged into stoking the boilers but that's a story for another time.

    This course used a "textbook computer" -- that is, the computer we were learning didn't even exist. It was an extremely simpilfied von Neumann architecture called "TYDAC" (back when everything ended in -AC), which stood for "TYpical Digital Automatic Computer" or something quite similar.

    There was, however, a simulator, which ran on an IBM 1620 (again, a story for another day).

    In any event, one of the earliest assignments was to learn how to use shift operations and for some reason or another I was having trouble with making them work for some no doubt very boneheaded beginner's reason.

    Bear in mind that in those days, the systems were mostly punchcard based, which meant waiting in line to use a keypunch, then submitting the deck to the operator, who had to load the simulator, run your program, get the punched card output, take it to an offline printer, print the results, wrap it all with a rubber band, and toss it in an output tray. This means a simple error could day a whole day to correct. For lowly freshmen who were taking an introductiory course, this could be living hell.

    At some point, because the assignment was due, I simply decided to bogus in the correct answer as something of a joke and turn it in, assuming that the grader would see that I'd not made the problem work and I'd be graded accordingly.

    The grader, being overworked and underpaid, never noticed that I'd basically cheated and gave me full credit for the problem.

    I was so embarrassed by this, I went to the professor and told him that I'd bogused the answer.

    Since I was at least honest, he gave me half credit, which was more than I deserved.

  • James (unregistered)

    That guy must be having a laugh, surely.

  • Martin (unregistered)

    Ok, this is bad, bad code. Really bad code. But it's not in production, it's not meant for production, and it has not been produced in exchange for money or anything else under the expectation that it would hold any qualitites what so ever. Yes, this guy is going to flunk his Java course, and the comment shows that he probably knows that. My guess is that he's spend way too much time trying to make this work to just not turn it in, and the comment is made in the realization that he's not respecting his TA's time. All these comments about that he's going to be a paid-by-the-line contractor or a government website programmer are totally out of line. Anybody else here ever took a college course and found out you're not good at it? Maybe even turned in a bad paper, knowing it? Uh uh.

  • Frandsen (unregistered)

    I think we may assume that main() is just as long, because it takes a lot of lines to call into this function a fixed number of times.

  • f@ (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.
    noname:
    Are you so desperate for WTFs that you need to pick on poor students now. I thought the official policy at TDWTF was not to make fun of people trying to learn.
    Agreed. WTFs are much more valuable when they're from industry-types who at least claim to know what they're doing. Sorry if it sounds harsh, but if you're gonna mock the students, at least scan in your own Geography/French/Home Economics book too so we can mock your inability to comprehend Europe/the past-participle of 'avoir'/how to make a pie.

    If this is the best we can get for a CodeSOD, go back to just doing the stories.

    CAPTCHA:
    alarm
    Yes, I hear it too.
  • (cs) in reply to Joe
    Joe:
    Maybe it's because of the teacher that the code looks so bad... maybe the class clown was treated like one in the first place, instead of giving the tools and the knowledge to get out of the class clownlyness... maybe

    Oh, grow up. By the time someone gets to college, they're old enough to be responsible for their own 'class clownliness.'

  • Taggy (unregistered)

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

  • Sean (unregistered) in reply to Martin
    Martin:
    Ok, this is bad, bad code. Really bad code. But it's not in production, it's not meant for production, and it has not been produced in exchange for money or anything else under the expectation that it would hold any qualitites what so ever. Yes, this guy is going to flunk his Java course, and the comment shows that he probably knows that. My guess is that he's spend way too much time trying to make this work to just not turn it in, and the comment is made in the realization that he's not respecting his TA's time. All these comments about that he's going to be a paid-by-the-line contractor or a government website programmer are totally out of line. Anybody else here ever took a college course and found out you're not good at it? Maybe even turned in a bad paper, knowing it? Uh uh.

    Very true. Given that this is an intro course, this was probably written within a few months of the student's first line of code ever. Any of you ever gone back and looked at the first programs you ever wrote? I did that recently and had a good laugh. Granted it was in QBasic and I had learned out of books for Basic-A so all my programs had line numbers, goto, gosub, and the works.

  • (cs) in reply to Martin
    Martin:
    Ok, this is bad, bad code. Really bad code. But it's not in production, it's not meant for production, and it has not been produced in exchange for money or anything else under the expectation that it would hold any qualitites what so ever. Yes, this guy is going to flunk his Java course, and the comment shows that he probably knows that. My guess is that he's spend way too much time trying to make this work to just not turn it in, and the comment is made in the realization that he's not respecting his TA's time. All these comments about that he's going to be a paid-by-the-line contractor or a government website programmer are totally out of line. Anybody else here ever took a college course and found out you're not good at it? Maybe even turned in a bad paper, knowing it? Uh uh.

    I think this kid has potential.

    We've all made mistakes. We've all written bad code. You might have been lucky enough to write it all in college / university, or for home projects.

    It's wrong, but he KNOWS it's wrong. That means he's got a good chance of getting it right later. Knowing you're wrong or out of your depth and admitting it is crucial to learning.

    It reminds me of a signals class I took years ago. We had to graph a signal after a LaPlace transform. I got it wrong, really wrong. At the bottom, I wrote, "This is wrong, and I know it's wrong, because it's supposed to look like this: [sketch]". I got most of the marks.

    He might not fail his Java class. I've taken classes where I've failed assignments and midterms yet still managed to squeeze a half-decent mark out by the end of the semester.

  • Mr Ascii (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.

    It is if you are transitioning from FORTRAN on a MAC.

  • Names for for suckers (unregistered)

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

    Captcha - xevious - Eh, I hope the game's code didn't look that bad.

  • (cs) in reply to Duston
    Duston:
    Should be if((male == female) || FILE_NOT_FOUND)

    lol more like if((male == femail) || GENTITALS_NOT_FOUND)

    it's sad but when doing a program that requires a M/F one must use M/F/B/O

    it's possible to be both or other (ok most don't put both but it adds humor)

  • (cs)

    He can't grasp the concept of picturing the 20x20 grid and solving it with loops. He figures brute force is the only way he understands it and the only way he can put something down on paper. Instead of spending some time to learn it, he just puts this crap on paper and sends it off to the grader hoping for partial credit.

  • (cs) 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.

    I'm sure you're 100% right, he's simply putting a value in and evaluating it, then using another evaluate, and did that the whole way down. The teach says that he didn't learn looping, which if he hopes to write anything of worth he's probably going to need.

    oh well, when I went to college, there was a guy studying to be a Programming/Database Administration degree.

    yeah he couldn't understand the concept of what a database did, nor did he he even have the brainpower to consider 1st, 2nd, or 3rd normal form, let alone going to what some term 4th normal form. The teacher had one heck of a time discouraging him from wasting more money on a degree that he wasn't going to get. Sad part, I was in class with him in his beginning of his second year. His teachers felt bad for him and passed him after he begged them to.

    Thank God some teachers stand up and refuse to pass someone in college who doesn't get it.

    • Jon
  • SomeCoder (unregistered) in reply to Names for for suckers

    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 :)

  • (cs)

    That can't be code someone actually wrote!...how do you not know how to loop...especially if you chose to take a CS class!!

  • (cs) in reply to mkb
    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

  • Anonymous (unregistered)

    This is exactly the reason why universities need to start teaching problem solving, logic, algorithms, and design patterns before EVER allowing the students to right a single line of code.

    A student's first year (at least) should be spend on programming theory. Then let them code. We don't let people take a driver's license road test before a written test (in the US, not sure how other countries handle it), do we?

    If this was the student's first dabble in programming, I partially blame the school for these bad pieces of code. He/she should have been given thorough courses consisting of programming fundamentals first.

  • Mr. Nice Guy (unregistered) in reply to dustin
    dustin:
    Duston:
    Should be if((male == female) || FILE_NOT_FOUND)

    lies

    should be

    if((male == female) || SEX_NOT_FOUND)

    No, no, no...

    if ( (male == female) || longjmp( time_space_warp ) )

    time_space_warp: Right Hand, Meet Mr. Winky.

    captcha: ninjas - my kung-fu is strong...

  • dolo54 (unregistered)

    No way guys! This is what he really meant:

    if (male == female){ jamieLeeCurtis = true; }

  • PS (unregistered)

    obviously this course is limited to students who want to be consultants when they get a job

  • (cs) in reply to Benanov
    Benanov:
    My money's on that it was auto-generated by a tool.
    Oh it was generated by a tool all right.
  • (cs) in reply to IQpierce

    "John Connor is the leader of the worldwide resistance and last hope for mankind."

  • muttonchop (unregistered)

    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!

  • shade11 (unregistered)

    Dock as many Points as possible? Insanity.

  • (cs)

    At least the student understood that comments are apologies.

  • Steve (unregistered) in reply to Taggy
    Taggy:
    School assignments shouldn't be allowed on The Daily WTF. Students cannot be held to the same standards as professionals.

    I agree with this, with one caveat: the student should have failed the assignment in question. If the student receives a passing mark, then the real WTFs are the teacher/grader/educational system, and those WTFs should be loudly trumpeted across the land.

  • Frank W. Zammetti (unregistered)

    No, no, NO, you are all wrong, this is freaking awesome code! Each block of logic is nicely decoupled from all others, so should the "developer" (ahem) need to change only one particular cell generation, he can do so without affecting any other. If God herself had written this code, it would scarcely be any better.

    I don't know, it's always so pesky to me when a change in one segment of code replicates all over the place. It's so much Easier & Convenient(tm) to have to change it in 1,000 different places... I mean, the gain you get from such lose couplingof the thousand pieces is phenomenal!

    Besides, we all charge by the hour, right?? I'd say this cat is well on his way to being a top-notch consultant ;)

    CAPTCHAL craaazy... what could be more appropriate?!?

    (I actually left and came back to the entry page... I have Xevious the first time... BEST... GAME... EVER!!!)

  • Okayyy, hes in school ffs. (unregistered)

    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. ;)

  • (cs) in reply to Okayyy, hes in school ffs.

    Hey, the world needs ditch diggers too... "Judge Elihu Smails"

  • (cs) 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.

    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."

  • Anonymous (unregistered)

    I hate to say it, but I saw worse in college working in the university labs. Questions about how to fix "this one bug," taking pity, and then see steaming piles of code like that are why I started working from the dining halls on my laptop.

  • TheQuux (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.

    Ummm... actually, it's "Just Another Vague Acronym"

  • G D (unregistered) in reply to muttonchop
    muttonchop:
    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.

    Careful! Degree =/=> Competence. When I was a TA, I had students tell me to my face that they had no intention of learning anything, but rather intended to beat the teacher into submission with the sheer volume of their nonsense and getting a degree that way.

    And it works. Often.

  • DM (unregistered) in reply to Duston
    Duston:
    Should be if((male == female) || FILE_NOT_FOUND)

    if((male == female) || "Hello RuPaul")

    captcha: craaazy -- yep...for thinking the kid could get away with a stupid apology and for whoever had to read this junk.

  • (cs) 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.

    I don't know about that. Of course, the code from a 4th-year student should normally be much better than that of a first-year student. But it certainly won't be WTF-free. Wait until you've been on the job a few years, then you'll be a better judge of what your code looked like as a new grad.

  • verisimilidude (unregistered) in reply to Martin
    Martin:
    All these comments about that he's going to be a paid-by-the-line contractor or a government website programmer are totally out of line.
    Years later Paula was out of school and making her money as a J2EE programmer creating Brilliant beans.
  • James Muscat (unregistered)

    Feel like I have to comment, as a student currently taking a course in Java/OOP...

    Ick! If anyone on my course wrote a program like that, the rest of us would hunt them down and put them out of their misery...

  • gl (unregistered)

    This code could be made a LOT shorter! This article contains an entire implementation of Game of Life in one line of APL: http://www.ddj.com/dept/architect/196900217

    (And no, I don't comprehend it at all - and I used to use APL. This is the reason that it's known as a write-only language.)

  • (cs)

    Well, at least this guy knows where he messed up, it was just too late to fix it. With any luck, we won't see him at Virtuadyne.

  • SomeCoder (unregistered) in reply to shadowman
    shadowman:
    Wait until you've been on the job a few years, then you'll be a better judge of what your code looked like as a new grad.

    Done.

    I've been working professionally in the industry for almost 8 years now.

    As for me not being finished with school... well that's a long story.

  • Patrick (unregistered) in reply to Benanov
    Benanov:
    Coding midterms forced this?

    No, no. Nothing could have forced this young person to write such a horrible pile of code.

    My money's on that it was auto-generated by a tool. That, at least, will allow the turing machine in my head to terminate, instead of looping forever.

    That or copy/paste.

  • Todd (unregistered)

    My favorite is

    if (male == female)

  • (cs)

    When I began learning programming (in BASIC), I didn't now about arrays. My code must have looked something like this:

    10 INPUT "How many", many
    20 INPUT "Value 1", val1$
    30 IF many = 1 GOTO 400
    40 INPUT "Value 2", val2$
    50 IF many = 2 GOTO 400
    60 INPUT "Value 3", val3$
    70 IF many = 3 GOTO 400
    

    and so on ...

    Addendum (2007-02-02 16:43): Sorry, it should be

    IF many = 1 THEN GOTO 400
    etc. I haven't used BASIC for a while.

  • (cs)

    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!

  • (cs) in reply to SomeCoder
    SomeCoder:
    shadowman:
    Wait until you've been on the job a few years, then you'll be a better judge of what your code looked like as a new grad.

    Done.

    I've been working professionally in the industry for almost 8 years now.

    As for me not being finished with school... well that's a long story.

    OK, so you don't count, slacker ;) (j/k -- I was in about the exact same position myself when I graduated)

    Well then your code is going to be a lot different (better, with waaay less WTF's hopefully) than the typical 4th-year student with no experience. My point was that even 4th-year college students are normally too-easy targets to be worthy of this site.

  • (cs) in reply to Benanov
    Benanov:
    Coding midterms forced this?

    No, no. Nothing could have forced this young person to write such a horrible pile of code.

    My money's on that it was auto-generated by a tool. That, at least, will allow the turing machine in my head to terminate, instead of looping forever.

    HAHAH! You said "Terminate" in an article about John Connor.

    HAHAHAH!!!

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

    It's not an acronym.

    Ummm... actually, it's "Just Another Vague Acronym"

    Not recursive enough. Try "JAVA: Another Vague Acronym".

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

Log In or post as a guest

Replying to comment #115591:

« Return to Article