Thursday, July 26, 2012

The ability to write nested loops is not a sufficient condition of employment

But it ought to be a necessary one.

Suppose you were helping me write a TicTacToe program. I have this Java code so far:
package com.vaporware.tictactoe;

import com.vaporware.common.logging.FormattingLogger;

class Board {
  Piece cells [][];

  Board() {
    this.cells = new Piece [3][3];

  boolean xWins () {
    return wins(Player.X);

  boolean oWins () {
    return wins(Player.O);

  boolean wins (Player player) {
    // FINISH ME!
    return false;
Assume further that there is a getOwner() method on a Piece that returns a Player.
Can we finish the wins (Player player) method?