CISC370, Homework H04, Summer 2007:
OOP and TDD practice

Due: Thursday, 07/05, 11:55pm

Introduction

This exercise builds on the work you started in class on 06.19, developing a class and JUnit tests for that class. In class on 06.19, you selected a class, and two attributes of that class. Here's what you came up with:

Joel M: Hockey: Team Name, Coach  
Kirsten: Movie: title, director
Steve: music: artist, song
Joel B: Baseball teams: City, Name
Will: Frisbee: weight, radius
Ben: Car: type, mpg
Brennen : anime, title;number or episodes
Doug: Cell Phones: Provider, Model
Jin: Game: Title, Genre
Rob: Country: Continent, Capital City
Mike: Shoes: Make, Size
Dan: Bonsai: Species, Age
Blake: Baseball Players: Name, Position

Here's what you'll do with these. First, you'll finish up whatever you didn't finish from the in-class work on 06.19—that is, doing test-driven development of a class with a constructor for the two attributes, and setters and getters for each attribute. You'll then write menu driven program that reads in a file of instances of your class, and allows users to search that list either by the first column, or the second column. We'll extend this program in future weeks to add more options to the menu. (More detail is provided below.)

 

You may collaborate—same rules as for H02

Of course, your collaboration is somewhat limited by the fact that you have two different topics. You may, however, collaborate on such elements as the basic outline of the menu driven program, the code to open the file and produce an error message if it can't be opened, code to read the lines and parse them, etc.

Required Reading

Java Extreme Programming CookbookChapters 1-4 in Java Extreme Programming Cookbook.

What you need to do

Write a menu driven program that takes one command line argument: a filename containing values for instances of this class. The file should be in a format that is read in by most common spreadsheet programs: namely, comma separated values, with a header line: For instance, for Kirsten's topic, the file might look like this:

title, director
The Godfather, Francis Ford Coppola The Shawshank Redemption, Frank Darabont Pulp Fiction, Quentin Tarentino Schindler's List, Steven Spielberg ...

Make your file contain at least 10 instances of your class.

You'll have trouble if any of your instances contain a comma. For example, the following may cause a problem:

...
Lock, Stock and Two Smoking Barrels, Guy Ritchie ...

In practice, this is usually solved by enclosing the value in quotation marks, thus:

...
"Lock, Stock and Two Smoking Barrels", Guy Ritchie ...

Choice Point Opportunity (25 pts): You aren't required to solve the "embedded comma" problem for this homework assignment. However, if your code can address that issue, and you illustrate that in your testing, this is worth 25 choice points. To claim these choice points, put a link on your choice point plan page called [07J_yourusernamehere_H04], and on that page, explain that you are claiming the 25 choice points for solving the embedded comma problem, and write a brief explanation of how you solved it (with some code excerpts, and a link to your full code), on that page. To get the full 25 choice points, it is not enough just to write the code—you must also provide a clear explanation.

The program should try to open that file, and produce an appropriate error message if the file cannot be opened. The program should then read all the values in the file into some data structure that will allow you to search for values. For example, if your class is Movie, you might use an ArrayList object that contains Movie objects, i.e. ArrayList<Movie> object. There are other possible choices as well, including HashTable, Map, HashMap, and others. You may want to read the JavaDoc for those, and decide which is most appropriate. (Chapter 16 in HFJ may be very useful—though it is not part of the assigned reading, you may want to read ahead!)

For this assignment, you'll get full credit for the assignment itself if you choose a data structure that "solves the problem"—i.e. if your program "works". For that purpose, an ArrayList<Movie> (for example) will be fine.

Choice Point Opportunity (50 pts): If you can find a better data structure than ArrayList<Movie>, use that in your program, and write a clear and convincing argument that your choice is better on a wiki page called [07J_yourusernamehere_H04], you can earn up to 50 choice points. Again, it is not enough to do the coding. You must also write a clear and convincing argument. Spelling, grammar, formatting and clarity all count. These choice points may be shared by up to two people, working together (i.e. you both get the full points awarded---you don't have to "split them" between you). Again, Chapter 16 in HFJ—think about it!

You also need to follow the deployment model from H03

That is to say,

You'll need to adapt this model to some things that are different about this project, vs. H03. For example:

You may find that you need to read over the Ant Documentation, and Chapter 3 in the Java XP Cookbook textbook to actually be able to figure out how to modify the build.xml from H03 to be appropriate for H04. That's part of my plan—remember I said in class that I had coercive ways of getting you to read the textbook? Now one of those has been revealed!

Think carefully about your scripting strategy.

Re-read the notes from H02 about scripting before you do your script.

Hint: A good practice would be to incorporate your scripting stategy into an Ant target, so that when you go to script, the process is automated!

Finishing and Submitting

Submit your work on WebCT for the assignment marked H04. Upload and submit BOTH

Your tar or zip files should NOT contain your .class files—but if you followed the build.xml example from H03 properly, your "ant dist" task should create a tarball and zip file automatically that is in the proper form.

In addition—go to the Wiki page named 07J_H04, and make sure that there is a link to your distribution on that page.

Reminder: Submit your code both in your .txt file and in your .tar file

A reminder: even though your distribution file contains your Java source, you are still required to "cat" this source code in your .txt file, and submit it in both forms. If you do not, you will lose points.

Here's why: Submitting both allows your TA the ability to

Of course, the two should agree—if they don't, that's also a potential grading deduction. So if you make changes to your code, be sure that you redo both your script, and your tar/zip file.

Next Steps: Re-read Chapter 1-6 in HFJ

As you read, consult the online reading notes. These contain

You may also want to apply the typo corrections from the errata to your book—i.e., actually write them in.

Grading Rubric (100 pts total)

Item Description Points
Functionality The program actual works—it does what it is supposed to do when you run it 25
Unit Testing Your code includes appropriate Unit tests, and those unit tests can be run from the build.xml file. 20
Style The program logic is clear and well documented. It is easy for someone to read your program and understand how the program works. 15
Deployment The build.xml file is clear, and operates correctly. It contains tasks for compiling, running unit tests, running the code, producing javadoc (and deploying it to the web), and creating a distribution file and posting it to the web. 10
Web Site There is a web site under your userid on copland.udel.edu where your javadoc is available, your code is avialable (in tarball/zip and browsable source form). There is a brief explanation of your code, and link to the assignment. You have updated the indicated wiki page with a link to this site. 10
Scripting Your script clearly demonstrates the functions of the program, and includes a reasonable amount of testing. 10
Following Directions Both submitted files (e.g. script and (tarball or zip)) are submitted according to directions, and all other aspects of the project comply with instructions given. 10
Total Points    

Valid XHTML 1.0 Valid CSS!