Mar 14, 2009

something i just thought about

Ive recently hit upon something about programming. There are two different kinds of objects that don't represent a data structure:
  • Generic objects with multiple possible meanings
  • Concrete objects with only one intended meaning
Integers, for example, can be used to represent lots of things, quantities, distances, speeds, and even the color of a pixel. Objects this basic aren't even really objects often, they don't need to be. The ability to correctly interpret the meaning of the variable is left to the programmer in the future. It is possible for example to add the number of apples on a tree to a persons height if the programmer decided to store those as ints (which they most likely would).

Most objects written by programmers have only one intended meaning. I could for example create a height class which would allow me to add heights and the embedded semantics of the operations would prevent me from adding height and apples together.

Whats interesting is creating classes of the first type and then being asked what the class is for.