CSC207 Software Design
Lectures
Frequently Asked Questions

Asking Questions

Everyone is encouraged to ask questions---lots of them. The best ways to do this are:

Prerequisites

The calendar states that in order to enrol in this course, you must have completed CSC148 or CSC150, have a cumulative GPA of 2.5, or be enrolled in a CSC subject POSt. As there have been some questions about this, some explanation is probably in order.

First, when you enrol in a courses, your prerequisites are not automatically checked. This is because they can't be, at least not accurately, because spring term grades are not in yet. The checks are run afterwards, and a list of students lacking prerequisitess is then sent to the department.

Second, all second year courses require either that you have a 2.5 CGPA or that you are enrolled in a CSC subject POSt. As instructors, we cannot waive the CGPA prerequisite. To apply for a CGPA waiver, you must submit a letter explaining your extenuating circumstances, along with a copy of your academic history, to the undergraduate office. Students who need a waiver and don't get one will be removed from the course.

Less formally, you ought to know the basics of programming in Java before taking CSC207. We will assume that you know what a class is, that you can write a method containing loops and conditionals, and that you are comfortable with arrays. You must also know how to use sets and lists, and how to use iterators to step through their elements.

If you haven't used Unix before, you will need to master the basics during the first two weeks of the course. You may find it helpful to pick up a book on Unix (such as Unix: Visual QuickStart Guide, by Deborah and Eric Ray).

Lecture Notes and Reference Material

Please bring printed copy of the slides for the lecture, and the source code for the lecture's examples, so that you can make notes. (But please don't print these out more than a day in advance, as we may make late changes.) Note that you have the source for the lecture slides in your individual CVS repositories, so that you can put them on your laptop (if you have one).

There is no set text for this course, although there is a recommended reading list. Much of what you will need to know is available on-line; part of the course is learning how to find it.

Do I Have to Use...?

Good programmers use lots of tools well, and build new ones for themselves as needed. CSC207 will introduce you to:

With regard to other tools:

Do I have to run Linux at home?
No. Many of the examples were originally written on Windows 2000 or Windows XP, and you can use CVS to keep your files at home consistent with the ones in your CDF account. If you are going to program on Windows, we strongly recommend that you get the Cygwin tools from http://www.cygwin.com, which provides standard Unix command-line tools on Windows.
Do I have to use [name of editor goes here]?
No. You can write your Java (and Python) using whatever editor you like. However, we strongly recommend that you use some kind of Integrated Development Environment (IDE) that includes an interactive debugger, such as Metrowerks CodeWarrior (which is available very cheaply through the university), the Personal Edition of JBuilder (which is free for home use), or Eclipse (which is also free). Students who took this course in the summer term of 2003 were fairly evently divided between JBuilder, Eclipse, and primitive editors such as emacs, vi, and notepad; the ones who used IDEs generally had better luck with assignments. Debugging with print statements is amateurish, inefficient, and often ineffective; learning how to use a debugger now will save you thousands of hours over your working life.

Late Policy

The due date for each assignment will be announced at least one week in advance. Anything submitted up to four (4) hours after the due date will have 20% deducted from its mark. Anything submitted after that will not be marked. Exceptions will be made only for natural disasters, illness (accompanied by a doctor's note), abduction by aliens (accompanied by a note from the aliens), and serious personal emergencies. Please note: "I couldn't get CVS to work" is not an acceptable excuse. You should check material in via CVS as you do it---CVS allows you to revise what you have submitted as many times as you want.

If you wish a late submission to be considered for grading, you must send mail to the professor no later than 10:00 p.m. on the due date (i.e. at most an hour after the late cut-off).

Re-marking Policy

If you feel that an assignment has been unfairly or incorrectly marked, you may submit it for re-marking. In order to do this, you must:

  1. Make the request within two weeks of the assignment being returned to the class.
  2. Print out and fill in a copy of this form.
  3. Write a cover letter explaining why you think the assignment should be remarked, and what grade you believe it should have been given. Be sure to include your name and login ID, but do not put your student number on this letter. Do not refer back to any email messages or newsgroup postings you may have written about your problem, as the professors may not have saved them.
  4. Return the letter, and a printed copy of your assignment, to your instructor.

Note that any assignment submitted for re-marking will be completely re-marked, and that marks may go down as well as up.

Unix

What's the difference between Ctrl-C, Ctrl-D, and Ctrl-Z?
Ctrl-C tells the operating system to stop a running program. Ctrl-D means "end of input"; when a program is reading interactively from the keyboard, it signals an end-of-file condition. Some Windows programs interpret Ctrl-Z in the same way that Unix programs interpret Ctrl-D.

CVS

What's the difference between "cvs checkout" and "cvs update"?
Doing a cvs checkout creates an initial local copy of the repository files. You only do this once when you first start working with this repository. Update examines the files in the repository and attempts to bring your local copy up to date. It does not change files in the repository. If changes have been made to repository files that you have not changed since your last update (or checkout) then these changes are made in your local copy. If both the local copy and the repository copy have changed, cvs tries to merge the changes. If the changes affect different parts of the file the merge happens automatically and you are informed. If the changes affect the same sections of the file then cvs warns you that it can't do the merge automatically and your intervention is required to resolve the conflict.

DrJava

Please make sure you have the latest version of DrJava. The debugger is turning out to be rather cool (for example, you can assign to any in-scope variable from the interactions pane) and, of course, JUnit is integrated.

Running a Main Method

To run a main method in class MyClass from the DrJava interactions pane you can just type this:

java MyClass

And you can give command line arguments as well:

java MyClass arg1 arg2

It works just like the command line.

Cygwin and Other Tools

When I run Make under Cygwin, it tries to run javac, then prints out "Error 255". What's wrong?
Here's the full transcript:
bash-2.05b$ cd c:/cygwin/bin/csc207h/exer/e02/
bash-2.05b$ make
javac -source 1.4 Atom.java
make: *** [Atom.class] Error 255
bash-2.05b$
The problem is that the directory containing javac (the Java compiler) isn't on your search path. To check, type "echo $PATH" to take a look at the value of the PATH environment variable. If your Java install directory isn't there, you'll need to add it to your path.

Java Programming

Enumerations

From Tim Smith (c3smitht@cdf)

An enumeration is a set of discrete values, such as HEARTS, CLUBS, SPADES, and DIAMONDS, or RED, GREEN, and BLUE. Pascal, C, and most other languages allow you to define new types of enumerations. Java doesn't (at least, not yet---Java 1.5 may include this feature). If you want enumeration-like behavior in Java, the best way is to:

  1. create a class for your enumeration type (e.g. State);
  2. have public static final members of the same type as your class within your class; and
  3. create a protected (or private) constructor that does nothing.

An example is:

public class State {
    public static final State STATE_START = new State();
    public static final State STATE_WAITING = new State();
    public static final State STATE_CONNECTED = new State();
    public static final State STATE_END = new State();
    public static final State STATE_ERROR = new State();

    protected State() {
    }
}

Now you can use the class's different values in a type-safe manner, as shown below:

public void setState(State state) {

    // state is guaranteed to be one of the above States
    if (state == State.STATE_END) {
        ...
    }
    else if (state == State.STATE_ERROR) {
        ...
    }
    else if (state == 5) { // won't compile!
        ...
    }
}

public void foo() {
    setState(State.STATE_ERROR); // perfectly fine
    setState(1);                 // won't compile!
    setState(new State());       // neither will this!
}

Googling for "Enumerated types in java" returns some good results, including how to make some pretty complicated enums. Unfortunately, switch statements can't be used with this method.

Commandline Arguments

What is a commandline argument and how do I use them in my java program?

A commandline argument is an extra piece of information you provide to a program or command you are executing by typing its name at a prompt. For example when you type ls -l *.html at the commandline -l is the first argument and *.html is the second.

Consider the main method of myProgram.java
	public static void main(String[] args) { 

           String firstArg = args[0];
           String secondArg = args[1];
           String thirdArg = args[2];
        }

If this code were executed with the command

java myProgram first 2 another 
typed at the prompt, then firstArg would be set to "first", secondArg to "2" and thirdArg to "another"

.

$Id: faq.html,v 1.1.1.1 2004/01/04 05:02:31 reid Exp $