Homework tips — CSC207H: Summer 2009

This collection of hints, tips and suggestions is meant to help you with specific points of difficulty you might encounter in the exercises, assignments and project for this course. It is not meant to give overall guidance on how to approach any particular piece of term work.

Contents

How do I prepare and submit my term work?
Why doesn't the file I just added to my repository show up there?
What's a text file?
How do I submit code that's in a package?
What's a Java program?

How do I prepare and submit my term work?

In this course, the steps to prepare homework (and we'll use "homework" as a general term embracing assignments, exercises and the project) are:

  1. Check out the handouts from your repository.
  2. Work hard to complete the files you need to submit.
  3. Commit ("check in") the completed files to your repository.

In fact, steps 2 and 3 should occur repeatedly. It is to your advantage, if we need to be convinced you were actually working on your submission well in advance of the due date, to have committed early versions rather than just waiting for the end to do a grand all-in-one submission. It's also safer for you: if you have troubles with your own computer, or if your connection to CDF is unreliable, or even if you feel a little uncertain of your skills with your repository, then having checked in a recent version of your work can save your day.

And now, more details.

Your repository

We have created a Subversion repository for you to use for this course. It contains subdirectories for the assignments and the project. The exercises are grouped into a single subdirectory, with each exercise in its own sub-subdirectory. When an assignment is ready for you to work on it, its subdirectory will contain a copy of the assignment handout in a file called index.html, and any other starter files that we might provide.

To begin work on an assignment, as we said above, you must check out the files in your repository for that assignment. To submit your work for the assignment, you must commit the required files from your local copy into your repository.

In the first week of classes, you saw how to check out a copy of your repository and also how to add and commit files. If you are unsure about how to do this, look at the lecture slides for that week and — for a more complete discussion — the book Version Control with Subversion by B. Collins-Sussman, B.W. Fitzpatrick and C.M. Pilato, available on-line for free at http://svnbook.red-bean.com/.

The command you use to initially checkout your repository depends on your own login (and, when there are sections of the course on different campuses, also on your campus). Use this command, inserting your own CDF account login where needed:

svn co https://stanley.cdf.toronto.edu/svn/csc207-2009-05/YourCDFLogin

This command checks out all the assignments for the term. Of course, we haven't prepared them all yet, but you'll be able to retrieve the handouts for later assignments with a simple svn update command.

Why doesn't the file I just added to my repository show up there?

Don't forget that you must use both the "svn add" command and the "svn commit" command to cause a file to appear in your repository for the first time.

The add command "marks the file for addition", but doesn't cause any actual changes in the repository itself. That only happens later, with the commit command.

What's a text file?

A text file is a file that contains only printable characters. For our purposes, we restrict the definition further: a text file must contain only ASCII characters - no "smart quotes", no long dashes, no non-Latin alphabetic characters. Preferably, they should not even contain tabs, and the lines must be shorter than 80 characters.

Generally, Microsoft Word documents and PDF files are not text files, even if they appear to contain only text, because in fact they contain invisible formatting information.

What are allowable names for text files?

Anything, really. That is, the extension ".txt" is not required. If we ask you to submit a file called "essay" and you submit "essay.txt", then you have failed to meet the requirements.

If you are using an application such as Microsoft Word or Notepad that insists on file-name extensions, you may have to put quotation marks around the file name in the save dialogue or change the name after saving the file.

Beware of desktop settings that hide extensions. To find out for sure, use the UNIX ls command or DOS's dir command if you are using Windows.

How can I be sure my file contains only allowable characters?

It can be a little tricky to be sure your file contains only printable characters. For example, the very nice editor SciTE, available on CDF, is happy to produce ASCII files, but it can also work with 16-bit alphabets. The trouble is that even if your work contains non-ASCII characters, it may actually look all right when you display it with some Unix commands such as "cat ide.txt" or "more ide.txt". To be sure you have the right format, print your file to a PostScript file (a virtual printout, if you will) with enscript and view the result with GhostView to avoid wasting paper. You can use the following command on a CDF machine to do this: "enscript -p ide.print ide.txt; gv ide.print". You'll see exactly what we will print.

Good editors for creating text files include pico (or nano), vim or emacs on Unix, TextEdit on a Mac, and Notepad on Windows. For those last two, you might need to make sure you use the "plain text" setting.

How do I submit code that's in a package?

In winter 2009, we are trying to be more relaxed than usual about packages and IDE projects. That is, we are probably going to require you to put your code in Java packages, but we hope you will be able to let your IDE (presumably Eclipse) save it where it wants to and still be able to submit your work without extra trouble. Your IDE will probably bury your source code deep in a project directory structure, and because that structure can be somewhat unpredictable, it is hard for a marker to find what you meant to submit.

This means you do have to follow some rules. Here, let's assume you are working on assignment "aN" and we have told you to put your Java classes into a package "pack". Let's suppose also that one of the source files you must submit is to be called "MyCode.java"; since it is in the specified package, there must be a directory/file pair called "pack/MyCode.java" somewhere.

To be absolutely sure that you have things right, then you should check out a completely new copy of your repository (perhaps just the part of it in aN) and look through it to see all the directory/file combinations that match the requirements. You can probably do this on Windows just as well as on a Unix system.

These rules also apply to the other source files you are required to submit (and to any unspecified ones that you decide on your own to create), but if you have the submission right for MyCode.java then you almost certainly have it right for the other files.

What's a Java program?

This question may sound silly, but it isn't. If you are told to make MyCode.java a "Java program", then it must contain a Java public class called "MyCode" that contains a main method of the standard kind. In other words, we're going to run MyCode directly, not something that calls MyCode or creates an object of type MyCode.

Generally, unless we say otherwise, you are allowed to add other files that MyCode.java will work with. However, none of them will be run directly with the java command: they are not "Java programs".