Obviously Mr. Labbauf, one of those who contributed an opinion about Windows 95 in your November issue (From the Editor, page 89), is a stranger to farms. His expression "bail and wire and bubble gum" should be "baling wire and bubble gum," a well-known rural engineering technique.
Patrick J. Brennan
Virginia Beach, Va.
I refer to the October 1995 letter from Joe Celko. The principal technical disagreement between Celko and myself (at least, in the area under discussion) concerns the difference between types and representations. Let me lay a little groundwork:
Now I turn to Celko's letter. At one point, Celko seems to agree with the foregoing, when he says that "numbers . . .and numerals . . .are [not the same thing]" -- that is, numbers are the type, numerals are the representation. Very confusingly, though, he uses the term type to mean representation -- which is presumably why he also says "I do not see how domain and data type can [possibly] be the same." The source of this unorthodox terminology is probably the SQL language, which is thoroughly confused in this whole area (my FLOAT example notwithstanding).
However, Celko also gives an extensive example that suggests that he does not properly understand the type vs. representation distinction after all: "I want to represent [sic] temperatures. Degrees Kelvin is one possible scale. I could use Celsius or Fahrenheit instead; they all use numeric values. Or I could use the scale ('hot,' warm,' 'cool,' 'cold'); the data type is character string. What is the right choice? [Given a certain application area,] I will probably prefer Kelvin because it is expressed with a numeric data type. I can use arithmetic operators with numeric data types, and I will need to do calculations. [But] you cannot add temperatures . . ." (somewhat edited and condensed from Celko's letter).
I have two major observations on this example. The first has to do with the type vs. representation distinction and is fundamental. The second is not fundamental but has to do with a question of good design.
Personally, I think none of these proposals is the best choice. Rather, I would have a single "temperature" domain, with operators to expose temperature values as "number of degrees Kelvin," "number of degrees Celsius," "number of degrees Fahrenheit" -- even as "hot," "warm," and so on, if desired. One advantage of this design is that it avoids the need for explicit conversion functions from one scale to another (any such conversions would be completely under the covers). Another is that it affords a greater degree of data independence (we can change the representation from, say, Kelvin to Fahrenheit with logical impunity).
Celko makes many further points in his letter with which I strongly disagree. If I went into detail on all of them, however, this would be a very long letter. Let me therefore just make a few apparently dogmatic assertions here, without trying to provide any evidence in support of them (I can provide such evidence on request):
I agree this is a valid concern (at least in general, though I'm not sure it's valid in the case of multiplying two weights in particular). I've pointed out elsewhere that, for example, if we can't add two dates together, we obviously can't go on to divide that sum by two to obtain the date midway between the given ones -- yet this latter would be a useful and valid thing to do. (This criticism applies to SQL, incidentally.) But the moral isn't that types should simply "inherit" operations from their representations, as Celko suggests, but rather that data type definition needs to be done carefully. What's more, this moral applies at least as much to built-in types as it does to user-defined ones.
C.J. Date
Healdsburg, Calif.