- 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
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).
Admin
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
Admin
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.
Admin
That guy must be having a laugh, surely.
Admin
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.
Admin
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.
Admin
If this is the best we can get for a CodeSOD, go back to just doing the stories.
Yes, I hear it too.Admin
Oh, grow up. By the time someone gets to college, they're old enough to be responsible for their own 'class clownliness.'
Admin
School assignments shouldn't be allowed on The Daily WTF. Students cannot be held to the same standards as professionals.
Admin
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.
Admin
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.
Admin
It is if you are transitioning from FORTRAN on a MAC.
Admin
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.
Admin
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)
Admin
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.
Admin
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.
Admin
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... 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 :)
Admin
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!!
Admin
Now this is cute throw(up);
very cute
Admin
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.
Admin
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...
Admin
No way guys! This is what he really meant:
if (male == female){ jamieLeeCurtis = true; }
Admin
obviously this course is limited to students who want to be consultants when they get a job
Admin
Admin
"John Connor is the leader of the worldwide resistance and last hope for mankind."
Admin
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!
Admin
Dock as many Points as possible? Insanity.
Admin
At least the student understood that comments are apologies.
Admin
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.
Admin
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!!!)
Admin
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. ;)
Admin
Hey, the world needs ditch diggers too... "Judge Elihu Smails"
Admin
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."
Admin
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.
Admin
Ummm... actually, it's "Just Another Vague Acronym"
Admin
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.
Admin
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.
Admin
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.
Admin
Admin
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...
Admin
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.)
Admin
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.
Admin
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.
Admin
That or copy/paste.
Admin
My favorite is
if (male == female)
Admin
When I began learning programming (in BASIC), I didn't now about arrays. My code must have looked something like this:
and so on ...
Addendum (2007-02-02 16:43): Sorry, it should be
etc. I haven't used BASIC for a while.Admin
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!
Admin
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.
Admin
HAHAH! You said "Terminate" in an article about John Connor.
HAHAHAH!!!
Admin
Not recursive enough. Try "JAVA: Another Vague Acronym".