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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2078dddcdcd8d83 X-Google-Attributes: gid103376,public From: "John G. Volan" Subject: Re: Warning: Religious naming convention discussion :-) [was: assign help!!] Date: 1997/05/16 Message-ID: <337CF962.40DC@sprintmail.com>#1/1 X-Deja-AN: 242068052 References: <5kjvcv$evt@news.cis.nctu.edu.tw> <5kn8ko$jcc@top.mitre.org> <1997May7.201035.2439@nosc.mil> <33727EEA.2092@sprintmail.com> <5kuf1j$17vi@uni.library.ucla.edu> <3373666A.31DFF4F5@spam.innocon.com> <5li43j$ur3@castor.cca.rockwell.com> Reply-To: johnvolan@sprintmail.com Newsgroups: comp.lang.ada Date: 1997-05-16T00:00:00+00:00 List-Id: Wayne Magor wrote: > > Altitude : Units.Feet; > Latitude : Units.Radians; > Rate : Units.Hertz; > > It's pretty important to know that Altitude is in feet and not nautical miles > or meters. It's also pretty important to know what is in Degrees and what > is in Radians. This is the most straightforward and elegant solution, IMHO. I'll say it again: If something is important enough to say in the type, then it's just as important to say it in the object names, too: Altitude_Feet : Units.Feet; Altitude_Meters : Units.Meters; Latitude_Radians : Units.Radians; Latitude_Degrees : Units.Degrees; Rate_Hertz : Units.Hertz; Rate_Megahertz : Units.Megahertz; If you're using many different units for the same kinds of quantity, all in the same program, then it's important to keep them all straight. But this pattern is basically just Booch style: _ : ; (For example "Altitude" can be seen as the specific modifier attached to the general noun "Feet".) Now, if you can guarantee me that you'll always be attaching some modifier or other, then this approach is workable. (Just don't ask me to try this sort of thing on my object-oriented abstractions... "The_" is just noise.) On the other hand, if your project intends to settle on _one_ standard universal unit for each type of quantity (a good idea anyway), then embedding the unit name in the objects, or the types, or both, is just noise (i.e., Hungarianism). Better to just say, a la Booch: The_Altitude : Altitude; The_Latitude : Latitude; The_Rate : Rate; or, a la Cohen: Altitude : Altitude_Type; Latitude : Latitude_Type; Rate : Rate_Type; Sure, it'll take discipline to always keep to the project-standard units. But (short of wrapping these up as private types) keeping to the units would take discipline _anyway_. Just because the type name says "Feet" doesn't guarantee programmers will always remember to treat them as feet... but if you think the programmers need reminding, better remind them with every object! ------------------------------------------------------------------------ Internet.Usenet.Put_Signature (Name => "John G. Volan", Home_Email => "johnvolan@sprintmail.com", Slogan => "Ada95: The World's *FIRST* International-Standard OOPL", Disclaimer => "These opinions were never defined, so using them " & "would be erroneous...or is that just nondeterministic now? :-) "); ------------------------------------------------------------------------