Friday, May 15, 2009

Copying programming homework

Before I start telling you the story which led me to write on this topic, I feel I'm obligated to reveal the main idea of this post:
In order to copy programming homework, you mustn't be a dumb fuck. (And a few ways to avoid being one)

And now the story. I have a colleague (let's call him John) at work who also checks programming courses homework at my college. Our college is really harsh about students copying programming homework (you can xerox algorithms homework, but programming is a big no-no).

One day John gets an email from one of the students claiming that he has submitted the last exercise but in the grades sheet it was marked "Wasn't submitted", so he demanded from John to check the issue. John checked his college email inbox to see if he has overlooked the poor guy's exercise. Surprise! The guy indeed sent him a programming exercise that week. Why wasn't it graded then? Well, when he opened the exercise to check it (as he was sure he overlooked it the first time) he saw that the name and the ID number at the top of the source code files were those of another student, not the one who submitted them and demanded a recheck. The moron copy/pasted the exercise from another student and didn't even change the name on it.

This is a true, although a bit extreme, example of a dumb fuck copying programming homework. If you want to avoid being caught in such situations, keep reading.

Two inputs to the beginning homework copier:
  • It's very hard to make copied code completely unrecognizable.
  • It is almost always easier (and more productive, and more fun) to write the program from scratch than trying to rewrite it for the pure purpose of making it unrecognizable.
If you don't mind the inputs, and you still want to copy someone else's code, you should at least put some minimal effort in camouflaging it, as you don't want to offend the intelligence of your exercise checker. You want to show him that you at least tried :D

Camouflaging equipment and techniques:

Equipment:
  1. Get yourself a descent IDE (I recommend NetBeans), as it enables advanced Find/Replace (regular expressions, refactoring, etc)
  2. Or at least a descent text editor (Notepad++ for windows. Ubuntu comes with Gedit)
Techniques:
  1. Change the name, the ID number and any other personal information that shows unambiguously that you are not the real owner of this code. Otherwise you're a dumb fuck and the rest of the techniques are not going to help you.
  2. The basic and most straightforward thing to do is rename your classes, functions and some vars. In the text editor you simply do Find/Replace (usually in the Edit menu). If you're not using an IDE you're gonna have a headache with Java classes as you need to rename all the files which contain those classes. With an IDE you can simply select a name of a class (or a function for that matter) right click > Refactor > Rename. And tada! You have your class/function/variable renamed on every reference to it, no matter where in the project.
  3. Change indentation, change comments. In an IDE or an advanced text editor (which supports regular expression or at least Find/Replace) It's really easy to do both. Remove all comments: Find regex "//[.]+\n" and replace with "\n". After all comments removed add yours in random order (remeber to remember what things do in general). Change indentation: Find regex: "\n[\s]+{" and replace with "{", or vice versa.
  4. Change for to while and while to for. Anything you can do with a for loop you can do with a while loop, playing a bit with those might make your code look a bit different. While to For translation example.
  5. Change temp variables to direct function call and vice versa. If you see too many redundant temp vars you can cut their count by by putting the calculation they hold directly to where you'd put the variable later. Sounds blurry I know, here's a code example.
  6. Use functions instead of in-main code and vice versa. Take pieces of code that perform some action and put them in a function (that involves some work compared to previous techniques). Or take some function and replace it's every occurrence with it's code (also takes some work to make it work). Make sure it's not an exercise dealing with functions before you remove them - otherwise you're a dumb ass!
These were just a few tips on how to make your code keep it's initial functionality, but resemble less to it's original. Please note that the tips provided arn't for code efficiency, but solely for the purpose of making it less recognizable!

As always questions, comments and slander are most welcome!

5 comments:

  1. LOL :)

    Funny one, and very informative.

    Gustav

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hmm, you know the things you descused in this post reminds me about paraphrasing technique. It is funny that it seems possible to "paraphrase code" getting the same result.When I was studying in college used this service http://www.programmingassignment.net/your-spirit-animal-programming-language-what-its-like/ to deal with a homework I wasn't able to find a solution for. There is a good article on programming language choose now.

    ReplyDelete
  4. It is really wonderful topic to find patch work paraphrasing centers. They are giving best rewording online centers shared instructions and reviews. Every point will help us to have great instructions.

    ReplyDelete