Homework 10

This is the archived website of SI 413 from the Fall 2012 semester. Feel free to browse around; you may also find more recent offerings at my teaching page.

Use a separate sheet of paper for your answers! Everything should be submitted in one packet, all printed out for me to see.

1 Cooking Spaghetti

In class we talked about "spaghetti code", which is code that uses GOTO statements way too liberally and becomes almost impossible to follow. I want you to write your own example of spaghetti code, in the C++ language.

Submit your code electronically as 413 hw 10 in a file called ex1.cpp. Your program should compile and run without any arguments or special flags. You also need to submit a description of what your code does, written out and turned in with the other exercises for this assignment.

Grading this problem will consist of me first looking at your code, briefly, and trying to figure out what it does. I will then look at your description of what it actually does and then run it. If your code actually does something, and it's what you describe, but I couldn't discern that by looking at it, then you'll do well on this problem.

It may help to go back and read Dijkstra's original article on GOTOs.

2 Generics

Consider the following very simple class definition in Java:

public class AClass<T> {
  T x;
  public AClass() {
    x = new T();
  1. What error does javac give when you try to compile this class?
  2. What does it mean - what specifically is wrong with this code?
  3. Would the equivalent code in C++ using templates work? Why or why not?

3 Licenses

Find an open-source software license that is not mentioned in the slides and tell me about it.

If you want to search around, there is a fairly comprehensive list at this link and also see the links from Unit 10.

Specifically, I want to know:

  1. What is the name of the license?
  2. Which license category from class does this licence fall into?
  3. How does this license differ from other similar ones?
  4. Do any notable software projects use it?