Termination

Code Comments Full Code Poem Commentary
//Person.java

/**
 * Models a person and their various attachments.
 *
 * @author Zach Tomaszewski
 * @version 10 May 2006
 */
public class Person {

  //the modeled contents/traits of a Person object
  //(a vector is a list of the specified kind of objects)
  public String name;
  protected java.util.Vector<Object> assets;
  protected java.util.Vector<Person> family;

  private java.util.Vector<Picture> pictures;
  private java.util.Vector<Address> addressBook;
  private Person lover;

  /**
   * Stores the given object in this person's assets
   */
  public void give(Object o) {
    this.assets.add(o);
  }


  protected void finalize() {
    this.addressBook.remove(this.lover.name);
    //remove all pictures after the first
    while (this.lover.pictures.size() > 1) { 
      this.lover.pictures.remove(1);
    }

    Person heir;
    heir = this.family.get(this.family.indexOf("sister"));
    heir.give(this.assets.remove("sorrow"));
    heir = this.family.get(this.family.indexOf("mother"));
    heir.give(this.assets.remove("faith"));
    heir = this.lover;
    heir.give(this.assets.remove("innocence"));

    this.assets.removeAllElements();
  }
}


/* empty class definitions */
class Picture {}
class Address {}
You were my last connection.

Now I am adrift,
washed by this city rain
through cold tunnels of guilt
out to a dark and glittering sea.

I have torn your name from my address book.
I have burned all your pictures, but one.

On my sister's grave, I left my sorrow.
In my mother's kitchen, I left my faith.
In your arms, I left my innocence,
  all those years ago.

Now I am hollow and empty,
  with nothing left to leave.

"Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup... The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded."

--Java 1.5 API Documentation for Object.finalize()

Termination is inspired by the idea of reaching some end, some point where there are no more references to us to keep us viable. And as our resources are recollected by the system, we have to release those attributes that have so long defined us. This is the only Process that was born as a poem, and only then translated into code.

Termination is written in Java 1.5. Java is a high-level, object-oriented language, which makes it one of the most expressive languages for codework like this, since we often think of the world in terms of objects, with their various states ("variables") and behaviors ("methods").

The full code will compile, but it does not actually do anything because there is no main method. In a complete system, the empty classes would need to be defined. Also, Person would need a constructor that sets up all assets that are being removed here in the finalize method in order to avoid errors. Strictly speaking, the work done in finalize() is not necessary, as all the particular objects contained by a Person here have nothing about them that would prevent them from being automatically garbage-collected along with the Person.

The translation to code raises some questions. For instance, the while loop that removes all the pictures--should it leave the first, the last, or some other picture behind? Also, it currently removes the pictures held by the lover object, rather than the pictures of the lover held by the garbage-collected person. An interesting distinction, though the original poem allows for either of these readings.