| 
cs205: engineering software? | 
(none) 05 April 2010  | 
cs205 Friday 25 August 2006
| Assignments Due | 
What is a more important property of a programming language: (a) what it can say; or (b) what it cannot say?
How do different languages you know trade off expressiveness
and truthiness?  (If Java is the only programming language you
know, try to answer this question for English)
                 High  |
                       |
                       |
Expressiveness         |
                       |
                       |                    x Java
                  Low  |
                       |______________________________
                         Low                    High
                                Truthiness
                        
What is an object?
How does strict type checking impact the expressiveness and safety of a language?
How do classes help programmers manage complexity?
How do visibility modifiers help programmers manage complexity?
public class CellState {
   // OVERVIEW: A CellState is an immutable object that represents
   //    the state of a cell, either alive or dead.
   private boolean alive;
   private CellState(boolean isalive)
   // EFFECTS: Initializes this to alive if isalive is true,
   //   otherwise initializes this to the dead state.
   {
      this.alive = isalive;
   }
   static public CellState createAlive()
   // EFFECTS: Returns an alive cell state.
   {
      return new CellState(true);
   }
   static public/* nonnull */CellState createDead() ...
   public Color getColor() 
   // EFFECTS: Returns the display color for this state
   {
      if (alive) return Color.green;
      else return Color.white;
      
   }
   ...
}
public class ExtremeLifeCell extends Cell {
   public CellState getNextState()
   // EFFECTS: Returns the next state for this cell.
   //          The next state will be alive if this cell or any of its neighbors
   //          is currently alive.
   {
      Enumeration neighbors = getNeighbors();
      while (neighbors.hasMoreElements()) {
         SimObject neighbor = neighbors.nextElement();
         if (neighbor instanceof Cell) {
            Cell cell = (Cell) neighbor;
            if (cell.isAlive()) {
               // If the cell has at least one neighboring cell
               // that is alive, this cell should become alive.
               return CellState.createAlive();
            }
         }
      }
      // No alive neighbor found, next state is current state
      return getState();
   }
}
 
It's surprisingly difficult to find a good name for a programming
language, as the team discovered after many hours of
brainstorming. Finally, inspiration struck one day during a trip to the
local coffee shop. — James Gosling