Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Education Programming IT Technology

Programming Assignment Guide For CS Students 761

kennelbound writes "For those students just getting started in a Computer Science degree or a career in software development, this guide has been written to help you understand what NOT to do when coding a project. Those with a little more experience should still read it to get a good chuckle (and hopefully the mistakes stated within will not seem too familiar!)"
This discussion has been archived. No new comments can be posted.

Programming Assignment Guide For CS Students

Comments Filter:
  • rule 1 (Score:2, Funny)

    by Anubis350 ( 772791 ) on Wednesday October 20, 2004 @12:23AM (#10572465)
    rule one: do not post vulnerable servers on slashdot without a mirror
  • by nebaz ( 453974 ) on Wednesday October 20, 2004 @12:27AM (#10572491)
    Use the minimum number of keywords in the language as possible. For example, all loops (for, while, do) can all be handled by a simple if and goto statement.
  • by account_deleted ( 4530225 ) on Wednesday October 20, 2004 @12:27AM (#10572493)
    Comment removed based on user account deletion
  • by Rufus211 ( 221883 ) <rufus-slashdotNO@SPAMhackish.org> on Wednesday October 20, 2004 @12:27AM (#10572495) Homepage
    Get your site linked from slashdot.
  • by esac17 ( 201752 ) on Wednesday October 20, 2004 @12:29AM (#10572507)
    I spent 2 days looking for a one character bug the other day, I hate these!

    if (condition);
    {
    myvar = 1;
    }

    The block was a lot bigger than myvar = 1, and my eyes kept skipping over the ; .. of course when I found it I felt stupid .. and well I should have :) hey wait, maybe I should have posted this Anonymously ...
  • by Anonymous Coward on Wednesday October 20, 2004 @12:29AM (#10572509)
    It's satire dude...
  • by nebaz ( 453974 ) on Wednesday October 20, 2004 @12:33AM (#10572530)
    Oh, and also, always use labeled line numbers in multipes of 10. That way, if you need to insert lines later in the middle, you have some line numbers to use later.
  • by ansleybean ( 618941 ) on Wednesday October 20, 2004 @12:33AM (#10572536) Homepage
    haha, i had a prof that did that. although i have to say that original powerpoint slides aren't any more interesting than plagarized ones.
  • by dtfinch ( 661405 ) * on Wednesday October 20, 2004 @12:37AM (#10572569) Journal
    Declaring local variables will just add unnecessary typing. Just put it all in globals for maximum code reuse.

    And classes, they don't add anything you can't get with functions. All they do is restrict you.

    But why even use functions? All that happens is you try to make one piece of code serve multiple uses when you'll be better off tailoring the code to each instance where it's needed.
  • by roman_mir ( 125474 ) on Wednesday October 20, 2004 @12:39AM (#10572582) Homepage Journal
    And what about that bloke in Operation Swordfish? Would he have cracked the Pentagon password if one of Travoltas hitmen hadnt been pointing a pistol at his head while another Travolta hitwoman was trying to distract him? - I think it should be mandatory for every CS class to have their own hitmen who would point guns at the students' heads while some hitwomen would try to distruct them. Then everyone would be like those hackers in movies, hacking away those 128bit encryption algorythms in just under 60 seconds.

  • by ral315 ( 741081 ) on Wednesday October 20, 2004 @12:45AM (#10572612)
    From 6:00p-12:43a EST, it's taken 2407 hits- 48140% more traffic than it did the previous day.
  • by gcaseye6677 ( 694805 ) on Wednesday October 20, 2004 @12:51AM (#10572651)
    In a pinch, you could just use GOTOs to branch your code farther down on the screen. But don't forget to include the GOTO to bring it back up, or your execution will be off. Ah, fond memories.
  • by ErichTheWebGuy ( 745925 ) on Wednesday October 20, 2004 @01:00AM (#10572717) Homepage
    I heartily disagree. Personally, being buzzed (but not hammered) provides my otherwise erratic brain the opportunity to focus intently.

    My motto: code drunk, debug sober
  • by vranash ( 594439 ) on Wednesday October 20, 2004 @01:02AM (#10572725)
    Yeah, I mean I once had a girl in a programming class say she'd do *ANYTHING* to pass the class, so I had her buy me dinner in exchange for helping her study, then never saw her again!

    Sad part is this is all true.
  • by Simonetta ( 207550 ) on Wednesday October 20, 2004 @01:03AM (#10572734)
    Yes, seriously...
    your code should read like a novel.

    After finishing the program, compiling, and debugging it, get out your microphone and one of those speech-to-text programs. Train it if you haven't done so already by reading the presented text for twenty minutes or so. Do the training twice: once when sober and properly intoxicated. (Myself, I grew up in the 1970's and consider alcoholic beverages déclassé, but everyone has their own favorite intoxicant).
    Get a picture of your favorite dreamboat celebrity and put it next to the screen. Load your source code on the editor and start the speech-to-text converter in the background.
    Take a deep breath and gaze adoringly in eyes of the person in the photo. Pretend that they are hopelessly infatuated with everything that you say and just love to hear you talk about your programming.
    Then start talking. Talk about your code. Start at the beginning. Talk about every line and what it does. How it works. How it fits. How totally cool it is. Just go on and on.
    When you're done, turn off the speech-to-text generator running in the background and save the hopefully rather large text file.
    Go back and cut and paste lines from the source file into the spoken description text file. (Use the speech-to-text engine to make this step go fast.)
    Hopefully you will now have about a half a page or more of rambling, but technically dense and accurate, speech text for every line of source code.
    This is the proper amount of commentary that every line of code needs.
    Put comment markers around your spoken text and lots of white space above and below the actual source lines.
    Your program is still good: it compiles and runs. But it now looks like a novel.

    This is good! The single line coding format that we all use is an obsolete product from the 1950's when a byte of computer RAM memory cost more than a good restaurant dinner. Those days are gone.
    Now you want to be able to read and understand the code quickly. It's far easier to glance and read through pages of rambling dictation describing the code than it is to try to understand 'normal' code with little pissant comments pasted randomly through it.
    You're a professional now. Anything that makes your job easier is good .
    If your CS professor disagrees, give them a copy of your speech-to-text software and a picture of Lindsey Lohan to place next to their screen and have them try it themselves.

  • by nwbvt ( 768631 ) on Wednesday October 20, 2004 @01:06AM (#10572749)
    This has probably been posted on /. before (in fact I probably origionally found it here), but I can't resist posting this site:

    http://mindprod.com/unmain.html/ [mindprod.com]

    My favorite:

    (On naming) # Bedazzling Names : Choose variable names with irrelevant emotional connotation. e.g.:

    marypoppins = ( superman + starship ) / god;

    This confuses the reader because they have difficulty disassociating the emotional connotations of the words from the logic they're trying to think about.
  • Another Tip (Score:5, Funny)

    by suwain_2 ( 260792 ) on Wednesday October 20, 2004 @01:10AM (#10572772) Journal
    Use clear, meaningful, variable names.

    I was playing with obfuscated Perl code, and got about 300 lines out. It was a script to go through my gaim [sf.net] logfiles, and generate stats for how much I talked to each person, how verbose they were, and so forth. It mostly just shelled various shell commands like wc, and my PIDs jumped by about 1,000 at the end (meaning that it was spawning about 1,000 processes from start-to-finish.) It wasn't well-written or anything, but it was kind of cool. And writing obfuscated, hack-job code is kind of fun. It ended up producing an HTML file.

    I finally decided that it'd be cool to have the program read its own source and output it to the HTML file. It was pretty easy, and, as with anything else done just for fun that isn't too challenging, I just assigned stuff to random variable names. $hats and $fog were the most commonly-used.

    I simply opened the source as $hats, and opened $fog for write, and then wrote $fog to $hats. No errors or anything!

    The output file was blank. So I went back to edit the source code. Umm, it's blank too. And, of course, I was just messing around, so I had no backups.

    Then one day it suddenly occured to me: I probably screwed up the variable names for the input and output, reading the blank output file and writing it over the program's source code.

    So, remember, kids, use meaningful variable names. Using $hats instead of $fog could be the end of your program.
  • by Mmmrky ( 607987 ) on Wednesday October 20, 2004 @01:17AM (#10572812)
    I don't know, I've had some lengthy coding sessions inspired by alcohol. Usually wake up in the morning, stare at the code, realize it works, wonder how that is even possible, rename some stuff for clarity and redo the comments (drunk comments can be amusing, but not the kind of stuff you want to turn in).
  • by Anonymous Coward on Wednesday October 20, 2004 @01:17AM (#10572813)
    Dude , U just made a F in my course. U should at least wait till u get the grades before making stupid (though true) /. posts abt me Mavaddat
  • by kngthdn ( 820601 ) * on Wednesday October 20, 2004 @01:25AM (#10572870)
    Thanks! Now I can write my first computer program... 10 DIM WITTED
  • by Anonymous Coward on Wednesday October 20, 2004 @01:26AM (#10572875)
    Although I agree the above post, I must point out that it wasn't written by me as I am the real Mavaddat.
  • by YOU LIKEWISE FAIL IT ( 651184 ) on Wednesday October 20, 2004 @01:28AM (#10572885) Homepage Journal

    No, no, no. Just patch the iterpreter or compiler to allow floating point line labels!

  • by Anonymous Coward on Wednesday October 20, 2004 @01:32AM (#10572895)
    There was one very funny incident in my school, a long time ago. This student copied the code from this other geek. Unfortunately the original writer put his name all over the place, like (c) Bill Gates, etc. So, the student had to do a manual find and replace (because he didn't know how to work vi either).

    As we, in the software community know, manual find and replaces are prone to errors. So, he submitted the code to his professor, who approved it and executed it.

    Unfortunately, the output started with something like:
    THIS PROGRAM IS WRITTEN BY BILL GATES

    Luckily, the professor did not see the message printed, and gave him a high score.
  • by Anonymous Coward on Wednesday October 20, 2004 @01:54AM (#10572986)
    Allow me to be completely honest. I was such a lazy slacker in school that I almost NEVER bothered putting in the thought or brainpower into writing an assignment. Instead, what I usually did was find a way to hack into the time sharing system, bypass file access privileges, and grab other students' finished code. I would then compile them into executables, and tested them to ensure they worked. I would keep discarding until I found one with the least possible number of run-time bugs. I would then use a disassembler and generate an assembly language version of the executable. Finally, using the assembly language version as a reference, I would begin coding in the appropriate high level language.

    Nobody ever figured out my method of cheating. But I got great grades and I sure didn't have to waste time thinking of how to write those silly assignments!
  • by MrBlue VT ( 245806 ) on Wednesday October 20, 2004 @01:56AM (#10572996) Homepage
    Not a bad idea. I like it! It does get tough because floating point numbers are often non-deterministic when you are dealing with computers.

    You might goto line 1.9999 when you meant to goto line 2. But hey, that's one of the prices you should be willing to pay for living on the bleeding edge of line numbering technology.
  • by fireboy1919 ( 257783 ) <rustyp AT freeshell DOT org> on Wednesday October 20, 2004 @02:05AM (#10573033) Homepage Journal
    As a TA, I've often felt that students who ignore errors should should get points marked off for reasons they can't understand. After all, if they're going to make me do more work because they can't be bothered with simple comprehension, shouldn't I give them the same?

    Old comments:
    -1 Missing ";"
    -1 Changed case of variable; not recognized by the compiler.
    -2 Need a closing bracket "}"
    -3 Trying to write from an unassigned pointer.

    New comments:
    -1 Missing weasels exception error.
    -1 I just felt like taking a point off here.
    -2 For great justice
    -3 Disco Inferno at this point in the code.

    I never got up enough nerve to actually do it. Plus, I don't really want to risk any students suing the school.
  • by Bullseye_blam ( 589856 ) <bullseye_1@[ ]oo.com ['yah' in gap]> on Wednesday October 20, 2004 @02:17AM (#10573084) Journal
    When borrowing someone else's code to finish an assignment that totally stumps you... don't forget to change the variable names. [slashdot.org]

    -Bullseye
  • by Wescotte ( 732385 ) on Wednesday October 20, 2004 @02:20AM (#10573095)
    Yeah, I mean I once had a girl in a programming class say she'd do *ANYTHING* to pass the class, so I had her buy me dinner in exchange for helping her study, then never saw her again!

    A woman says she'll do anything for your help and the best you can think of is dinner? She said ANYTHING! Are you a man or what!?! Think bigger my friend!

    Have her buy you two dinners!
  • by Anonymous Coward on Wednesday October 20, 2004 @02:23AM (#10573110)
    Just use COBOL and this will happen automatically.
  • by demonbug ( 309515 ) on Wednesday October 20, 2004 @02:30AM (#10573139) Journal
    OBVIOUS, but always missed. If you need to cheat, change majors.


    Yeah. Thats what the college of business is there for.

  • by Anonymous Coward on Wednesday October 20, 2004 @02:31AM (#10573141)
    What kind of fucked up language starts arrays at zero?
  • by Anonymous Coward on Wednesday October 20, 2004 @02:53AM (#10573205)
    I love that essay. Unfortunately almost all of the habbits described apply to the program I was hired to maintain...
  • by Anonymous Coward on Wednesday October 20, 2004 @02:54AM (#10573207)
    No, I am the true Mavaddat ! You can tell because i only write in italics, unlike my imposters
  • by hussar ( 87373 ) on Wednesday October 20, 2004 @03:44AM (#10573388) Homepage
    Don't provide solution sheets that contain code that will actually compile. After the frustration of working unsuccessfully for days (nights) to get her assigned programming project to compile and run correctly, what the student really wants is the character building exercise of debugging the instructor's solution to the exercise. When the students see that their instructor also has problems writing bug-free code, it will help to buttress their self-confidence.
  • by Trepidity ( 597 ) <[gro.hsikcah] [ta] [todhsals-muiriled]> on Wednesday October 20, 2004 @03:45AM (#10573392)
    mavaddat prefer people not post on slashdot using mavaddat name

    mavaddat work very long time downloading lecture notes for ungrateful kids paying only $700!

    mavaddat remind you 30" lcd monitor needing to purchase but cost much more!!!!

    MAVADDAT THE PROFESSOR!!!!! MAVADDAT BREAK HEAD WITH PLAGIARIZED CD!!!!!
  • by nmb3000 ( 741169 ) on Wednesday October 20, 2004 @03:46AM (#10573397) Journal
    Why use boring old For and While loops when recursion is so much more fun? Next time you start typing 'for (i=0;'... ^H^H^H^H a few times and do it with a recursive function call instead. It's a lot more exciting, and just think of the fun somebody else is going to have in a few years when they try to update your code!

    That'll teach those dirty corporate &%*@!s. Lay me off will you? I hope the Indians like puzzles!

    Besides, nothing's cooler than that which has the rule "Just have faith it [recursion] will work."
  • by jlemmerer ( 242376 ) <xcom123@SLACKWAREyahoo.com minus distro> on Wednesday October 20, 2004 @04:07AM (#10573480) Homepage
    ... to be the microsoft way. did you copy it from them?
  • They forgot (Score:3, Funny)

    by coolgeek ( 140561 ) on Wednesday October 20, 2004 @04:10AM (#10573490) Homepage
    Don't waste valuable coding time checking for various error conditions and handling them. Most of the time the return code from various functions is just fine. If it isn't, then there is something really wrong with the system, or the user is a complete jackass who deserves to spend hours scratching their head trying to figure out why your program doesn't work.

    Time wasted coding error handlers is better spent implementing more features in your program. You can always wait for version 2 to implement real error handling where it is needed based on user reports.
  • by cozziewozzie ( 344246 ) on Wednesday October 20, 2004 @07:51AM (#10574026)
    You're a PhD student, and the only thing wrong you noticed with this heap of advice was the little part you quoted? Oh my. Good luck with your PhD! :-)
  • by Anonymous Coward on Wednesday October 20, 2004 @07:59AM (#10574054)
    Yeah, because, as we all know, weed causes you to totally blackout for HOURS on end with no recollection of the evening *rolls eyes*

    BS.
  • True story (Score:4, Funny)

    by markov_chain ( 202465 ) on Wednesday October 20, 2004 @09:38AM (#10574670)
    In an algorithms class (about 60 students) at my school there was a big challenging programming assignment mid-semester. The prof and the TAs caught a couple of people cheating, like 3 or so. Now this was a cool prof who didn't want to get kids kicked out of school so he decided to give them a second chance. On the final, there was a question worth 1 point stating "We found some cheating last month. If you did it, confess and you only fail the course. If you don't confess, we'll get you kicked out. Did you cheat? (1)"

    Half the class confessed.

  • What kind of person would advise someone not to make questions because he/she will be intepreted as stupid?

    erm, The kind of person who is being satirical??

    But of course, I could be wrong since I'm not a PhD student....

  • by Anonymous Coward on Wednesday October 20, 2004 @11:16AM (#10575556)
    What about doing a hypercard implementation of Daleks while on LSD? Does that count?
  • by Anonymous Coward on Wednesday October 20, 2004 @11:30AM (#10575708)
    Actually, really good bud can do that to girls. I've seen a couple get all loopy and not know where they are after smoking a couple of bowls.

    Uh dude... they're just pretending. They're acting like that because they want you to fuck them.
  • by Anonymous Coward on Wednesday October 20, 2004 @01:19PM (#10577072)
    So he's aware of what celsius is, and pays enough attention to notice the nationality of the author, and he's ethnocentric? NO, I charge that you, sir, are secretly a fundamentalist anti-Fahrenheitist! Yes you and your "rest of the entire planet" brainwashed lackeys will stop at nothing to eradicate the last traces of good ole F. Your attempts to whitewash history will fail! Don't turn your back on the tradition of your forefathers only to sell out to some cheap, glamorous, modern machine. Don't join the masses simply because they are numerous. Oppose the cultural imperialism of Celsius!
  • by Anonymous Coward on Wednesday October 20, 2004 @01:34PM (#10577300)
    You need to comment on how the heck you have two variables on the left side of the =.

    most likely you're using a custom language, which will be unfamiliar to the reader, and therefore will require a novel to explain it!

"I've seen it. It's rubbish." -- Marvin the Paranoid Android

Working...