600.226: Data Structures


Pair programming exercise

We'll be using a Quadtree1 data structure to practice pair programming. Pair programming is a concept in software engineering where one person acts as a driver, writing the code, and the other is the observer, reviewing the code as it gets written. Choose now who will start in each role. After 15 minutes, we'll switch off. Two novice programmers working together can accomplish great things this way!

Quadtree code repository:
svn+ssh://USERNAME@ugradx.cs.jhu.edu/home/obuzek/svn/cs226-quad
(quadtree code thanks to jotschi at github)

You can also get the source from Google Code if you don't yet have a ugrad account, though you won't be able to commit to the repository:

http://cs226-quad.googlecode.com/svn/trunk/

We'll be modifying the PointQuadTree.java file to add an Iterator. This will involve making it implement Iterable, adding an .iterator() method, and writing an inner class called PointQuadTreeIterator.


Using SVN

On a PC: TortoiseSVN
On a Mac (graphical): Versions
On Linux / UNIX / Mac through Terminal: use your command line!

Commands

Making a repository on the server
First, go to your home directory. We're going to set
[obuzek@ugradx ~]$ cd ~
[obuzek@ugradx ~]$ mkdir svn
[obuzek@ugradx ~]$ cd svn
To create a repository:
[obuzek@ugradx ~/svn]$ svnadmin create PROJECT_NAME
Make sure you set the permissions so other people (namely, your group members!) can access it.
[obuzek@ugradx ~/svn]$ chmod -R a+rw PROJECT_NAME
Now you've got a repository! If you go into the directory, you'll see something like this:
[obuzek@ugradx ~/svn]$ cd PROJECT_NAME
[obuzek@ugradx PROJECT_NAME]$ ls
conf  db  format  hooks  locks  README.txt
Checking out your repository

Now that you've got it, you can access it from elsewhere. You should be able to access a repository on the ugradx servers.

Do the following on your own computer. You can also use this URL to enter into TortoiseSVN or Versions.

daifuku:working olivia$ svn checkout svn+ssh://USERNAME@ugradx.cs.jhu.edu/home/USERNAME/svn/PROJECT_NAME PROJECT_NAME
Adding files to the repository
Now that you've checked out a copy of the repository, create a folder of your own inside the repository for your pair programming project. Go into the directory that you've just created, and create a new directory inside it.
daifuku:working obuzek$ cd PROJECT_NAME
daifuku:PROJECT_NAME obuzek$ mkdir YOUR_NAME
daifuku:PROJECT_NAME obuzek$ cd YOUR_NAME
You can now modify files in the YOUR_NAME directory on your own computer. Make the changes you'd like to make, add files, etc. You'll also have on your computer now a folder called quadtree_code. For today, copy the code inside that directory into the YOUR_NAME directory.
Checking in the repository
When you're done, add the YOUR_NAME directory to the repository, and check it back in. Run the following commands from the project directory (PROJECT_NAME):
daifuku:PROJECT_NAME liv$ svn add YOUR_NAME
A         YOUR_NAME
A         YOUR_NAME/file1
A         YOUR_NAME/file2
A         YOUR_NAME/file3
daifuku:PROJECT_NAME obuzek$ svn ci -m "message"
obuzek@ugradx.cs.jhu.edu's password: 
Adding         YOUR_NAME
Adding         YOUR_NAME/file1
Adding         YOUR_NAME/file2
Adding         YOUR_NAME/file3
Transmitting file data .
Committed revision 1.
The first puts all the files in the YOUR_NAME directory. The second command checks in the revisions you've made.
[1] Wondering what on earth a Quadtree is, and what it's good for? Quadtrees are key in computer graphics. They're particularly good at compressing spatial information. There's even a whole book on them (H. Samet).