CS10, Fall 2009, lab05

Instructor: Phill Conrad
TAs: Esra Kucukoguz, Yiming Li, Murali Yeleswarapu

Primary TA for this lab: Yiming Li
Graders for this lab: Esra Kucukoguz and Yiming Li

Important notes—please read these!

What about your lab04 submissions?

If you already made a lab04 submission, this is good! It is:

However, we won't be grading your lab04 submission unless you fail to submit something for lab05.

One way to look at this is that if you are willing to forfeit 100 points (or already have 100 points of extra credit), then lab05 is optional. But I'd encourage you to do it anyway—the pair programming experience is very valuable.

Here's how it will work

How your pair programming will be evaluated

You'll be asked to evaluate your pair, and your pair will also evaluate you. These are the questions you'll be asked. You may find it helpful to consider those before you begin work—you certainly want your pair to say good things about you. (Previous experience with pair-programming in courses suggests that 95% of students do end up giving their pair good evaluations—make sure you are part of the 95%!)

  1. Did your partner read the lab assignment and preparatory materials before coming to the scheduled lab? [Note: In this case, this will refer to: did your partner do a reasonable amount of work on lab04?]
  2. Did your partner do their fair share of the work?
  3. Did your partner cooperatively follow the pair programming model
    (rotating roles of driver and navigator)?
  4. Did your partner make contributions to the completion of the lab assignment?
  5. Did your partner cooperate?

Based on your pair's evaluation, the 100 points for the pair-programming component of this lab will be scaled by the results of your pair's evaluation. That is, if you receive 90 points on that part of the lab, and your pair gives you a 100% on their evaluation, you'll get 90/100 points. If she/he gives you a 50% on your evaluation, you'll receive 45/100 points.

So please do work with your pair in a constructive way!

Also: know that the vast majority of your grade in this course is still based on individual work, not pair work—so while you do need to try to have the best pair experience possible, in the unlikely event that your experience does not go well, the impact on your grade is limited.


Detailed Instructions

Step 0: Getting Started

Step 0.1: Finish H14 (the orange worksheet)

This worksheet has some questions about pair programming. If you don't have a copy, you can print one from the PDF on the website.

This worksheet is due in class on Friday—and must be completed in pairs.

You can probably answer the questions based on just the discussion from class, and the video we saw—but if you missed class on Monday or Wednesday, or need a refresher, you may find my online guide to pair programming helpful—it has a link to a video about pair programming, and some additional articles.

Step 0.2: Decide with your pair, which lab04 you want to build on

Together with your pair, look through both of your lab04 projects. Decide which one is a better starting point. You might use the grading criteria from lab04 as you look through.

You might also ask each other whether either of you already found the bugs that were in lab04.

This should be the only part of lab05 where you may want to sit at separate terminals so that you can each bring up your own lab04 without having to logout and log back in.

Step 0.3: Get into pair programming mode

After you decide, one of you should log out, and you should sit at one terminal, pair programmer style:

Step 0.4: Learn how to copy code between each others directories

It is important that when working in a pair, that you each are able to be self-sufficient in case the other person gets hit by a bus, has a family emergency, wins the lottery and moves to Tahiti, etc.

So, at the risk of planting the seeds of inappropriate collaboration in the future, I'm going to show you how to copy code between each others directories

Later in your CS courses, you may learn about "tarballs", which are the most common way that professional programmers distribute source code—but for now, I'm going to assume that most of you are more familiar with "zip files". So we are going to build on that familiarity. (Tarballs work pretty much the same way as zip files—they just use different software, and have more geek street cred.)

There are many ways to copy code, but the way we'll use is (1) create a zip file, (2) use scp to copy the zip file. The next two steps explain the details.

Step 0.5: Making a zip file of your code

To make a zip file from a directory on CSIL (or in the Cooper lab)—for example to make a zip file of your lab04 directory, you can use the cd command to put yourself one directory level "higher" than your lab04 directory, and then use the "zip" command, as shown here:

-bash-3.00$ cd
-bash-3.00$ cd cs10
-bash-3.00$ ls
cooper csil Hello.java~ lab00 lab01 lab02 lab04 untitled folder
-bash-3.00$ zip -r lab04.zip lab04
updating: lab04/ (stored 0%)
adding: lab04/lab04Project/ (stored 0%)
adding: lab04/lab04Project/bluej.pkg (deflated 75%)
adding: lab04/lab04Project/Complex.class (deflated 45%)
... etc...
adding: lab04/lab04Project/QuadraticSolver.java (deflated 65%)
adding: lab04/lab04Project/README.TXT (deflated 48%)
-bash-3.00$ ls
cooper csil Hello.java~ lab00 lab01 lab02 lab04 lab04.zip untitled folder

Note that if you forget the -r flag on the zip command, you'll get an empty zip file, just containing an empty lab04 directory.


-bash-3.00$ zip lab04.zip lab04
  adding: lab04/ (stored 0%)

The -r means "recursive" and it means you want not only the directory, but everything inside the directory, and everything inside the directories in the directory, and everything inside the directories in the directories in the directories... and so on until you have everything. So be sure your command is of the form

zip -r zipfile.zip directoryname

Step 0.6: Copying the zip file to another person's directory

The scp command can be used to copy between two different unix accounts—on the same machine, or different machines.

To copy files from the current directory to another account, e.g. jsmith's CSIL account, you can use this command. This command copies lab04.zip into the cs10 directory of jsmith's CSIL account:

-bash-3.00$ scp lab04.zip jsmith@csil.cs.ucsb.edu:cs10
Password:
lab04.zip 100% 50KB 50.1KB/s 00:00
-bash-3.00$

Here, jsmith's password must be typed in. You won't see anything echo on the screen—not even ****** or •••••••••

On jsmith's account, the new file lab04.zip will show up in his/her cs10 directory.

In case you are interested (you can skip down to Step 0.6 if you aren't)

The general form is:

scp localfile username@machine:targetdirectory

You can also copy an entire directory without making a zip file, by using the -r (recursive flag):

scp -r localdirectory username@machine:targetdirectory

The command also works in reverse to "pull" instead of "pushing" a file or directory:

scp -r username@machine:remotedirectory localdirectory

In fact, that's the form of command you've been using in many previous labs to get the starting files—we've used "dot (.) as the localdirectory (meaning "the current directory").

Step 0.6: Unzipping the file

If you want to unzip a file, you can just type unzip file.zip

asdf-bash-3.00$ unzip lab04.zip 
Archive: lab04.zip
creating: lab04/
creating: lab04/lab04Project/
inflating: lab04/lab04Project/bluej.pkg
inflating: lab04/lab04Project/Complex.class
... [etc]
inflating: lab04/lab04Project/QuadraticSolver.java
inflating: lab04/lab04Project/README.TXT
-bash-3.00$ ls
lab04 lab04.zip
-bash-3.00$

A complication is that you really want your lab04Project to be renamed lab05Project inside a directory called lab05. This can get a little tricky, but it is good practice with unix commands such as mv, cp, cd, pwd, etc. You and your pair can help support each other in figuring out how to finally get your lab04Project that is your starting point to be called lab05Project inside a directory called ~/cs10/lab05

Step 0.7 VERY IMPORTANT: Share your work at the end of each session

At the end of each session, be sure you make a zip file of your work so far, and share it with the person whose account you are NOT using.

For example, if Suzy pairs with Sunita, you may choose to work in Suzy's account on CSIL. In that case, when you are finished with work FOR THE CURRENT SESSION (not finished completely), do the steps below.

This is important because if your pair gets hit by a bus, or wins the lottery and moves to Tahiti, or catches the swine flu, you need to be able to continue working without him/her:

-bash-3.00$ cd ..
-bash-3.00$ ls
cooper csil Hello.java~ lab00 lab01 lab02 lab04 lab04.zip lab05 temp untitled folder
-bash-3.00$ zip -r lab05.partially.completed.Friday.12.50pm.zip lab05
adding: lab05/ (stored 0%)
adding: lab05/lab05Project/ (stored 0%)
adding: lab05/lab05Project/bluej.pkg (deflated 75%)
adding: lab05/lab05Project/Complex.class (deflated 45%)
adding: lab05/lab05Project/Complex.ctxt (deflated 63%)
... adding: lab05/lab05Project/QuadraticSolver.java (deflated 65%)
adding: lab05/lab05Project/README.TXT (deflated 48%)
-bash-3.00$ ls
cooper csil Hello.java~ lab00 lab01 lab02 lab04 lab04.zip lab05 lab05.partially.completed.Friday.12.50pm.zip temp untitled folder
-bash-3.00$ scp lab05.partially.completed.Friday.12.50pm.zip sunita@csil.cs.ucsb.edu:cs10
sunita@csil.cs.ucsb.edu's password:
Permission denied, please try again.
[copying file....] -bash-3.00$

With all that out of the way, you are ready to begin the real work!

Step 1: Fixing the bugs

Step 1.1 Look for the test cases that don't start with "test"

Find any test cases that don't start with "test", and rename them so that they do. It is reasonable to just add the letters "test" to the name of the methods in the JUnit test classes.

Step 1.2: Look through the test cases for errors

Look through all the test cases carefully. Ask yourself (and your pair)—is this a valid test? Is what is being "asserted" really correct?

A hint from lecture: a great test of whether a quadratic equation solver works properly is to find the root(s), then plug the roots back into the equation (that's what the evaluate method is supposed to do), and then see if the result is zero. This is, after all, what the root of a quadratic equation is: the value of x for which f(x) = ax2 + bx + c = 0. This should work for both real and complex roots. So, see if the tests that claim to do that are really doing that, or if they are doing something other than that. If they are doing the wrong thing, they need to be fixed.

Step 1.3: Look through the code that calculates and check the formulas

Now that you have the tests working properly, you may find that some of the test cases are failing—unless you already fixed bugs in the formulas during your work on lab04. Look carefully at all the mathematical operations in QuadraticEqn and Complex and be sure that the code does what it is supposed to do. If it doesn't, then you need to fix it.

Step 1.4: Finish up anything else from lab04's work that you didn't already finish.

You may have started with a "complete" lab04—if so, wonderful! You are almost finished with lab05!

But if you didn't, then finish up the work from lab04. Your lab05 submission will be evaluated using all the grading criteria from lab04 for the first

Step 1.5: VERY IMPORTANT: Be sure that every file you modified together has BOTH OF YOUR NAMES in the @author Javadoc comment.

You will only be making one turnin submission for lab05. It doesn't matter which of you does the turnin step. But you MUST be sure that both of your names are in the Javadoc comments for you to get full credit.

 


Turn in Step

This week, use turnin to submit your entire lab05 directory to lab05@cs10

Don't be surprised if that ends up being a LOT of files, especially if you are using BlueJ, and don't worry about warnings for binary files.

You are finished—there is no paper component to hand in with this lab.


Grading

Points for this lab are distributed as follows. Partial credit may be awarded for each step at the discretion of the TA/Instructor.

Grading for lab04 part (repeated from lab04 file)

Grading for lab05 part

The 100 points in this part will be multiplied by a scale factor dependent on your pair's evaluation of your work.

As a separate assignment, you'll also be asked to fill out a pair survey. Points for completing this survey will be calculated separately.

Total points: ?

Due Date: You should do your best to complete as much of this lab as possible within the assigned lab time 05/14 or 05/15. If you don't, you may continue to work on it over the weekend, and next week, including during next week's lab. We'll accept this assignment up without penalty up until 5PM Friday on 05/22.

However, you should try to get it done sooner, both as a way of studying for the exam, and because there will be additional assignments, and you don't want to get behind.

Submissions turned in after the stated deadline above are subject to receiving zero credit. They will be graded if only they arrive before the TA finishes work on grading the entire "batch" of assignments submitted. So you should still continue to work and do your best to get the assignment done even if it is after the deadline, but know that the longer you wait, the less chance of getting credit.



End of lab05