Slashdot Mirror


Programming Assignment Guide For CS Students

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!)"

141 of 761 comments (clear)

  1. Slashdotted. Already. Here is article text. by Pig+Hogger · · Score: 4, Informative
    How NOT to go about a programming assignment

    Computer programming students invariably fall into more than one bad habit. It can be extremely difficult to eradicate them (and many lecturers and professional programmers keep succumbing to them time and again). I wrote this when, in the days leading up to an assignment deadline, I saw these things happening so often that I couldnt help but recall my classmates and I a decade earlier doing exactly the same things as my students.

    This article is an attempt to show these irrational attitudes in an ironical way, intending to make our students aware of bad habits without admonishing them.

    NOTE: This text was published by ACM's SIGCSE in the June 2004 issue of Inroads, the SIGCSE bulletin.

    All about programming, in the strictest sense of the word Ignore messages

    Compilers, operating systems, etc. generate error messages designed only to be read by their creators (maybe to justify their salaries). Precious time is wasted reading these messages; time that could be better spent writing code, of course! Error messages make us less productive. Dont fall into the trap. Ignore them.

    As for warning messages, ignoring them makes you feel like a professional programmer whos not scared of computers. What better way of showing ones experience as a programmer than delivering a program that generates dozens, no, hundreds of warning messages when it compiles without its author feeling the slightest bit concerned? Everyone can see that youre an experienced, laid-back programmer who is too busy to waste time on drivel.

    Dont stop to think

    Lets not kid ourselves here. What are we building? A program. What is the only thing that really matters in a program? Code. What really works? Code. Why use outdated resources like pencils, pens or paper? You are a paid-up member of the SMS generation; you dont make a fool of yourself writing time-consuming syllables, right? Then, stop messing around thinking about nothing when theres so much code to write.

    You should never stop coding. We all know that error messages are an unacceptable interruption, a pointless obstacle as we go about our work. So what do you do if you get a compiler error message? As you should know by now, reading and understanding it is just not an option.

    You can try making some random change to the source code. You never know, you might pull the wool over the compilers eyes. But if this doesnt work, dont waste any more time. NO, dont be tempted by trying to read the message or understanding it. Just keep churning out code - thats the only way of finishing off this horrendous assignment. Youll get to sort the error out later on. And as we all know, errors tend to disappear by themselves if theyre ignored. At the end of the day youll compile, youll

    1. Re:Slashdotted. Already. Here is article text. by roman_mir · · Score: 2, Funny

      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.

    2. Re:Slashdotted. Already. Here is article text. by cozziewozzie · · Score: 4, Funny

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

    3. Re:Slashdotted. Already. Here is article text. by sm1979 · · Score: 2, Insightful

      Sorry to say that man, but you really got lost on the irony in the text. Or you are so used to skimming over 100+ pages of literature at insane speeds doing your PhD research that you just can't slow down while reading anymore. :-)

    4. Re:Slashdotted. Already. Here is article text. by JudicatorX · · Score: 3, Funny
      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....

      --
      "It is a good divine that follows his own instructions" - Portia, The Merchant of Venice
  2. rule 1 by Anubis350 · · Score: 2, Funny

    rule one: do not post vulnerable servers on slashdot without a mirror

    --
    "goodbye and hello, as always" ~Prince Corwin, from Zelazny's Amber series
  3. Bad Idea by Anonymous Coward · · Score: 5, Insightful

    I'm sure many people will say this, but you learn much more from making mistakes and working out the problems than by reading a book on common mistakes.

    1. Re:Bad Idea by xs650 · · Score: 4, Insightful

      No need to repeat others mistakes, learn from theirs then go on to make you own unique mistakes.

      A smart man learns from his mistakes
      A wise man learns from others mistakes.

    2. Re:Bad Idea by Concerned+Onlooker · · Score: 4, Insightful
      It's not about not making mistakes, it's about bad habits being formed. Of course we're going to make mistakes starting out, but this is about avoiding the mistake of forming harmful habits.

      We cement our knowledge by doing hands on programming and working out problems, but we have to learn from someone/something in the first place, otherwise we'd be always reinventing the whole process.

      --
      http://www.rootstrikers.org/
    3. Re:Bad Idea by HawkingMattress · · Score: 2, Insightful

      There are mistakes you can learn from by reading, e.g you can understand that reading a stream using a particular technique is bad in whatever circumstance because of this and that.
      But the most important mistakes generally seems obvious when you read them, and you only realize you felt in the trap, and why it's so easy to fell in it once you've made it using your own flawed logic. Then you realize you're in the exact situation this damn book told you was bad, and you start to realize why the book tried to warn you. No it wasn't so obvious, because it seems so logical and fits well at first glance.
      What the book didn't tell you is how to recognise the start of a reasonment that will lead to this error...
      A detailled modelisation should be able to see those problems before implementation, but the modelisation is never detailled enough to spot everything.

  4. Cheating. by mikeleemm · · Score: 2, Insightful

    Not cheating would be a good important one.

    OBVIOUS, but always missed. If you need to cheat, change majors.

    1. Re:Cheating. by sqrt(2) · · Score: 2, Informative

      Why? It's giving you real world experience. Do you think professionals don't steal code?

      --
      If you build it, nerds will come. Soylentnews.org
    2. Re:Cheating. by Concerned+Onlooker · · Score: 2, Insightful
      It's hard for me to imagine cheating on a coding project (or anything else, for that matter). I've gone back for a second degree after many years out and I'm taking all that math I avoided the first time around. I do not like the math so much, but I'm putting on my game face.

      I feel like I'm taking more math than CS so when I get into a CS class it's just plain fun. If you have to cheat at something that is your major, for crying out loud, what are you doing in that major?

      --
      http://www.rootstrikers.org/
    3. Re:Cheating. by demonbug · · Score: 5, Funny
      OBVIOUS, but always missed. If you need to cheat, change majors.


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

  5. i can't get to the article, but... by ansleybean · · Score: 5, Insightful

    a HUGE thing is not to plagarize code. I was a TA for CS101 at my school, and plagarism is not only rampant, but really really easily detectable. besides, you don't learn anything; although, as one of my professors said, "if you can copy someone else's code and alter it so I can't tell, you may as well have actually done the assignment."

    1. Re:i can't get to the article, but... by gcaseye6677 · · Score: 5, Insightful

      This really depends on how well the professor defines the assignment. If every aspect of the programming assignment is spec'd out to the point that there would only be one correct answer, it would be easy to get away with cheating since all of the good submissions would look the same. If, however, the professor assigned a creative problem solving exercise and a proper solution could take many different paths, 2 or more identical submissions would be a dead giveaway of cheating. If professors really want to stop cheating, they need to take the initiative to assign work that requires creativity on the part of the students as opposed to submitting code that could be a cut and paste of textbook examples. Having had both kinds of professors in school, I saw first hand what kind of work students provide in each environment.

    2. Re:i can't get to the article, but... by Christopher+Thomas · · Score: 5, Interesting
      This really depends on how well the professor defines the assignment. If every aspect of the programming assignment is spec'd out to the point that there would only be one correct answer, it would be easy to get away with cheating since all of the good submissions would look the same.

      There are a few things that you can still look for, here:
      • Nearly identical style.
        This includes names, indenting, order of functions, spacing conventions, and so forth. Some similarity could be coincidence. Nearly identical style is very suspicious, especially if any of the other flags come up too.

      • Nearly identical discussion.
        Many assignments (like the ones I'm currently marking, for instance) require a short write-up explaining what they did. This may only be a few sentences, but people who cheat tend to either copy it word for word, or do a broken copy of it taking key words and trying to paraphrase the rest. Usually badly. This leads into the next point.

      • Identical mistakes.
        Two assignments. Both would fail on their own lack of merits, but curiously, they both made exactly the same set of errors, in addition to having very similar style. Not likely to be concidence, that. Especially since they were...

      • Handed in on top of each other.
        These assignments are put in a drop box. Electronically submitted assignments are usually datestamped. Cheaters, once they finish cheating, tend to submit at the same time (at least in this course). Finding two matching assignments in a stack of a hundred would take a good memory (or a heuristic checker). Finding two matching assignments that are right on top of each other, or within a few entries of each other, is much easier.


      Despite the fact that it's _possible_ to cheat without detection, a large number of people don't. Remember, the people who are cheating are the ones who can't hack a first-year CS course. While there will be exceptions, the kind of person who can't figure out how to make "hello, world" or set up a very simple Excel spreadsheet, with the instructions in front of them, is probably not going to be very good at cheating either.

      If, however, the professor assigned a creative problem solving exercise and a proper solution could take many different paths, 2 or more identical submissions would be a dead giveaway of cheating.

      The problem is that it's very hard to do this in a way that's easy to mark. In an ideal world, that wouldn't matter, but in practice, some poor TA is going to have to try to mark 200 assignments in 3 hours. That's hard enough when they _are_ written to be easy to mark (I still wince at the memory of one marking assignment that involved digesting a 5-page report and then visually determining whether another 5 pages of non-trivial code worked or not).

      In summary, despite the fact that we're stuck giving cookie-cutter assignments for practical reasons, the cheaters (that I see, at least) seem to be as bad at cheating as they are at doing the work.
    3. Re:i can't get to the article, but... by JohnFluxx · · Score: 2, Interesting

      "Your professor obviously had no idea what he was talking about. "

      This is what arrogance is. When you put down a professor, when you aren't even right.

      Sometimes just a little rephrasing can make a world of difference. Instead of "Your professor obvious had no idea what he was talking about", how about: "How would the professor spot plagiarism if I did: ..."

    4. Re:i can't get to the article, but... by multipartmixed · · Score: 2, Interesting

      > The problem is that it's very hard to do this in a way that's easy to mark.

      I used to have prof who did the semi-creative assignment thing, and this assessment is bang on the money.

      I once had to write a blackjack game in SmallTalk. The only mark I lost is because I made the dealer inherit from the player class, instead of the deck.

      WTF?! The deck? HELLO! Maybe, MAYBE I could see him wanting to inherit from the game, and make him part of game play. But making him inherit from the deck means replicating draw and hit methods, and makes no sense whatsoever.

      10 years later and about a billion lines of code later, I'm still pissed at that TA.

      --

      Do daemons dream of electric sleep()?
  6. Additional Advice by nebaz · · Score: 5, Funny

    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.

    --
    Rhymes that keep their secrets will unfold behind the clouds.There upon the rainbow is the answer to a neverending story
    1. Re:Additional Advice by nebaz · · Score: 5, Funny

      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.

      --
      Rhymes that keep their secrets will unfold behind the clouds.There upon the rainbow is the answer to a neverending story
    2. Re:Additional Advice by dtfinch · · Score: 2, Funny

      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.

    3. Re:Additional Advice by gcaseye6677 · · Score: 4, Funny

      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.

    4. Re:Additional Advice by kngthdn · · Score: 2, Funny

      Thanks! Now I can write my first computer program... 10 DIM WITTED

    5. Re:Additional Advice by YOU+LIKEWISE+FAIL+IT · · Score: 4, Funny

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

      --
      One god, one market, one truth, one consumer.
    6. Re:Additional Advice by MrBlue+VT · · Score: 3, Funny

      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.

  7. Comment removed by account_deleted · · Score: 5, Funny

    Comment removed based on user account deletion

  8. Programming Mistake #1 by Rufus211 · · Score: 4, Funny

    Get your site linked from slashdot.

  9. Slashdotted ... by ggvaidya · · Score: 5, Informative

    but also mirrordotted :).

  10. One thing not to do by esac17 · · Score: 5, Funny

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

    1. Re:One thing not to do by esac17 · · Score: 2

      if (condition);
      {
      myvar = 1;
      }

      because of the semi-colon at the end of "if (condition);" the {} are simply considered a block and myvar is set to one no matter if condition is true or not.

      Or maybe you are being sarcastic and trying to make fun of my stupidity.

    2. Re:One thing not to do by LeiGong · · Score: 4, Insightful

      Maybe you should have used a debugger and stepped through the code. A good programmer knows when he's defeated and when he has to step through the code. Maybe that should be one of the rules. Use the debugger, it's there for a reason. Don't assume you're wiz and will fix the problem by just reading the code line by line. If you're a neophyte, chances are you're going to mess up existing working code.

    3. Re:One thing not to do by Yaztromo · · Score: 4, Insightful

      Oh I just know I'm going to open up a huge bag of worms with this one, but this is why I vastly this sort of syntax:

      if (condition) {
      myvar = 1;
      } // end-if

      It makes it easier to identify which statement the block is intended to begin with, and makes it easier to spot if there are un-intended characters between the condition and the block-opening (besides reducing vertical space wastage).

      Yaz.

    4. Re:One thing not to do by Bonkers54 · · Score: 2, Informative

      Both (sp)lint _AND_ gcc with -Wall should have picked up this error immediately. Try using the tools available to you.

    5. Re:One thing not to do by Yaztromo · · Score: 2, Interesting
      But do you really use comments like "// end-if"???

      Yes, in fact I do. It makes it obvious what statement a close-brace goes with, in the event the indentation is screwed up, or if it's on a separate page from the block opening. Take this class, for example.

      I'll give you an example of where this is useful:

      (Note: I tried typing up this post using <ECODE> with spaces and non-breaking spaces, but /. appears to strip them all out. The code below was intended to be indented, but it doesn't look like /. is going to let me. The point is even more poignant without the indentation, but as very few people code without indentation, it doesn't make for as good an example IMO. So please imagine the code below as being indented).

      // The same useless code, but with block-closing comments.
      int x=0;
      while(x<10) {
      if (x%2==0) {
      for(int i=0;i<x;i++) {
      doSomething(x, i);
      doSomethingElse(x);
      }
      }

      This code is obviously incomplete, as it specifies more open braces than close braces. I coded it, but it's up to you to fix it.

      However, without knowing the algorithm, where do you add the extra close brace? Note that the first close-brace isn't at the same indentation level of anything else (due to developer typo) -- was it intended to close the if statement (and thus it's the for statement that is missing its closure), or is it the closure for the for statement, and it's the closure of the if statement that is missing?

      Using my syntax, this is brutally easy to fix without going through the algorithm to discover what was intended:

      // The same useless code, but with block-closing comments.
      int x=0;
      while(x<10) {
      if (x%2==0) {
      for(int i=0;i<x;i++) {
      doSomething(x, i);
      doSomethingElse(x);
      } // end-for
      } // end-while

      Thus, it's the if statement that is missing its close block. The code should look like:

      // The same useless code, but at least it's syntatically correct.
      int x=0;
      while(x<10) {
      if (x%2==0) {
      for(int i=0;i<x;i++) {
      doSomething(x, i);
      doSomethingElse(x);
      } // end-for
      } // end-if
      } // end-while

      You may think that looking at the indentation might tell you where the closing brace is missing -- but just try working in a development group sometime where some developer is using 2 or 4 character tabs instead of 3 character tabs, or where they're using spaces instead of tabs (or tabs instead of spaces). Indentation is easily munged in such a case, and it can creep into source very easily. Without close-brace comments, a missing close may be very difficult to insert in the correct position.

      So yes, I do add such comments to every close tag. They're quick to type, but generally I set-up my code editors to either insert them automatically, or to at least assign a macro to insert them. It makes the code easier to maintain if someone accidentally forgets to close off a block, and makes it easy to determine what statement a given close goes with if the close is on a different page from the block opening statement.

      Yaz.

    6. Re:One thing not to do by Bill+Dimm · · Score: 2, Informative

      Incidentally, is there any good reason why people like the other way? (i.e. braces aligned)

      1) If you ever end up with mismatched braces you can do this:
      egrep '{|}' program.c
      to get an overview of the braces to more easily find the mismatch (no "if" or "for" stuff to clutter it). This is probably less useful with modern editors that do brace matching.

      2) Personally, I think it makes it easier to skim the code. For example, look at:

      if (condition)
      x = y;

      and then look at:

      if (condition)
      {
      x = y;
      a = b;
      }

      When reading either of the above, I think "If I care about what happens when the condition is satisfied, indent one level and read, otherwise skip to the next line with the same level of indentation." If you do braces the other way, when you skip forward to the next line with the same level of indentation you may or may not run into a "}", which seems out of place to me (i.e. the braces are part of the statement to be executed, not part of the "if"). Just my opinion though. Do whatever makes you happy.

    7. Re:One thing not to do by Yaztromo · · Score: 2, Interesting
      Why didn't I think of that?

      I don't know, but now that you know, feel free to use it in your own projects :).

      Actually, for anyone interested in how I typically write easy-to-read code, check out this PDF document (or the HTML version). These are the coding guidelines I wrote up (and follow) for the jSyncManager Project. And yes, they're enforced (albeit not in a draconian manner -- if another developer misses something, I usually just fix it for them as opposed to nailing them to the wall :) ).

      Good Open Source code needs to be readable and easy to work with IMO. If you want to attract more developers to your project, and/or want third-party developers to use your Open Source APIs, you need to make sure when they grab your code they can get working with it with an absolute minimum of hassle, and as much information as they need. The last thing you want to make them do is go through all your code with a fine-toothed comb trying to figure out what it's doing. They want to write code, not try to figure out what the existing code is doing manually.

      Just as nobody likes to read a novel with no paragraph breaks/indentation, no chapter breaks, and no formatting, nobody should have to read messy code. Writing elegant looking code with useful comments takes very little time (particularily if you're a fast typer), and is always worth the extra effort, especially in an Open Source project that is close to your heart.

      Speaking of which, if anyone out there is interested in developing code for an Open Source, pure Java data synchronization solution for Palm OS-based handhelds, or using such code in one of their own projects, send me an e-mail :) ).

      Yaz.

    8. Re:One thing not to do by renoX · · Score: 2, Interesting

      Well, unfortunately this is a pretty common mistake, blame it on K&R to introduce such an easy pitfall.

      Unfortunately, if I'm not mistaking neither C++ or Java designer had the guts to make {} mandatory after an if,for..

      C is a language with lots of pitfall, but usually they are not too difficult to catch:
      1. read a document which list the pitfall.
      2. when you have a problem, first a. stop 10min to free the mind, b. use debugger, printf to narrow the search, c. if it doesn't work ask for help: two are better than one. Of course it means that you two must work to solve it on the same screen, as you will probably be the one who catch the bug anyway (don't send by email the code waiting for the magic answer).

    9. Re:One thing not to do by raehl · · Score: 4, Insightful

      I read his objection differently than I think even he intended it...

      } // end_if

      should be

      } // if (x%2)

      Or some such. The point being that you should have meaningful comments, and chances are with oodles of If's, sticking end-if after each closing brace will probably be less than informative.

    10. Re:One thing not to do by cheekyboy · · Score: 4, Insightful

      I used to do that in the previous millenium, but its crap, you cant just // comment out the condition and run the code as is, you have to move the { later.
      Besides it looks ugly the way you have it.

      --
      Liberty freedom are no1, not dicks in suits.
    11. Re:One thing not to do by Chelloveck · · Score: 2

      There's no excuse, ever for indenting the braces as well as the code. We all know that this is the proper way to indent.

      if (condition)
      {
      ....a = b;
      }
      else
      {
      ....c = d;
      }

      (Come on, Malda, the <ecode> tag really needs to preserve spaces at the beginnings of lines, too!)

      One thing I've found is that this style helps with grotty #ifdef statements. I like to put superfluous braces around them, too.

      while (condition)
      {
      ....#if defined(FOO)
      ....{
      ........a = b;
      ....}
      ....#else
      ....{
      ........c = d;
      ....}
      ....#endif // #if defined(FOO)
      }

      This makes it really easy to track large blocks in nested #if..#endif directives, and makes them read more like regular if..else statements. And yeah, I know, preprocessor directives are ugly as sin, but they're sometimes necessary. Most of what I write is code for microcontrollers, and it must be portable from one target platform to another. I can't afford to waste memory or execution time to evaluate conditionals at runtime when they can be done by the compiler instead.

      --
      Chelloveck
      I give up on debugging. From now on, SIGSEGV is a feature.
  11. high school by Anonymous Coward · · Score: 5, Informative

    This may sound a bit odd, but I went back to my home country Iran for 2 years as a teenager. This is when I had my first insight into computer programming.

    At the time I along with most students didnt have a computer, not did I have access to one properly.

    I did my first BASIC coding on paper. Looking back, working that way worked extremely well.

    Since then I always do some sort of rudimentary pseudo code on paper before implementing using a computer.

    note: I never finished high school and I haven't been to university

    1. Re:high school by roman_mir · · Score: 4, Interesting

      Since then I always do some sort of rudimentary pseudo code on paper before implementing using a computer. - congrats. You and me, both. I didn't have a computer at 11, and that is when my grandma bought me a book on programming. Only the book was an adventure story and in order to progress in the story, I had to solve tricky problems that became more and more complex as the reading went on. For each new problem set I had to learn yet another programming concept, conditions, loops, function calls etc. The book was structured in a way that would not allow one to understand what was going on without solving the problems.

      I didn't have a computer, but I became insanely interested in them and I did write my first dozens of programs on paper and traced them that way. Wrote games something like robots and FPSs on paper. Later was able to type them into translators and they worked.

      Argh, where is my childhood?

  12. i thought it was going to be something serious... by Fluidic+Binary · · Score: 3, Insightful

    I was hoping for something educational and instead I found a collection of jokes that I don't find very amusing. I mean sure I'm smirking, but shouldn't something that took that many bytes at least make me chuckle?

  13. Most of the Prof's lecture notes are plagarized by Cryofan · · Score: 4, Interesting

    I found that if you googled most of the CS lecture notes, most of them were plagiarized from some other school....

    --
    eat shiat and bark at the moon
    1. Re:Most of the Prof's lecture notes are plagarized by ansleybean · · Score: 2, Funny

      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.

    2. Re:Most of the Prof's lecture notes are plagarized by Sir+Joltalot · · Score: 4, Informative

      I had a prof that did that, at the University of Waterloo, of all places.
      It's one thing to use somebody else's lecture notes. But this guy clearly didn't even read them before coming to class. You'd ask him a question and he'd just say "Uh, I don't know, these aren't my notes." For crying out loud! And I was paying $700 or so for that course! The prof was Mavaddat in case you're curious. If you're ever scheduled to have a course with him, SWITCH as fast as you freaking can! You're better off Googling for stuff and reading other people's PowerPoint slides by yourself.

      --
      "Caffeine is not an option. Caffeine is a way of life."
    3. Re:Most of the Prof's lecture notes are plagarized by Anonymous Coward · · Score: 2, Funny

      Although I agree the above post, I must point out that it wasn't written by me as I am the real Mavaddat.

    4. Re:Most of the Prof's lecture notes are plagarized by Anonymous Coward · · Score: 3, Funny

      No, I am the true Mavaddat ! You can tell because i only write in italics, unlike my imposters

  14. Ye old Slashdot Effect by beacher · · Score: 4, Interesting

    Anyone want to see it? If you can get the page to load, click on the chart icon which leads you here...
    12:32 EST 20 octubre 2004 1223... Took 300 hits since 2 minutes ago.. Neat

  15. Re:Compiler Warnings by Anonymous Coward · · Score: 2, Insightful

    Irony - look it up.

  16. Re:Advice from a fellow student by jschottm · · Score: 4, Interesting

    I highly (so to speak) advise avoiding coding under the influence of daytime cold medicine. The nighttime ones are not so bad, as they make me go to sleep and stay away from my keyboard. Dayquil on the other hand...

    Well, the code was 100% accurate and fast, but when I went to refactor it, the logic was so bizarre that it was easier to rewrite it from scratch. It didn't run any faster [insert snide comment about my lack of skill here], but at least some random person could sit down and figure out what was going on afterwords.

  17. Re:Advice from a fellow student by YouHaveSnail · · Score: 3, Interesting

    Do not, under any circumstances, code under the influence of alcohol.

    This was actually a rule at a company for which I worked. We'd occasionally have beer or wine at company parties and such, and writing code after drinking was verboten. You could go back to your desk and work on design, documentation, etc. But no programming after drinking.

    It's a damn good rule.

  18. Guide to programming languages by prostoalex · · Score: 4, Funny
  19. "Cheat with your assignment" - ETS by Anonymous Coward · · Score: 2, Informative

    I go to the ETS, (Superior Technology school) in Montréal, and currently strudying CS. The part : "Copy the programs. Lecturers will probably have to mark dozens of them, making it difficult to spot similarities between them. And even if they do, it sure as hell ain't easy to prove..." don't really apply to us.
    You see, they have a kind of program, which they use to compare all the assignement that are handed in. Not only does it compare it with everyone in your class, it compares your code with the code of all the students from the last four year.

    Try and copy anything now... good luck!
    This is how you run a school ... at least with respect to CS assignment handling...
    Any other school has a similar setup?

    1. Re:"Cheat with your assignment" - ETS by 6th+time+lucky · · Score: 2, Interesting

      At the uni i go to, they have started testing out Turn-it-in (http://www.turnitin.com/). It can be used in all faculties for code, mathematics, and 'normal' written assignments. Checks all submitted assigments against each other and the web, highlights the similarities and gives a report.

      The good thing about it is that it is not just to catch cheats, but to educate students (particularly in the sciences) about referencing quotes etc, and to not just block copy other peoples work. Courses will either have the students submit to Turn-it-in and see the reports before they actually submit and fix it if necessary (at least one dumbass submitted his copied assignment anyway!), or markers can submit bits they think are suspicious.

  20. The best advise.... by cjjjer · · Score: 5, Interesting

    For those students just getting started in a Computer Science degree or a career in software development.....

    Quit now and take up a skilled trade. The odds that you will be employed in the future are marginal at best. While most here might think that as trolling or flame-bait it's the cold reality. I have several friends who are tradesmen who say in the next 5-10 years there will be a significant shortage of highly qualified tradesmen. Where as everyday more software jobs are going off shore, it's pretty hard to send manual labor off shore and be competitive.

    My $0.02

    1. Re:The best advise.... by cheekyboy · · Score: 2, Informative

      Yeah, here trades people are in DEEP demand (au) and they are getting 80-100k plus, while programmers are being given 32-45k starters at best, (seek.com.au)

      What a joke, be a kitcken cabinet installer, get mega bucks, if you want to be creative, do it at home, why spend 9hrs/day being a slave and getting fat.

      --
      Liberty freedom are no1, not dicks in suits.
  21. My advice for young programmers by jschottm · · Score: 4, Informative

    This is stuff aimed at people without a whole lot of experience programming in first year CS courses.

    1. Get a software engineering book, and study the concepts of software design. Even if you're just doing some small little "print a schedule" type assignment, thinking about how you would design a bigger project will help you.

    2. Get a good book on algorithms. I'm partial to Introduction to Algorithms but there's lot's of good choices. So when your prof assigns you to do a project using a circular linked list, think about what might be better. But resist the temptation to smart off and try to do better, and complete the assignment the way (s)he says to. Perhaps ask the instructor what they wanted you to learn from the assignment if you feel that the algorithm is particularly inappropriate.

    Don't just read the alogrithms, write them from scratch as well until you understand them. Be aware that some algorithms are completely different if you're using a language that starts arrays at [0] than at [1].

    3. Take good technical writing courses. Many CS majors can't write well. Being able to clearly communicate is a great skill to have, regardless of what your position is, and it's a good way to differentiate yourself from the masses. Being able to write in American style English is something that many Indian/Chinese/etc. programmers won't be able to offer.

    Take business courses, etc. Broaden your horizons in profitable ways.

    4. Network, network, network. Not LANs and wireless, but people. They are the ones that will get you jobs in the future, who will provide you with sales leads and consulting. Mingle with people in the field. Mingle with business majors. Start it now, not in your senior year. Today's seniors may be the one's e-mailing you about a great position three years from now when you're about to graduate. I've seen very smart, very talented people sit for months without a job because they didn't start this process early.

    5. Get out and enjoy yourself. You have the rest of your life for LAN parties and coding sessions. If you're in college and not working, you are likely never to have the same freedom that you do now. (Excepting unemployment...) Get out, go hiking, meet people of the appropriate sex, see concerts, learn to cook. Virtually no one dies wishing they'd spent more time in front of an LCD screen.

  22. Wait until the PENultimate minute. by emarkp · · Score: 2, Informative

    Nearly every assignment I received was modified between assignment and due date when earlybirds ran into difficult or unsolvable snags. These were the only classes I found in which waiting to start was really did help.

  23. Re:Finer points of Spanish-English translation by attonitus · · Score: 2, Informative

    :-). But maybe a more appropriate title for this comment would have been "Finer points of living on a diverse planet for ethnocentric Americans". In the rest of the English speaking world, we have no problems with Celsius.

  24. Real Programmers by gustgr · · Score: 3, Informative

    Thanks, but I have my very definitive programming guide already. Mwaahahha

  25. Why aren't people learning to code properly? by Indy+Media+Watch · · Score: 3, Insightful

    The proliferation of 'happy-clicky' programming environments has led to sloppy inefficent coders who have limited understanding of how to write clean code.

    The result? Word Processors which ship on 5 CDs and do little more than similar products from a decade ago.

    More RAM, bigger hard-drives, faster processors, and for what? A new version of software that doesn't do a whole lot more to justify the upgrade?

    Meanwhile, a lack of formal coding education also means we still see buffer overflows and other security nasties that should never have happened in the first place.

    The good news, is devices like the Palm have forced people to operate in the limited hardware/memory environments of years ago. The result, clean efficient code in just a few kilobytes.

    Time to go back to school people...

    --

    Indy Media Watch-Proctologist of the Internet

  26. Re:Compiler Warnings by nwbvt · · Score: 5, Insightful

    So let me get this straight, you didn't get that the article was a work of satire, yet this is the only part of it you felt needed to be challenged?

    --
    Mathematics is made of 50 percent formulas, 50 percent proofs, and 50 percent imagination.
  27. Bad Joke by cookiepus · · Score: 3, Interesting

    Dont compile on a regular basis, dont tiptoe your way forward. Youre a professional and professionals take giant steps. Write thousands of lines of code first and leave the compiling for later; it will be far more entertaining and worthwhile to look for compiling errors.

    Actually that's uncalled for. Compiling frequently is not good because you should not be thinking about such details as syntax and var name spelling until the very end.

    For most of the time you're writing code, what you have should not be compileable. Well, doesn't need to be. Since you (hopefully) are doing things top-down, at first you're going to have a lot of empty functions and comments.

    Then you're going to fill in code. During coding, why bother compiling? Who cares if you get a 100 compiler errors at the end when you compile once, vs. getting 1 error each time, but having to compile 100 times?

    Don't bother. Focus on the higher picture. Implement your vision. Only once you've done that, fix what the compiler is bitching about. Doing the same things along the way can sidetrack you from your higher-level view of the program.

    Besides, it's a lot less annoying. Say, you're done coding. All you have to do is go make tiny changes to shut up the errors. Probably won't have to think too hard how to fix them. And then you're DONE!

    The other way, you go fix your errors, and you still got mad code to write. And now you're annoyed and distracted so it won't even come out as good.

    Also, sometimes I actually shock myself by writing code for an entire day and then having it compile w/o errors the first time! I really don't expect that, and it's a "wow" thing when it happens.

    1. Re:Bad Joke by Martian_Bob · · Score: 5, Insightful

      I've got to disagree - for beginning CS students, compiling frequently is an excellent thing to do. I'm a CS TA, and most of the panicky emails I get from students the night before a project is due revolve around small, simple problems that get blown way out of proportion. A single misplaced semicolon can make the compiler spit out dozens of errors for lines of code below it, none of which will make any sense. Errors propogated through code are terribly difficult to detect; your program's output might be incorrect due to something that you wrote two class files ago and have already forgotten about. And then there's the problem of poor program planning combined with infrequent test compilations - namely, the design sucks donkey balls and you just spent three hours laying down the foundation for a code base that is completely useless. I wrote code like this until I because a grad student, and it shows - I spend way less time designing and write far better programs due to multiple test compilations.

    2. Re:Bad Joke by jjohnson · · Score: 2, Interesting

      You're an excellent example of a freak who does a particular thing very well, and so convinces others to do it not nearly as well as you can.

      If you can code all day with minimal errors and minor cleanup afterwards, great, you've found what works for you.

      But compiling frequently is sound advice for the vast majority of programmers, in line with the maxim to keep your code in a shippable state at all times so that bugs don't fester. Also, you're violating another maxim that may be false in your case, but is generally true and sound advice: design first, code later. According to you, the design is happening at coding time, which is something most programmers don't do well.

      A top down programmer can still be an incremental developer by stubbing out the design, thus leaving it compilable without getting distracted coding helper methods.

      --
      Anyone who loves or hates any language, platform, or manufacturer, doesn't know what they're talking about.
    3. Re:Bad Joke by aussie_a · · Score: 5, Insightful
      Why am I not seeing +4 Funny? Oh well, time to argue your ridiculous post point by point (I've got 2 assignments due tomorrow, I'm using this time as a break from coding, dear god I'm a nerd).

      Compiling frequently is not good because you should not be thinking about such details as syntax and var name spelling until the very end.
      As of tomorrow I will have done 5 assignments in C++ this year. For 4 of those assignments I didn't have a compiler at my home (our program had to compile in Turbo C++, you could tell who used different compilers at home). Instead I had to go to school to debug my programs, so what I did was I'd write out my code at home in a day, go to school and then spend a few days debugging it. For 1 of my assignments (my last one) I had a compiler at home so I could debug as I go. Guess which assignment I actually enjoyed. That's right, the last one. Not knowing if my code will work makes coding unfulfilling. Spending days debugging is tedious and stressful.
      For most of the time you're writing code, what you have should not be compileable.
      This just sounds plain lazy. Your code should (with as minimal effort as possible) always be compilable. If you've got a menu that calls 5 modules, write stubs for the modules. Utilise flags. This allows you to compile as you go along.
      Who cares if you get a 100 compiler errors at the end when you compile once, vs. getting 1 error each time, but having to compile 100 times?
      Actually it's closer to "create 100 errors get 10000 error messages, try to sieve through all the messages to find the correct 100." Whereas it's much easier to go through 10 error messages to find the correct 1. You'll notice you tend to get the same 9 error messages each time, whereas having 1000 makes it a lot more difficult. And this is just syntax errors. We're not even talking about logical errors (and yes, there will be some, no-one's perfect).
      Focus on the higher picture. Implement your vision.
      Actually you won't be implementing anything. You haven't implemented it until it's working. And focusing on the higher picture should be done in the PLANNING STAGE. NOT the CODING STAGE. Ideally you shouldn't even be on a computer when writing the algorithm (which is where you focus on the higher picture). You should have a pencil, a rubber and lots of pieces of paper. But even if you are on the computer it should be done in Pseudocode.
      Say, you're done coding. All you have to do is go make tiny changes to shut up the errors. Probably won't have to think too hard how to fix them.
      I bow before your intelligence, for you can write code without debugging it at all and only have "a couple of errors." You must truly be a coding genius. That or you're talking out you're ass. I haven't met anyone who can do what you just described. Not any students and not any teachers.
      Also, sometimes I actually shock myself by writing code for an entire day and then having it compile w/o errors the first time!
      Either you write simple code or you're a liar and/or a troll. Because the chances of that being true is (IMO) very small.
    4. Re:Bad Joke by Cederic · · Score: 4, Insightful


      If you don't compile every few minutes, you're running your tests every few minutes.

      If you're not running your tests, how do you know your code works?

      If you're not compiling and testing, how are you figuring out what the code you're writing is meant to be doing?

      I used to code for a day without compiling, then sit in amazement as my code compiled first time. Luckily computers are faster now and it doesn't take the better part of an hour to recompile - it takes a few seconds - long enough to pick up my coffee, take a sip and think about the next test I'm going to write.

      Now that I compile more often, and run tests several times an hour, my code is immensely higher quality, I write it faster, I spend far less time sorting out compile errors and random bugs and I can safely walk away from the computer with just a couple of minutes notice without worrying about leaving a nasty mess that it'll take me a couple of hours to understand, finish and compile the next day.

      In other words, thanks for the advice, I'll follow it if I want to return to where I was a decade ago.

  28. Re:Advice from a fellow student by ErichTheWebGuy · · Score: 5, Funny

    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

    --
    bash: rtfm: command not found
  29. Re:For the guys... by vranash · · Score: 2, Funny

    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.

  30. Hint for programming. by Spy+der+Mann · · Score: 4, Insightful

    Here's a VERY GOOD hint for those of you who are starting to program:

    THINK UML.
    THINK OBJECTS.
    THINK MULTI-TIER.
    THINK BOTTOM-UP.
    USE A NOTEBOOK.

    If you start designing on paper the functions/object/interfaces/etc for your program, then start coding. As you begin to code, you'll start realizing that you'll need auxiliary functions (like an array searcher or something - most of the time lazy guys like you or me want to do everything in one function or method. Don't fall in the trap. If a series of steps is going to be very difficult, thing bottom-up and put it in a separate function or method. But before you start coding it, add it to a "to-do" list in your notebook.

    That way you can keep coding your current function, by calling the not-yet written function that only exists as a declaration on paper. But the idea is there.

    In the end, you'll end up with practically a completed .h header file or UML diagram on paper.

    That helps a lot when programming (specially for low-termed memory guys like me). When you're finished designing the code, all you got to do is start typing and see which functions need to be coded, or which details . Why? Because you've already solved the problems in your code.

    In one day i could design an OOP SQL wrapper (business tier) for my database project, and i only had to adjust minor details (i.e. bugs) when finished coding.

    So, believe it or not, paper SAVES TIME. Trust me.

    1. Re:Hint for programming. by roman_mir · · Score: 3, Insightful

      Here is a better hint:

      get your hands on an old 386, a debugger and an assembler. Figure out your way through building simple tools for cutting and concatenating files, fixing file system, writing simple menu driven apps. Attempt a calculator, a text editor (try this one in assembler, I am dead serious,) try a few games. A labyrinth game, an FPS, maybe some sort of a space ship game.

      Write all this stuff first the way you like, don't worry about style and comments. Stick to it, work on your own spread sheet, graphics library, TSR programs (ah, good old DOS.)

      Once you are comfortable (this will take at least 6 months, maybe more,) go back and revisit your own code. Now you will learn that all your good old code will not stay in your own head forever, you will learn to appreciate structure and comments.

      Noone can make you do it unless you realize it yourself - structure is important.

      From procedural programming, move into something more esoteric - try to write an adventure game in Prolog so that you will have to learn more and more about that way of programming. You will spend a minimum of 3 days learning and writing that shit. You know - you are in a room, now the lights are off, you have this in your hands... what are your actions.... etc.

      Now you can go into OO. OO is not a natural way of writing code or even thinking about software. You will make common mistakes, like using OO as a procedural language. But if you are still interested at that point, you will continue learning and you will understand the difference between OO and procedural or imperative. Don't use OO for everything, please, network is not object oriented. Neither is HTML. Whatever.

      But start with a 386, on that platform you will really have an opportunity to learn and control the hardware. If you will like that you will know that programming is for you.

    2. Re:Hint for programming. by beelsebob · · Score: 2, Insightful

      You seem to be implying that we're all going to go out there and use OOP? This in it's self is one of the many bigoted views that makes most code today bloated slow and buggy. What happened to chose the best tool for the job? What happened to looking at all the possibilities? There are certain tasks that OOP works really well for, and others that, quite frankly, it sucks for. Try to write a compiler in an OOP language, you're gonna go down in flames - you need a procedural language, or a functional language. Try writing a human speech parser in an OOP language, again, not going to happen - you need a logic language. I really don't get why people think that OOP is panacea, it's just another tool in the toolbox. Bob

  31. your code should read like a novel by Simonetta · · Score: 5, Funny

    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.

    1. Re:your code should read like a novel by lemonylimey · · Score: 2, Insightful

      Lindsey Lohan? Why, man, why?

      Baps.

    2. Re:your code should read like a novel by ComaVN · · Score: 2, Insightful

      "Oh, and here we take a local variable, which for brevity we called 'i', and let it iterate over a range from zero to the length of the array minus one (note that array indexes are zero-based here, so the last valid index is length minus one"

      Yeah, I can see how that would help. :(

      Don't comment lines that don't need explaining. Comment the functions they are in, what it does, under what circumstances, and why.

      --
      Be wary of any facts that confirm your opinion.
    3. Re:your code should read like a novel by Anonymous Coward · · Score: 2, Interesting

      How about why you're doing it? Are you calculating a temporary balance, a projected balance, the latest balance? Admittedly, I haven't got the rest of the code for context but, clear as your example is, it doesn't tell me anything about whether I should or shouldn't think about refactoring it.

      The main point to remember is that comments are not there to describe what code does for non-coders. It's there to describe why you did it (to aid maintenance) and to reduce the brain lag of trying to follow what amounts to a foreign language (code). Admittedly, in your example it's likely that the comment might be limited to //Calculate balance, but even that can cut maintenance time dramatically if I'm trying to scan a 10000 line file to work out where the balance is calculated.

      (That said, if I wanted a novel, I'd read Stevenson. Keep it simple)

    4. Re:your code should read like a novel by Ed+Avis · · Score: 3, Insightful

      Yes, your code should read like a novel or at least like a well-written newspaper article or technical paper.

      However, it should read like that _without_ comments! If you need to add long comments to make the code clear then fix the code first. In general, it is better to say something in code than in comments, for example 'const int x' is better than 'int x' plus a comment saying 'x will not be changed'. Well-chosen variable and subroutine names are also important. Finally arrange things in a sensible order: when writing you can either lay out the simple concepts first and use them to build up more complex things (like writing a mathematical proof) or you can start with a broad overview and then fill in the details. Either of these two styles may be appropriate depending on what your program does.

      Remember: comment _how_ and _why_, not _what_.

      --
      -- Ed Avis ed@membled.com
    5. Re:your code should read like a novel by Erik+Hollensbe · · Score: 4, Insightful

      Your assertion is too absolute.

      Sometimes, especially in the real world, commenting what is just as important.

      In the real world, a comment like this: // writing pseudo-pascal sucks

      Is common - in class, it got me a D when the rest of the code was well commented and the code well-formed. It was in direct protest to the assignment I was given. In reality, my fellow coders would probably agree with me.

      However, that's not my point. I've written blocks of code that were hard for me to understand after I put them away for a month, not because of poorly named variables or functions, but because they made use of side-effects. A great example of this is optimization. Optimization in many cases has the deliberate effect of making your code harder to read for a number of reasons.

      Duff's device is a great example of an optimization that, without explanation of what, you certainly won't get how or why.

      Well chosen names only go so far. I've worked on code that used sentences for the names of some of it's DB calls. And one could say that OCI has well-chosen names, but only the bravest database programmers tackle that mess.

  32. Some F/OSS develpers need to read this. by Yaztromo · · Score: 3, Interesting

    Or, perhaps not read this...

    Okay, I know that there are a lot of professional developers out there who follow some of the "rules" in the article, especially those involving ignoring warnings. I've been in professional programming environments, and I've seen this sort of thing excused all too often (personally, my code isn't done until it compiles 100% cleanly). However, for good or bad, this is typically hidden in closed-source projects -- how many compilation warnings does Microsoft get in its nightly Windows builds? I have no idea.

    Unfortunately, in Open Source Software everyone gets to see where the developers ignore warnings, and IMO there isn't much excuse for it. Honestly, there are far too many Open Source projects which seem to do the things this article "advocates". And everyone gets to see it.

    I remember all of the warning messages I get when building the Linux 2.4 series kernels. And I recently looked into forking the recently cancelled JPluck, but its near complete lack of code commenting makes the effort exceedingly difficult.

    This has long bothered me. If you're going to release your code as Open Source so others can work with it, it should at least have some comments in it (even just simple things like the expected input.output values for procedures, functions, or methods, expected use for variables/fields, etc.), and it should generally build without a single warning [1], in order to make it easier for others to work with the code, and to ensure them that there aren't going to be any unexpected results due to ignored warnings.

    Yaz.

    ------------

    [1] Okay, I know someone is going to call me a hipocrite when they go and grab the sources for the Open Source project I administer (the jSyncManager), build it, and find well over 100 warnings. I just want to preempt this by stating that these deprecation warnings occur because I've specified parts of the jSyncManager API to be deprecated to ensure developers currently using these deprecated classes move their code over to their replacements.

  33. While we are on the subject by nwbvt · · Score: 4, Funny
    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/

    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.
    --
    Mathematics is made of 50 percent formulas, 50 percent proofs, and 50 percent imagination.
  34. Another Tip by suwain_2 · · Score: 4, Funny

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

    --
    ________________________________________________
    suwain_2 :: quality slashdot p
  35. What to do an not to do in CS by nate+nice · · Score: 5, Insightful

    Do not slack at your math. You will repeat it. It often takes time. It is very important. Learn to utilize math and make it one of your more powerful tools.

    Do not cheat on code assignments. Once again, it may take time but you need it. Messing up and looking through code more than writing it is what really makes you good.

    Take hard CS classes. Take advantage of rare courses your school may offer in CS. Take tough classes like compilers or computational geometry. Make sure you take some diverse classes but also try and focus on something a bit that you enjoy.

    Take more math. This is a skill that can really differentiate you from other programmers in the industry, If you have good math skills, you can get good paying, secure jobs in fields like computer graphics, physics, medical and other science fields that demand proficient math skills. It will also change the way you think if you really take it seriously and understand that much of the early math is indeed lame, but necessary to understand useful math that you will eventually learn.

    Take other classes, like art. You can learn a lot from these things and apply them to what you are doing. Knowing about various things will come in handy at some point.

    Learn more than what your school will teach you. It is up to you to read about things in the field, both theory and practical. Learn languages not needed in your school. Play around with things. Put together a cheap Linux computer at home and play around in it if you haven't already. You are interested in this anyways, so this shouldn't be something you have to do.

    Maybe CS is not for you. The future is not guaranteed in this field as far as job security is concerned. You may spend a lot of time taking hard classes only to have to end up doing something else. You may not even make it through the program. Personally, I think there will always be a need for well educated, creative, smart people. The analytic skills you can learn will do more for you than anything else. Pay attention.

    If you love it and are good at it and really spend the time in school to really learn this art, you could enjoy a career working in an industry you love. If you are ambitious, there will be many trails to be blazed in the future in this young, ever changing field. It's not about "computers". It's about computation, a modern subset of math that we can abstract in electronics. The possibilities are endless and you may invent the next big thing.

    --
    "If you are a dreamer, a wisher, a liar, A hope-er, a pray-er, a magic bean buyer ..."
    1. Re:What to do an not to do in CS by tootlemonde · · Score: 2, Insightful

      Do not cheat on code assignments.

      In the working world, it's ok to cheat, even desireable. You use existing libraries and modules and avoid re-inventing the wheel even when you think you can invent a better wheel. You can usually learn more from reading the code of a master than you can from figuring it out yourself. Time is money and scalping code saves time.

      Cheating in the sense of using someone else's code without understanding it is the basis of higher-level languages. Most people use the print statement without knowing how it works and don't feel guilty. In professional programming, one of the hardest things to decide is when to cheat and when not to.

      Knowing about various things will come in handy at some point.

      They probably won't but as you get older you find that you derive the most enjoyment from the useless information you have. The pleasures of useless information are so great that you constantly have to make a difficult choice between learning things that are useful and learning things that aren't.

      The possibilities are endless and you may invent the next big thing.

      More realistically, you'll be lucky if you even get hired to work on the next big thing. The trick is to take every project and make it into a Big Thing. After you retire, your colleagues should say, "The guy that used to sit over there, he was one hell of a programmer."

  36. Re:Advice from a fellow student by Mmmrky · · Score: 4, Funny

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

  37. Re:In my experience.. by nate+nice · · Score: 4, Insightful

    That's a pretty pretensions comment. Many people don't have access, either through finance or friends, etc to get interested in CS things like programming at an early age. Granted, while in it you ought to be interested and enthused about, else you should probably be doing something else that does. But, that's the whole point of college; to discover what interests you if you haven't already and experiment with things. Many of these "majority of CS students" are taking a Java class to see if they enjoy it, thus it is the first time they have touched a command line. Many of them will find it's not for them and drop. Some will stick around for some reason.

    Besides, if you knew anything of CS you would know Java and command lines have as much to do with it as telescopes do to astronomy, to paraphrase Dijkstra. In fact, I had professors who could care less about Java or command lines because their interests are in theoretical computer science, algorithms, math, theory, etc.

    Perhaps you are in the wrong major. Maybe you belong in a traade school for programming?

    --
    "If you are a dreamer, a wisher, a liar, A hope-er, a pray-er, a magic bean buyer ..."
  38. Re-use is ok after you graduate ... by AHumbleOpinion · · Score: 2, Insightful

    Re-use is ok after you graduate so the professors are OK, copyright assumed not to be an issue. While you are learning you need to do things yourself.

  39. My favourite by smallpaul · · Score: 3, Insightful

    When I was in university I would spend 90% of the time putting together a "framework" to solve the actual problem (much more general and thus useful for future classe). Then I would spend 7% of the time debugging it. Then I would spend the remaining 3% desperately trying to figure out how to use the framework to solve the assigned problem.

  40. Re:In my experience.. by iMaple · · Score: 3, Insightful

    .. most CS students should not be in the program much less touching computers. A good programmer is usually found in someone who does it outside school or work requirements. Someone who touches the command line for the first time in their Intro to Java class (one of the first ones in most CS programs today) is not one of these people.

    Well I was under the impression that they join the program to learn CS and not the otherway round. I have seen smart students who have never used a computer before do really well in my course. Also CS is not just about programming, its like other engineering branches ... i.e. about solving problems ... programming languages are just the tools. Your argument is similar to saying that unless u have experience constructing bridges and buildings dont go into a Civil engg. program. (anyway most analogies are as dumb as a bat :)

  41. Re:i thought it was going to be something serious. by Christopher+Thomas · · Score: 2, Insightful

    I was hoping for something educational and instead I found a collection of jokes that I don't find very amusing.

    This is intended to be educational. Rather, it is intended (at least in part) to be yet another thing to point first-year (and later!) students to, in the hopes that they decide to absorb it for a change. Give the advice in enough forms, and maybe one of them will take.

    That, and it reads a bit like it was written to vent frustration. I know I can sympathize with a lot of what was expressed there (I've had to TA programming courses many times).

  42. Re:Compiler Warnings by Wocko · · Score: 2, Informative
    #pragma warning (disable : 4503 4786)

  43. What would've been more helpful by xRelisH · · Score: 5, Interesting
    might be a list of common typoes and also weird compile errors that often scare newer programmers. Here's are a couple that I know of

    if( blah = true ){ // common single equal sign mistake
    }

    if( someclass->someMethod ){//I know of some compilers that do NOT give you a warning when you forget to put brackets in a function call.
    }

    As for compile errors, one that ususally scares newer programmers is making a mistake in a header file that in return causes a whole lot of other errors. This happens when you forget to put a ";" in a class definition in a header file, then in the source file, you include "someheader.h" and then include "" below it, I've noticed a lot of compilers spew out odd errors that can very confusing.
    Another common compile error deals with mismatched curly brackets, editors like vim will point this out, but I know some 2nd year students here in Computer Engineering that still want to use Notepad and refuse to try anything else.
    Anyone know of any others?
    1. Re:What would've been more helpful by colinleroy · · Score: 2, Informative
      if( blah = true ){ // common single equal sign mistake Not so common in these days of modern compilers:
      $ javac test.java
      test.java:7: incompatible types
      found : int
      required: boolean
      if (i = 1)
      ^

      $ gcc -Wall test.c
      test.c: In function `main':
      test.c:6: warning: suggest parentheses around assignment used as truth value
      --
      blah
    2. Re:What would've been more helpful by Anonymous Coward · · Score: 2, Informative

      As for compile errors, one that ususally scares newer programmers is making a mistake in a header file that in return causes a whole lot of other errors. This happens when you forget to put a ";" in a class definition in a header file, then in the source file, you include "someheader.h" and then include "" below it, I've noticed a lot of compilers spew out odd errors that can very confusing.

      Here's something I've learned over the years:

      - Start compilation. Get a gigantic mass of wierd compiler errors.
      - Fix the first one and the first one only .
      - Restart compilation. Goto top of this list unless there are no more errors.

      Seriously, most errors are caused by the parser being off track after the first error. Don't sift through your entire error list trying to find the cause for each one. In most cases, it will be the first error.

      And for those who say "compilation takes far too long!": that's what make is for. And distcc.

    3. Re:What would've been more helpful by nmnilsson · · Score: 3, Informative
      ... and suggestions how to avoid those errors in the first place.

      E.g.
      if( blah = true ){ // common single equal sign mistake
      }
      could be rewritten
      if( true = blah ){ // the compiler won't let you do this
      }
      or simply
      if( blah ){ // if blah is used as a boolean flag
      }
      (I just finished reading "C Traps and Pitfalls". It contained many amusing errors, but it was very sparse on defensive coding advice.
      I wouldn't recommend the book. Read "Code Complete" instead, that's a gem!)
      --
      No sig to see here. Move along.
    4. Re:What would've been more helpful by dsplat · · Score: 2, Insightful

      - Fix the first one and the first one only .

      Actually, I fix the first one and any similar errors that I know I committed elsewhere.

      A corollary to this is:

      "When your code compiles cleanly, it is ready for testing and debugging."

      --
      The net will not be what we demand, but what we make it. Build it well.
  44. not stopping to think by pres · · Score: 5, Insightful

    While some thought is, of course, necessary I have definitely seen the problem with new programming students of thinking too much.
    Basically, they try to understand the whole problem fully before writing the first line of java or C. My feeling is that this is not possible for a new student. There is just too much. Rather you just have to write code at some point. Forcing yourself to try things in code is often the only way to really get started in your first programming language. (After the first one, you should be able to think as much as you want because you should have enough background not to get lost).
    I have actually noticed this problem more in girl then guys. Guys tend to rush right in and try to hack it while girls try to understand it fully first. Sometimes the hacking approach is just the necessary one. (Of course this then flips in the second or third CS course where NOT fully thinking through the problem hurts more).

  45. The choice of FONTS by Taco+Cowboy · · Score: 3, Insightful



    Many a programmer will give you tons of insights on what not to do, but everyone and their great-granduncle seem to forget that the use of FONTS is of great important on eye-balling bugs.

    Your example of the ";" could have easily caught if you use a font that makes stuffs like ";" "." "," "`" and so on FAT and OBVIOUS.

    And on more thing - ENLARGE the size of the font to a comfortable degree, instead of squiming your eyes to look for ridiculously faint dot.

    For programmers, although our brains are important, it's our eyes that have often been over-strained.

    --
    Muchas Gracias, Señor Edward Snowden !
  46. Suggestions for instructors.... by Chanc_Gorkon · · Score: 2, Insightful

    If the class is not a early class in the CS flow, don't place the focus of the course on simple documentation. Also, on a scripting class like Javascript, enforce what would be asked for on your job. Inline comments. Block diagrams or system flows are more used in industry then nitty gritty flowcharts and pseudo code. As most CS projects are too small to go beyond building just a flow, I can see why they don't use block diagrams.

    Classes should try to focus on teaching as much of the subject as possible in the time alotted especially if it's further down the prereq list. The subject should not be if you got your flowchart right! it should be if you got the program right AND knowing how you did it. Require the documentation, but don't let it weigh in heavy on the grade.

    In my current class, there are also group projects (in a web class no less). While a little hard to deal with, it's not too bad as that is the way alot of developers are meeting.....just in e-mail or IRC or what have you.

    In any case, as far as supporting others work, comments in the code and decent end user documents is all I ask.

    Also, alot of languages don't lend themselves to flowcharting...so why require it?

    Sorry, just venting on how far back in the times some instructors are! I spent the first 3 weeks of class learning basics....basics I learned 15 years ago.

    --

    Gorkman

  47. Re:Compiler Warnings by fireboy1919 · · Score: 4, Funny

    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.

    --
    Mod me down and I will become more powerful than you can possibly imagine!
  48. Advice from a student by miyako · · Score: 4, Insightful

    I'm a CIS student, about ready to graduate. I'd already been programming for several years before I started school (and never allowed my school to interfere with my education), and I've spent a lot of time helping my fellow students, and here is some advice based on what i've seen.
    Learn to love whitespaces. I don't know how many times i've seen people try to cram their code down as small as possible by removing every possible whitespace. A few extra spaces can really help you catch mistakes when your using a lot of nested parenthesies. ( ( (th) ( (i)(s) ) ) is much easier to read than (((th)(i)(s))) if your trying to make sure you don't screw up your parenthesies.
    DO NOT comment every line. Seriously. Comments are a good thing, but when you comment every single cin and cout, every single bracee and function call, then it can make it a lot harder to find what you are looking for. A good rule of thumb I tell people is to comment every line you have to think about for more than 30 seconds, comment every function and class, and comment every block of code that you have to spend more than 2 minutes pondering over.
    Learn to use your editor. Whatever IDE or editor you decide to use, learn to use it well. Learn to use the debugger specifically, but also get used to the environment. I don't know how many people I've helped who's problem was not with their code, but with an improperly configured IDE.
    READ Error messages. This sounds obvious, but I swear people don't read them, or don't think about what they could mean. I think a lot of this comes from programmign classes that teach people to memorize syntax, without giving them an understanding of what's going on at the machine level, or what the compiler is actually doing.
    If you miracously fix something, understand why. Students seem like they can not resist randomly moving code around, and sometimes this does fix things. If this happens, take some time to understand what you moved and why it might have fixed the problem
    Take Breaks. This one applies to everyone. I've seen a lot of good programmers go crazy over simple problems simply because they are too stressed out to think clearly. If you start to feel stressed, tired, or your mind starts to wander, then step away from the computer, have a cigarette or a cup of coffee, take a walk, and get your mind away from the problem for a bit. Even if you have a deadline, a 15 minute break can often save an hour of frustration at the computer.

    --
    Famous Last Words: "hmm...wikipedia says it's edible"
    1. Re:Advice from a student by stewby18 · · Score: 4, Interesting

      A few extra spaces can really help you catch mistakes when your using a lot of nested parenthesies. ( ( (th) ( (i)(s) ) ) is much easier to read than (((th)(i)(s))) if your trying to make sure you don't screw up your parenthesies.

      Personal preference, I guess. I was able to almost immediately tell that the tighter set was correctly balanced, but I had to spend a lot more effort to determine that the first set is missing a closing parenthesis.

      I can't help but wonder if your mistake was intentional humor, or unintentional irony.

  49. How about... by Bullseye_blam · · Score: 3, Funny

    When borrowing someone else's code to finish an assignment that totally stumps you... don't forget to change the variable names.

    -Bullseye

  50. Re:For the guys... by Wescotte · · Score: 2, Funny

    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!

  51. Don't compile now, diagram instead by Simonetta · · Score: 2, Interesting

    My profs insisted that we should diagram the process algorythym before coding.

    They recommended strict diagramming techniques like Warnier-Orr. They said use a white board with big erasures and little markers because large sections are going to be junk.

    Strict and systematic Warnier-Orr diagramming can be a real discipline.

    I've gone back to it in order to code very tight , time-dependent 50 nanosecond mulitple interrupt routines in assembler for microcontrollers and embedded systems. I've even placed the white board on the flatbed scanner to copy it when I've gotten that finally works in a walk-through (take the hinged cover off- it goes much easier.)

    Even after doing this..and then assembling and burning the code into the chip..and having the device actually function correctly..I still get the feeling that there is something stange and magical happening that I'm not aware of.
    One just sits down and tells oneself that, no, there's no magic here. You designed a complicated machine, you throughly tested a precise simulation, you built it, and it worked exactly like it supposed to because there wasn't any possiblity that it could not work like it was supposed to. It's just going through hundreds of precisely defined steps many millions of times a second...and gives the illusion of magic and sentinite intelligence. ..ramble on...

  52. Zero tolerance for errors by mcrbids · · Score: 3, Interesting

    I've been coding for some time very extensively using PHP. It, along with GTK is a good, high-level language that lets me get lots done, very quickly.

    In many cases, it will accomodate common errors, such as strings not being quoted, etc seemingly without complaint.

    However, I recently changed my strategy to one of "zero tolerance", which entailed me reducing the error reporting threshold to 0 (all errors) as well as defining a standardized error handler callback function. I spent about a month just going thru the existing codebase to quote all the strings, etc.

    However, now having done paid that price, I'm quite surprised at how often bugs that would have previously gone un-noticed pop out in clear view.

    Undefined variables previously translated to equal false now stand out as a mis-spelling. Database errors previously un-noticed suddenly highlighted and shown to me. Hiccups in the code previously shown to users now archived and hidden away so that I see them instead.

    It's made a HUGE difference - I'm more productive despite the appearance of having more to look out for!

    I also have a generic error() function defined that's really a wrapper for the error handler - so the error logging system now in place works for language errors and logic errors alike.

    It's awesome!

    --
    I have no problem with your religion until you decide it's reason to deprive others of the truth.
  53. Re:Advice from a fellow student by ZorbaTHut · · Score: 4, Interesting

    A friend of mine once had a large windowing class he needed to write. He was late on a project and basically needed it done Now. Or sooner. So he resigned himself to an all-nighter and got crunching.

    Round about 8pm, he realized he was getting overly stressed, and he still had about half the code left to write. So he decided to take an hour break, smoke some pot, and come back to the project after he was a little unwound.

    The next thing he remembers is waking up the next day. He had that dawning moment of realization that I'm sure all of us have experienced at one point in our lives - "Oh CRAP I screwed up" - and ran to his computer to finish the code as fast as he could.

    The code was finished.

    Several thousand lines, all commented, all readable even without comments. The interface was clean. The implementation was clean. It was finished.

    To this day, he has never remembered writing even a single line post-toke. He has also never found a single bug, and he's used that code quite often. Now, I don't recommend relying on this technique - but once in a while, it seems to work.

    --
    Breaking Into the Industry - A development log about starting a game studio.
  54. Develop a programming conscience by Viv · · Score: 5, Interesting

    I've gone back to school, and have noticed that I have something that makes me a much better programmer than my peers.

    Over the years, I've developed a little voice at the back of my head that speaks up every time I am having problems with code I've written.

    It asks me, "Is the problem you're having a result of a broken implementation, or is it the result of a design that lends itself to a broken implementation?"

    With a good design, the code is not only easy to bang out, but the good design will tend to prevent you from making errors in the implementation. With a poor design, the code is hard to bang out, and it actually tends to cause you to make errors.

    Develop this programming conscience. Constantly ask yourself, "Is my bone-headedness in the code itself, or the design?".

    This will make your life easier.

  55. Re:The best advice[sic]-off topic but by panurge · · Score: 4, Insightful
    Yes, take up a skilled trade, or preferably two, one of which is IT related. Most plumbers, electricians and carpenters are not capable of running a business because they lack the organisational and IT skills that are needed nowadays. If you are capable of doing comp sci and becoming a plumber, you could end up running Kohler...well, I exaggerate a bit but I think the point is valid.

    Rudolf Diesel, the inventor of the engine, graduated from University and then went and trained as a skilled mechanic. Isaac Newton could use a lathe by the time he got to Cambridge. And Alan Turing could machine his own relays. Apart from the career options, acquiring both academic and practical skills makes you a more rounded person, and thus more employable generally.

    --
    Panurge has posted for the last time. Thanks for the positive moderations.
  56. Way too advanced. by kahei · · Score: 4, Insightful


    As far as I can tell, especially with people from an academic background (PhDs! argh!), this guide is way too advanced -- something like this might be more useful to start with:

    -- Do not keep the entire project in /tmp
    -- Use source control
    -- Run the code before delivering it
    -- NOT JUST ON YOUR OWN WORKSTATION, BUDDY!

    Then, from that one could work up to 'try and ensure it is possible to install the software by some deterministic process', and only then would it be worth actually starting with actual code...

    Well, they learn eventually I guess, in most cases.

    --
    Whence? Hence. Whither? Thither.
  57. Re:Compiler Warnings by dcam · · Score: 2, Interesting

    There is actually a better way of getting rid of these rather than contaminating your code with unecessary #includes. Check this out. Basically add the same pragma command to YVALS.H which is in the include dir for the Visual studio installation.

    In case you are wondering whether you are really going to break something, the error message relates to the debugger not being able to handle >255 chars.

    The problem with this warning message is that it can obscure real error & warning messages.

    --
    meh
  58. People never coded properly by Cid+Highwind · · Score: 3, Insightful

    Every /. story about programming seems to bring this tired meme out of the woodwork yet again. There never was a time when people wrote apps that do almost as much as current software in a tiny fraction of the disk and memory space.

    What people forget is that old games and GUIs only had 1/50th of the pixels (and 2 of the 16 million colors) a modern display has to contend with, that their old 100KB "word processor" was really a stripped-down text editor with 3 fonts and no spelling check, DOS could fit on one floppy because it was really just a program loader and a half-hearted attempt at a shell, and "searching your filesystem" meant rummaging through desk drawers for a floppy disk! Programmers could fit apps of the time into tiny memory spaces because their programs didn't *do* much of anything, not because they had some magic ability to "code properly" that's lost on programmers of today.

    --
    0 1 - just my two bits
  59. Suggestion for Instructors by hussar · · Score: 3, Funny

    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.

    --

    Bureaucracy loves company.
  60. MAVADDAT SPEECHLESS!!! by Trepidity · · Score: 5, Funny

    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!!!!!

  61. FOR and WHILE loops are for babies by nmb3000 · · Score: 3, Funny

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

    --
    "What do you despise? By this are you truly known." --Princess Irulan, Manual of Muad'Dib
    /)
  62. Re:I prefer relying on my tools (part 1). by Yaztromo · · Score: 2, Insightful

    (Posted in "Code" so as to get the formatting right).

    "Since modern code editors force tabs or spacing in these scenarios, I find comments like "// end if" to create more noise overall."

    It's additional meta-information. And if you're working in a group where each developer gets to choose their own editor (such as in virtually any Open Source project on the web), if one user sets their tabstops to something different from the rest of the group, and/or someone starts using spaces instead of tabs (or vice-versa), you wind up with indentation problems.

    For example, you're using tabstops every 3 characters, insterted as tab characters. Some guy working with your file is using 4-space tabs, inserted as spaces. They need to add a line of code below an existing line starting at column 12 on their display (ie: three tab stops in your editor). So they hit tab three times. Looks correct to them, and the editor permits it, so they save the file and fire it back to you.

    /You/ look at the newly added line, and see that where the previous line starts at column 9 on your display, their newly added line starts at column 12, one whole tab-stop extra.

    Or how about if you're always working with only spaces (ie: tab is set to insert three spaces, and not a tab character). /All/ of your sources are using this. Someone comes along and uses an editor which inserts a tab character instead of spaces, with a 3-character tab stop. They work on a file, and check it back in.

    Developer number 3 checks out the file, and for whatever reason always uses the space bar instead of the tab button for indentation. Because of this, they never bothered to change their editors default tab stop of 8. They load up the file, and suddenly it's a mess: the space-stopped lines are still indented in multiples of threes, but the lines containing tab characters as inserted by developer number 2 are now indented in /multiples of eights/! If developer number 2 didn't just add new functions/methods/etc. to the end of the file, and they added lines inside existing blocks, the code readability is now totally fubar.

    And yes, I see this happen all the time, both inside and outside commercial development. You can mitigate this through education and enforcement, but anyone who does any real development work has seen this happen.

    Adding what you call /noise/ provides structure, and allows you to determine which close braces go with what statements. It is due to this sort of potential confusion that many non-C derived languages actually use specific close statements for each different type of open statement (ie: Pascal, Modula-2/3, Ada83/95, shell script (although for a somewhat different reason).

    And in some environment, it can be exceedingly important if you're nesting a large number of blocks. Take this simple Java example, for example:

    // A fragment of Java
    class MyClass {
    method someMethod() {
    for(int i=0;i<100;i++) {
    if(i<50) {
    synchronized(this) {
    try {
    ...
    } catch (Exception e) {
    ...
    }
    }
    }
    }
    }
    }

    Here there are six closing tags in sequence, in short, concise, and valid code. It doesn't take much to scroll the top few lines off the top of the screen (I'll get to why your refactoring comment is invalid in a second). It is exceedingly easy to introduce errors here, such as inserting code in the wrong place, such as:

    class MyClass {
    method someMethod() {
    for(int i=0;i<100;i++) {
    if(i<50) {
    synchronized(this) {
    try {
    ...
    } catch (Exception e) {
    ...
    }
    }
    }
    doSomethingElse(); // Oops -- not supposed to be inside the for statement
    }
    }
    }

    This is very easily mitigated through the mechanism I've already demonstrated:

    class MyC

  63. Heh, I think this may be wishful thinking... by raehl · · Score: 2, Insightful

    You only catch bad cheaters, by definition.

  64. this copy thing seems... by jlemmerer · · Score: 2, Funny

    ... to be the microsoft way. did you copy it from them?

    --
    ".Sig Stealer" was here
  65. They forgot by coolgeek · · Score: 2, Funny

    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.

    --

    cat /dev/null >sig
  66. plagarize code from Many.... integrate and deliver by Gopal.V · · Score: 3, Interesting
    Like we used to do in college :)

    Take a program done by 3-4 people , pick the best parts, integrate

    Macros from one, sortings from another, recursion from yet-another...

    It's a lot less hard than writing it yourself and the result is often better than the originals .. Most of all, you actually learn from other people's mistakes .

    Even after getting a job, I find that this is a much more stable way of programming newish things -
    "find a lot of similar things, pick the best strategies & adapt".

    Btw, these days - that's called "Research" :)

  67. Always blame the compiler or even the computer by ArcticCelt · · Score: 3, Informative
    He forgot to mention that you should always blame the compiler or even the computer for any bug.

    Say things like: Ho! That computer in the computer lab is so crippled, I am sure that my code would run fine on a fresh Windows install.

    --

    Yahh, hiii haaaaa! -Major Kong, from Dr. Strangelove
    1. Re:Always blame the compiler or even the computer by Anonymous+Brave+Guy · · Score: 4, Insightful

      The great irony, of course, is that at some time in your programming career you probably will come across a genuine compiler bug, and no-one will believe you...

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    2. Re:Always blame the compiler or even the computer by Phisbut · · Score: 3, Interesting
      at some time in your programming career you probably will come across a genuine compiler bug, and no-one will believe you

      Oh so true... I once hit such a bug (be it compiler, OS or whatever, I didn't investigate that deeply), I was compiling an OpenGL/Qt application with g++ on an IRIX platform, and something just wasn't right... One of the most basic ways of debugging being sending output at just about every line of code, here's what I saw on the console :

      SomeClass::SomeClass() // default constructor
      {
      cerr << "Beginning constructor\n" ;\
      myAttribute = 5 ; // myAttribute is an int
      cerr << "myAttribute = " << myAttribute << endl ;
      // [...] rest of the constructor
      }

      ... and then, I got an output of "myAttribute = 0"...

      I lost about 2 days just trying to find that stupid "bug", but damn did it feel good that I could actually prove I was not wrong on that one.

      I never knew exactly what caused it, but fixing it required to scrap 2 files (declaration and implementation of the class) and write it again.

      Compiler bugs *do* exist, you just need to find a way to prove it to your boss.

      --
      After 3 days without programming, life becomes meaningless
      - The Tao of Programming
    3. Re:Always blame the compiler or even the computer by Mr+Z · · Score: 2, Informative

      Did it ever occur to you, at this point, to:

      • File a bug report with the vendor of the compiler?
      • Examine the assembly output of the compiler and verify that the compiler output bogus code?

      I find that the believability of compiler bug reports goes way up if you actually look at the compiler's output and can say "See! There it is! It's wrong!" And once you do that, you should point it out to the vendor so they fix it. (I say all this as someone who actually has spent signficant time filing compiler bug reports of my own.)

      Finding a bug and just kluging around it might be a nice short term expedient, but it doesn't increase the long-term quality of the tools.

      --Joe
  68. Christ, people.... by billybob · · Score: 2, Interesting

    Every response to the parent has been negative.... "That's horrible advice" etc etc. However, I find myself agreeing with the parent, as long as you have atleast one year experience programming.

    For most of the time you're writing code, what you have should not be compileable. Well, doesn't need to be. Since you (hopefully) are doing things top-down, at first you're going to have a lot of empty functions and comments.

    How could you disagree with this statement? This is basically writing pseudo code, which is how most things should be done. It's just an OO approach. Write code that utilizes functions / class methods that dont yet exist, this lets you create your logic. Then go in and write the actual methods, which eventually will make your logic work. OO approach lets you focus on logic and fiddle with technicalities later. This is how it should be done. :P

    --
    Joseph?
  69. Re:Don't bother testing. by AVee · · Score: 3, Insightful

    Of course, I'd very very thoroughly stepped through every code path by hand.

    So where is the, not testing, part? Dry testing is testing as well. And not the worst way of testing, imho.

  70. Re:Compiler Warnings by KontinMonet · · Score: 2, Interesting

    TFA may be ironic but it might help more if it was sarcastic. The number of sites at which I've worked where Warning messages are set to Ignore is ridiculous.

    At one place, so many warning messages were being generated that when I eventually got a decent developer on board, after writing some scripts and working hard to reduce the number of messages, he got the overall compile time to go down significantly. Of course, despite my 'petty Hitler' rantings, most of the team decided not to fix the cause of these errors and the compile time started creeping up again. The arrogance of these guys was palpable, they had no intention of improving, they were, after all, the A-team (or so they said). I eventually moved on to running another team in another part of the company - who were prepared to listen (or were more afraid of me maybe) and, with other processes, productivity shot up over the course of a few months.

    --
    Did he inhale?
  71. Re:Funny you should bring this up.... by jsebrech · · Score: 2, Insightful

    On the other hand, with his code layout, it's clearer where the if starts and ends, and it's clearer to what the else is associated.

    It's clearer for you, because that's how you got used to coding. The other way is clearer to me, because that's how I got used to it.

    With regards to the vertical space wastage, this is just my personal opinion, but there is always code that is self-contained but doesn't fit on the screen in one go, and the more of it you can fit, the easier debugging becomes. There's a reason we don't use line-by-line editors anymore, it's because seeing more of your code at once actually helps you code.

    Regardless though, this is a matter of personal preference. It's my personal opinion that those using the newline before brace style are making life harder on themselves, but I'll respect them if they respectfully disagree with me, and let them be.

    Meanwhile, let me state that any project where more than one person is working on the code needs a coding style guide, including how to name things. I'd code the other way if the style guide told me to, because it's better to have code all in the same style than to protect your own personal opinion fiefdom.

  72. Re:Advice from a fellow student by Anonymous Coward · · Score: 2, Funny

    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.

  73. Let me expand on #1... by gosand · · Score: 3, Interesting
    1. Get a software engineering book, and study the concepts of software design. Even if you're just doing some small little "print a schedule" type assignment, thinking about how you would design a bigger project will help you.

    AMEN BROTHER!!!

    Better yet, take a software engineering course if it is offered. Granted, it was back in the early 90's when I was in college, but my software engineering course was what got me my first job out of college with a big company. I took my senior project with me on my interview and showed it to the first person I talked to - she said "show this to every person that interviews you today". There was ZERO code for this project. What it did have was requirements, design, budget, test plans, mock-ups, documentation outlines, etc. All the stuff that is done outside of actual coding. This is how things work in the real world. It was the most important class that I took in CS. I probably won't be coding in Pascal any time soon, but I still use the principles I learned in that Software Engineering class.

    I will admit that it has been a while since I did any hardcore coding, but if you are doing any kind of project, design it first. Draw pictures. You'd be surprised how much easier it can be. I am still amazed after working in the industry after 10+ years how little software engineering education a lot of coders have. And there is a HUGE difference between a coder and a software engineer. Learn the concepts early and try to use them as much as possible. I couldn't write requirements to save my ass in college, but just the fact that I tried, and knew where they fit in the process made a huge difference. Do you know what a testing organization does and why? Where I work, we just got a set of issues out of a "lessons learned" session for our release that just went out. Many of the questions that came out of our development group were along the lines of "What does our QA group do, and why?" Some of these people have been coding for 10 years or more, and they don't understand why we have a QA group (QA and testing, which aren't the same thing)

    --

    My beliefs do not require that you agree with them.

  74. You'd like Knuth's "Literate Programming" by hildaur · · Score: 2, Insightful

    If you like this approach, you might want to take a look at Knuth's "Literate Programming." One place to start is http://www.literateprogramming.com/

    In either case, one needs to remember that too much can be as bad (or worse!) than too little. In real life, you may not always be the one to edit the code, and if someone edits the code but doesn't update the commentary, you can get into real trouble.

    -Hil

  75. Annoying bugs by Kombat · · Score: 3, Interesting

    Hahah, I know exactly how you feel. I wasted 2 hours on what should have been an extremely simple C assignment in university one day. Back then, we did our C/C++ assignments on a shared Solaris server, working on dumb terminals in a lab. I was getting some kind of strange exception with my C macros. So, I created a "test" program and copied over the guts of the logic of my app, so I could re-add the functionality piece-by-piece until my test app broke. This would allow me to isolate the code that was causing the problem.

    Only one problem: my "test" app didn't appear to be doing anything. It would run fine, with no error messages, and then exit quietly. In fact, it was producing no output at all. I began removing code, and adding printf()'s, desperately trying to get my app to say something, anything. After a couple of hours, I had stripped my "test" app down to little more than a "Hello, world" app, but it still wasn't producing any output! I would just type


    dragon:/home/kombat/> gcc test.c
    dragon:/home/kombat/> test
    dragon:/home/kombat/>


    Can anyone spot the problem? Anyone?

    It turns out that "test" is actually a built-in system utility for regular expressions, used in scripts. That was the day I learned what my $PATH means, why /usr/bin is at the beginning of the $PATH, and how one can use ./test to make sure that one is actually running the program in the current directory, rather than the system utility with the same name!

    That day ranks as one of my most stressful, and yet most educational, at university.

    --
    Like woodworking? Build your own picture frames.
  76. Value of Readability by justanyone · · Score: 2, Insightful


    THE MOST IMPORTANT THING FOR YOUNG PROGRAMMERS TO LEARN IS READABILITY.

    Yes, code must work, it must error check and be stable. Good design is an obvious requirement. But, too many young programmers don't know the true value to business of code readability. I'm a 15-year veteran primarily in C, C++, Perl, Java, and alas, Cobol. I've seen crappy code for years as a contractor, coming in to fix problems or add features.

    The statistics on business costs bear me out. Nearly 50% of the cost of a program is incurred during the long in-use / maintenance phase. There are definite rules for making code readable and they should be taught early.

    Practice during programming classes should include:
    * Code reviews - other people looking at your code;
    * Code reviews - reviewing other people's code and asking lots of questions;
    * Style guides - rules re: what coding style (where to put curly braces, for one) to use on a project are common, be prepared for them;
    * Simplification paradigms - stuff like avoid do_while loops since they're seldom used and often just confuse people;
    * Reliability lessons - lessons like don't use while(1) loops with breaks, rather for(1..n) with an overlarge n and subsequent test if N got big to know if things failed;
    * Max Subroutine sizes - too often violated but a bigger deal than you think;
    * Global variable minimization - sometimes it does make it simpler to use a global variable, just keep it to a minimum;

    Lots of these rules apply. SIMPLIFY! SIMPLIFY!
    It speeds up everyone's life.

    --Kevin

  77. True story by markov_chain · · Score: 3, Funny

    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.

    --
    Tsunami -- You can't bring a good wave down!
  78. Same thing happened... by SoTuA · · Score: 2, Interesting
    On the #1 assignment, there had been rampant copying, and the professor was mightily pissed off. Usually, when you catch someone cheating on an assignment, they get a 1.0 score (in a scale between 1.0 and 7.0) and a warning to frikking behave, although the rules say that every cheater must be sent to the Rector and get a "sumario" (kind of a "trial", don't know how that translates) whose biggest consequence is get kicked out AND banned from the biggest universities in the country for two years. Since that's really harsh, most teachers don't send people to sumario unless there cheating is way overboard (i.e. sending in someone to do a test for you or the like).

    It happened that this time, the professor had been appointed as "Director de la Escuela", and, as an official of the Uni bureaucracy and not just "a professor", he was bound to apply the rules to the letter. So we had to (I was TA) hand out a sheet of paper during the first test and I told them "people, we're onto you. We have tens of cheaters (from a 100-people class) indentified in assignment #1, and this time, you are S.O.L. because the prof is ALSO the director, so he's bound to send you straight to the rectory, instead of marking you with the customary 1.0. In this paper, you can write your name if you admit to copying the first assignment. You'll get an 1.0 score on that, and at the end of the course you'll have to do a "live assignment" in the computer lab with the prof perched at your shoulder to prove that you learned something in this class.".

    Almost all the identified cheaters turned in, and a hefty quantity of unidentified cheaters turned themselves in, and even some people turned themselves in for the #2 assignment!

    Another funny one, at the final examn of a course, when I (I was TA) said "ID will be requested while the test is in course, please place your University Card in your table next to you". I had just finished saying this when I saw one of the students jump out the window (it was a 2 meter drop to the grass outside). Never figured out who he was subbing for. (Whoever he was, he failed the class, since we customarily let the students who have an average such that an 1.0 in the final will still give them a passing grade keep their average and skip the final)

  79. They Missed One Thing by $criptah · · Score: 3, Insightful

    Computer Science is a good major to be in. It is useful, hard and interesting at the same time. However, given the fact that IT job cuts are on the rise, students should learn more things than just coding.

    I am a recent CS grad. I work in the field and yet I am thinking of getting a second degree that is not related to computer science because I realized that in several years developers who know only one thing -- that is coding -- will become extinct. What you need to teach CS students is how to develop valid and correct solutions that can be used by real people and businesses. These solutions must be well designed first; then developed. If I got a cent for every piss poor designed program that I have seen in my life, I'd be Bill Gates :)

    Developers solve problems with code; however, just because you have an ability to write a program does not make this program a valid solution! I have noticed that there are too many people with excellent software engineering skills that are simply out of touch with reality and its business side. If your "cool" program does not solve a problem it is absolutely useless in the real business world (the world where you get a pay check for what you do).

    Despite being relatively young, I have been employed in the field during all downturns. I managed to survive using only one rule: you must come up with solutions that are valuable for customers who are willing to pay for it. Unfortunately, many of the recent comp. sci. grads do not understand this rule. Instead of focusing on real life and its business needs, they spend their time learning languages without even knowing what these languages are good for. Then they use wrong tools for wrong tasks. My favorite example is my friend who used J2EE to build a site that could have been (and should have been!) done in PHP. He spent half a year on the fucking thing just to realize that a simpler solution could do everything that he wanted!

    Then there are people who run into terrible coding problems because their design is flawed. For some odd fucking reason people never think before they start implementing. I use one great rule: software engineering does not provide efficient solutions for some of the problems. Period. Too many people jump into coding without even thinking about the problem. They waste their time on something that can either be done manually with lower cost OR cannot be done at all. The worst thing is that most of these people are afraid of throwing their initial design away and starting from scratch...

    With this in mind, here is what I think every comp. sci. student should know:

    How to meet business needs with software engineering. How to "read" requirements and come up with solutions that meet them.

    How to realize that your design leads to implementation problems and when to throw such a design away.

    A well-written program is good. A well-written program that meets customers' needs is better.

    How to use a right tool for the right task.

    How to become employed and stay employed.

    How to use computer science in various aspects of real life. When I am talking about real life, I am talking about something useful that can be actually used by people. I found out that this can be achieved by taking a second minor or getting a second major that is not related to technology.

  80. Cheaters Always Prosper by Anonymous Coward · · Score: 2, Insightful

    Yeah, well if the college actually followed through and expelled plagiarists maybe people would think twice before doing it?

    Over half of my networked operating systems class was caught cheating on a machine problem (write a UNIX shell with job control and I/O redirection). The professor announced this during class and said whomever came forward wouldn't face any punishment. The college handbook clearly says that this is an offense that may result in explusion from the University. What happened? Not only did the University not expell any of these students, the professor wouldn't point them out in class so the rest of us knew who they were.

    During an exam for a linear algebra class, I saw students pulling crib sheets out of their backpacks and placing them between their feet during the exam. Surely the proctor saw this (~35 students in the class), but nothing was done.

    If colleges want to cut down on cheating, they need to start enforcing their own policies.

  81. How Pertinent by vivin · · Score: 2, Informative

    Coding Style

    One thing I've noticed, well at least the university I went to (Arizona State - ok I've heard all the jibes), is that there is not as much emphasis on coding style as there is in just getting the assignment done. This article is essentially talking about the bad habits that students develop, and mostly this is due to insufficient emphasis on good coding style. I had been writing code for almost five or six years before I started college, so it was second nature to me. However, some of the people I met hadn't written a single line of code in their life. They were genuinely interested in CS (but there were some who were in it just because "CS people make a lot of money"). Most first year programming classes that I know of, just give you to tools to the language without telling you how to use it well. It's like you know English, but does that mean you can write a really good Story, or an Essay that is grammatically correct all the way? No, it takes training - and that is what I think some of these first year classes fail to provide. Sure, later on in your CS/CSE degree you may come across a professor/class that emphasizes good coding style, but by then some of these bad habits may be so ingrained. Like for example, I have seen C programs without ANY indentation. How terrible is that? Whitespace is awesome - use it liberally.

    I was lucky enough to have a good professor my first year in college. I rememember that he eschewed the use of "goto's" (ok I have heard enough debates on this). His reason was that many students simply did not know how to use them right, leading to the inevitable spaghetti code. Also since we were using Java, it wasn't possible anyway.

    Anyway, my point on Coding Style is that first year classes should emphasize that point so that students can learn to write programs that are easy to debug and document.

    Proper Specs, Writing Algorithms, Documentation, and Knowing what your code does

    I can't even begin to say how important this is. The major problems (some) Engineers have is that they write terrible comments, or none at all, or cryptic ones. I have come back to code that I wrote months ago and I have had a hard time deciphering what it is that I wrote. Documentation may seem like a pain, but in reality it makes the maintenance of your code more effective. Also, in an industry setting if someone else has to come along and look at your code, it makes it easier for them. How many times have you had to go over someone else's code and found no comments, or terribly obvious ones like:

    i++; //increment i

    I took an assembly language class in my sophomore year, and another one in my junior year - they were required courses. The prof in the first class was a former student of the prof in the second class, so they had the exact same methods. They had three main emphasis points:

    1) Algorithm
    2) Program Size
    3) Documentation

    Both these professors gave our excellent specs on our assignment (something more professors should do). They were extremely detailed and they exactly told us what was expected. In addition to this, they graded on program size and execution time. This prompted (most of) us to create efficient algorithms. I have to say that usually I'd just jump into the code and start coding, with a hazy algorithm in my mind. This time, I really had to sit down and come up with an algorithm. I discovered that it made my coding process much easier. It's better looking at your algorithm in paper and the comparing it to your code than doing it in your head. Their final emphasis was on documentation. 20% of the points for a lab assignment was for documentation. We had to provide an introduction/user's guide for the program. By reading it, any person should know WHAT the program does. Secondly, we had to provide an internal overview. This is esesentially the description of the algorithm that we use. Any person, by reading the internal overview, should have a good idea o

    --
    Vivin Suresh Paliath
    http://vivin.net

    I like
  82. Advice from an Employer by ewanrg · · Score: 2, Interesting

    OK, this article pushed a couple of my hot buttons since I get to see the results of the "good" schools during interviews almost every week (and if you're willing to live in San Antonio and know Hibernate, go ahead and email me).

    First, because of all the concern about "cheating" I often spend weeks getting recent graduates to work on teams. The idea that sharing and collaborating on code is "OK" is so foreign to them, that I get people who won't show their work to anyone.

    Next, because they have learned that the instructor "has the answer", they will come up to me and ask me how to solve the problem I asked them to work on several days ago. I work at a research institute, and if I knew the answers I wouldn't have bothered asking in the first place. I can help you figure out ways to find the answers, and suggest sites to look for examples of code that might solve similar problems to use as a guide (oh, but there's that cheating problem again), but if I have to figure out the answer for you, then why am I paying you a salary in the first place?

    Finally, and I think I've seen this a few times in this discussion already, there's people skills. No program seems to bother to teach folks how to talk in front of a group, and if they do it's to tell them how to cover their Powerpoint slides. Folks, if I can read (and I wouldn't be where I was otherwise), I don't need you to recite your slides. I need you to tell me what you couldn't put on them, or to expand upon the couple bullets you have on each.

    Sorry, but when I see how what people learn in school makes them start out on the wrong foot in the "real" world, it does get a little upsetting.

  83. Re:The best advice[sic]-off topic but by Politburo · · Score: 2, Interesting

    Most plumbers, electricians and carpenters are not capable of running a business because they lack the organisational and IT skills that are needed nowadays.

    Nice subtle dig at manual laborers. Most carpenters, etc., run their own businesses, and do quite well, so I'm not sure where your observation comes from. You don't need IT to run a carpentry shop or install some pipes.

    If you are capable of doing comp sci and becoming a plumber, you could end up running Kohler...well, I exaggerate a bit

    You exaggerate a lot. Big companies no longer use people familiar with the market for management. They use managers with MBAs. The days of coming up from the mail room to the board room are gone.