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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2a687662f09731bb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Newsgroups: comp.lang.ada Subject: Re: Ada Quality and Style book discussion ("_Type" suffix) References: <1132227241.9036.44.camel@sonnenregen> From: Brian May Date: Thu, 17 Nov 2005 23:26:07 +1100 Message-ID: User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:vSV81qkssr1e3+JJxQFeOjyODtM= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: snoopy.microcomaustralia.com.au X-Trace: news.melbourne.pipenetworks.com 1132230367 202.173.153.89 (17 Nov 2005 22:26:07 +1000) X-Complaints-To: abuse@pipenetworks.com X-Abuse-Info: Please forward all headers to enable your complaint to be properly processed. Path: g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!news.xtra.co.nz!news-north.connect.com.au!news-south.connect.com.au!duster.adelaide.on.net!news.melbourne.pipenetworks.com!not-for-mail Xref: g2news1.google.com comp.lang.ada:6447 Date: 2005-11-17T23:26:07+11:00 List-Id: >>>>> "Georg" == Georg Bauhaus writes: Georg> Somehow this discussion reminds me of the type prefix notation Georg> introduced in some Windows C programming books. Georg> lpszLastName; That is a style that was used, I believe, by Microsoft, in Windows 2 (probably 1.0) days. Its possible it first came from IBM (or Microsoft?) in OS/2 1.0 (my memory isn't that good). I believe the windows include files still use it. It was decided that it helped if you were reminded what type the variable is whenever you go to use it. Perhaps overused. I am not sure there is even a distinction between "long pointers" (lp) and "short pointers" anymore with 32 bit software (not counting low level device drivers and OS code), but the names seem to remain. Also, how often do you encounter a string in C that isn't null terminated (sz)? Possibly this style was influenced by lack of type safety, especially in early C compilers. Also, you could have two variables: spszLastName lpszLastName To signify that one is a short pointer and one is a long pointer to the same data. However, sometimes it still helps to add a type prefix/postfix to a variable, if for example two or more variables contain the some data but different types for example. type kilometres_per_hour ...; type miles_per_hour ...; .... vehicle_speed_kps := convert(vehicle_speed_mph); or even: kps := convert(mph); Is easier to understand then what I often see happen: car_speed := convert(vehicle_speed); What units was car_speed again? What units was vehicle speed? What is this convert doing? Gee - I need the speed in meters_per_second too. Lets create a new variable temp_1_car_speed. Now I need to calculate the "wind speed" of the car (yes - dumb example - I don't know why you would want to do this, unless the car can fly or drive over water). temp_2_car_speed. Hang on. This code also works for trucks, too. Who cares, its just a variable name... Next month, somebody takes over the code: "This code is a complete mess - It is going to be much quicker if I just rewrite the code instead of trying to work out what all of these temp_n_variable do. I will give better variable names like variable_temp_b instead, and document everything on this scrap piece of paper. Did anyone see where I put it?" . It is interesting that the decided to remove spaces, and replace make the next letter uppercase. I don't like this when you have to encode an abbreviation in the function name: MakeHtmlForPage seems wrong, as it is HTML not Html, however, this is worse: MakeHTMLForPage Is the abbreviation HTMLF? Unfortunately, this style seems to be required for CORBA (as underscore is used for a special purpose in the C bindings). Enough of my raving. -- Brian May