From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,988f2c34ce3e6595,start X-Google-Attributes: gid103376,public From: vsnyder@math.jpl.nasa.gov (Van Snyder) Subject: Modest proposal, 2 of 3 Date: 1996/11/22 Message-ID: <575ag6$rt6@netline-fddi.jpl.nasa.gov>#1/1 X-Deja-AN: 198151586 organization: Jet Propulsion Laboratory content-type: text/plain; charset=US-ASCII mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-11-22T00:00:00+00:00 List-Id: BACKGROUND One of the reasons for code-bloat is the way we teach our children to structure programs. What Parnas had in mind when he recommended "information hiding" and "encapsulation" in Comm. ACM (Dec 72) in "On the criteria for dividing programs into modules" was that one could thereby (almost) change the representations of objects in a program by changing their declarations, but not their references -- no matter what representation one chooses, the references always look the same: a procedure. Almost. In the procedures that support an "abstract data type" one must still cope with changes in representation. That's not terrible. The amount of work necessary to change a representation is reduced from something proportional to the size of a program to something on the order of the complexity of the data type. The unfortunate side effect is that it leads to innumerable tiny procedures. On the positive side, the design methodology is applicable to any language. Geschke and Mitchell had a better idea in IEEE TSE SE-1, 2 (June 75) in "On the problem of uniform references to data structures": Design languages so that differences in representation are not reflected in references. So the [] vs () for arrays vs functions in C would be considered to be a bad idea. (Actually, Ross described the germs of the idea in Software Engineering 1 (1969) in "Uniform referents: An essential property for a software enginering language.") Minor incremental changes could bring Ada to the state of allowing one to change the representation of objects without changing their references. PROPOSAL for next standardization of Ada Allow objects to be declared in the public part of a package specification with mode "out". The meaning is that clients of the package can reference the variable, but can't store into it. Thus, a variable that a package publishes with "out" mode has the same properties as a private variable with a public parameterless function to access it, and no procedure to update it directly. But it's more efficient, and there's less code to write initially, and therefore less to read and understand when you're the poor schmo assigned to make the next minor change. There's more that could be done to make programs more mutable, less fragile, and more efficient, all at once. See "Not so modest proposal, 1 of 1" to be posted soon. -- What fraction of Americans believe | Van Snyder Wrestling is real and NASA is fake? | vsnyder@math.jpl.nasa.gov