CS 3460 Homework 1

Objectives

  1. To learn to distrust code on the Internet.
  2. To learn to read other's code and to evaluate it with discernment.

Questions to think about (not to turn in)

Here are some questions that I want you to begin thinking about. These are not to turn in, just to think about and perhaps discuss with others.
  1. What does it mean for code to work?
  2. Can a program be "correct" and still be poor?
  3. Can a program be "incorrect" and be good?
  4. What makes a program good? an algorithm good?

Background

This semester, we will look at different data structures and different algorithms for problems. We are going to see some really cool techniques for solving problems that may not be the most intuitive or the most common way that people solve the problem. Your textbook will claim these techniques are better in many ways - especially with respect to time efficiency. Because we are learning ways that are different from the way the average programmer might approach the problem, our textbook should be our first resource.

Some of you may have seen the Internet site, codingbat.com or javabat.com. It is a site for students to learn about programming. Students are given short methods to write to solve particular problems, and then the site tests the methods on a few cases. If the method passes all the test cases, a green check is given for feedback. Javabat also allows students to send the results of their work to their computer science teachers. What an easy lab for teachers to create and grade! However, we found that people were posting solutions to the Javabat problems on the Internet, and some students just were searching for solutions from the Internet and were copying them. The way we discovered this was that students were finding strange, not very good, or even wrong, solutions to the problems that somehow made it through the Javabat test cases.

This semester I want to discourage students from using code from the Internet. One reason is that it is cheating - the students are passing off copied work as their own. Another reason is it defeats the whole purpose of the assignment which is for the student to learn how to solve the problem. A third reason is that I believe the majority of the code on the Internet is of extremely poor quality.

There are good reasons to search the Internet for code - to find examples of how to use a particular feature in a language is one example. For this class, anytime you use code from the Internet, I want there to be documentation and citation in your code giving credit to the site you found the code.

Assignment

Find and print off (or type in) the solution to one of the Javabat exercises online that in your opinion is "weirdly" written. Pick a method where the author claims the method works, but there are some real issues with the code. Give a citation for where you found the code, and also describe what you found objectionable in the code.

Have fun. Ideally, the method you find wouldn't work on all inputs, but somehow they managed to get it past the test cases on the codingbat site. However, it is also OK to find solutions where the authors calculated values they didn't need - used loops that were unnecessary, or in some other way, did something ridiculous.