A White Horse Is Not A Horse

   曰:马者,所以命形也;白者,所以命色也。命色者非名形也。故曰:“白马非马”。
公孙龙子

‘Horse’ is that by which we name the shape. ‘White’ is that by which we name the color. Naming the color is not naming the shape. So white horse is not horse.
  — Gongsun Longzi

public class Horse extends Shape{
 ...
}

public class WhiteHorse extends Horse implements Colourable
{
  public Colour getColour(){ return Colours.WHITE; }

  public boolean equals( Object other ){
    if ( !other instanceof WhiteHorse){
      return false; 
    }
    ...
  }
}

public class AnotherWhiteHorse{

  public Shape getShape(){ return ShapeConstants.HORSE; }

  public Colour getColour(){ return Colours.WHITE; }

}


public class Argument{
  public static void main(String[] args){
    Horse horse = new Horse();
    WhiteHorse whiteHorse = new WhiteHorse();
    AnotherWhiteHorse anotherWhiteHorse = new AnotherWhiteHorse();
    log.info( whiteHorse == Horse.class );
    log.info( WhiteHorse.class == Horse.class );
    log.info( WhiteHorse.class.equals( Horse.class ) );
    log.info( whiteHorse == horse );
    log.info( whiteHorse.equals ( horse ) );
    log.info( anotherWhiteHorse == horse );
    log.info( anotherWhiteHorse.equals ( horse ) );
    log.info( anotherWhiteHorse instanceof Horse.class );
    log.info( "Therefore white horse is not horse" );
  }
}
Advertisements

One thought on “A White Horse Is Not A Horse

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s