home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / pascal / 8616 < prev    next >
Encoding:
Text File  |  1993-01-28  |  7.5 KB  |  183 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!news.univie.ac.at!scsing.switch.ch!univ-lyon1.fr!ghost.dsi.unimi.it!rpi!utcsri!newsflash.concordia.ca!sifon!thunder.mcrcim.mcgill.edu!poly-vlsi!music.mus.polymtl.ca
  3. From: Steph <CT80@music.mus.polymtl.ca>
  4. Subject: Naming conventions
  5. Message-ID: <26JAN93.10699202.0054@music.mus.polymtl.ca>
  6. Lines: 172
  7. Sender: usenet@music.mus.polymtl.ca
  8. Organization: Ecole Polytechnique de Montreal
  9. Date: Tue, 26 Jan 1993 14:54:24 GMT
  10.  
  11. My server, and account, were down for the past 3 days so I wasn't
  12. able to reply to any messages.  I think my reply about one other
  13. message didn't get through.  Doesn't matter, it was sort of
  14. flamish.  Anyhow, here's another one I did:
  15.  
  16. In article <1993Jan20.132920.5828@ncsu.edu> samodena@csemail.cropsci.ncsu.edu (S. A. Modena) writes:
  17. >In article <pf-200193004907@biomac1f.bio.purdue.edu> pf@bilbo.bio.purdue.edu (Paul Furbacher) writes:
  18. >>In article <18JAN93.14103652.0032@music.mus.polymtl.ca>,
  19. >>CT80@music.mus.polymtl.ca (Steph) wrote:
  20.  
  21. [ my stuff deleted ]
  22. >>>
  23. >>> Okay, let's assume I have an object definition that _looks_ like
  24. >>> this:
  25. >>>
  26. >>> PObjectType         = ObjectType;
  27. >>> ObjectType          = OBJECT
  28. >>>   Stuff             : StaticRecord;
  29. >>>   Stuff2            : PtrRecord;
  30. >>> ............
  31. >>
  32. >>> Stuff2 = RECORD x,y,z : WORD; Buf : POINTER; END;
  33.  
  34. Okay, if you guys want to nitpick ...
  35.  
  36.   1) PObjectType should read ...
  37.  
  38.      PObjectType        = ^ObjectType;
  39.  
  40.      I'm amazed no one has screamed murder on that one yet.
  41.  
  42.   2) It's not Stuff2 that should be defined as a RECORD .. END, but PtrRecord,
  43.      like so:
  44.  
  45.      PtrRecord = ^RECORD .. END;
  46.  
  47.      Again, no one complained.  Strange world.
  48.  
  49. [ more of my stuff deleted, as was as Paul Furbacher's ]
  50.  
  51. >
  52. >To carry Paul's critique of Steph's code just a bit farther to make
  53. >a general point.
  54. >
  55.  
  56. Ooooh boy, this should be educational, and oh-so entertaining.
  57.  
  58. >Steph does this:
  59. > Stuff: StaticRecord;
  60. > Stuff2: PtrRecord;
  61. >
  62. >Let's consider what this communicates to a stranger (which is the code
  63. >writer himself one month later).
  64. >
  65. >Try these alternative declarations:
  66.            ^^^^^^^^^^^
  67. You said it yourself, Steve.
  68.  
  69. >
  70. >TYPE TStaticRecord = RECORD....
  71. >TYPE PStaticRecord = ^TStaticRecord;
  72. >
  73. > StaticRecord: TStaticRecord;
  74. > StaticRecordP: PStaticRecord;
  75. >
  76. >Notice that my naming convention is quite suggestive of what the hell I
  77.              ^^
  78. >am dealing with when I use those identifiers farther down in the code.  :^)
  79. >
  80. >Of course, I've be told that "all that typing" is so *tedious,* but it gives
  81. >so much *help* when I'm debugging my own code.
  82.                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  83. Matter of opinion, I guess.  If I were to debug code that used StaticRecord
  84. and StaticRecordP, I'd be wary the programmer confused the two.  I would, in
  85. my own code, use something like StaticRecordPtr to define the pointer record,
  86. but that is only _me_.  And, to skin it to death, a PointerToAStaticRecord
  87. could be misleading to some other programmers.  It would be a
  88. PointerToADynamicRecord, no?  ;)
  89.  
  90. >
  91. > "Stuff" tells me absolutely nothing about itself, so I am
  92. >free to absent-mindedly do any old nonsense that pops into my head.
  93.  
  94. *BINGO*.  You got that one right, at least.  That's exactly the point of
  95. putting a variable name as Stuff in an EXAMPLE.  It succeeded it telling
  96. you this much : the content could be _anything_ and is _not_ relevant to
  97. the example.  Pretty good, *clap* *clap*.
  98.  
  99. >
  100. > "Stuff2" real, truely tells me even *less*.......not even the
  101. > same *storage* type........and the
  102.  
  103. Ooops, I take it back -- you didn't get the real point of the Stuff
  104. variables.  Of course Stuff2 can't tell you more, it's nothing important
  105. again.  And since it's not the same storage space, and not the same name,
  106. what does this tell us?  Different _stuff_, that's all.
  107.  
  108. >        "PtrRecord" is disasterously misleading.
  109. >
  110.  
  111. Is it?  In an example, all it does is inform me that we are dealing with a
  112. pointer pointing to a dynamic variable that is, in fact, a data structure.
  113. PtrRecord, Pointer-to-a-Record.  In a program, maybe it would be misleading,
  114. maybe_.  If someone uses it all the time and defines their dynamic records
  115. types as Ptr<RecordName> or <RecordName>Ptr, as long as they are consistant,
  116. it makes sense to me.
  117.  
  118. >An friend who is an electronics manufacturing engineer assures me that
  119. >"they" are always in such a hurry to get the "job" done, that following
  120. >simple, standard set up and quality procedures is "such a waste of time",
  121. >that invariably the "job" has to be redone, and redone and redone until
  122. >they finally get it right.
  123. >
  124. >So how is Pascal coding different?  No, coding conventions do not prevent
  125. >the occurance of bugs, but they do *significantly* reduce the number of
  126. >"silly" bugs (aren't most of them silly?) and significantly reduce the amount
  127. >of time needed to debug....and, believe it or not, sometimes promotes
  128. >clear thinking to the point of coding it right-the-first-time, more often.
  129. >
  130. >Look back above at Steph's naming convention (pretty much like yours,
  131.                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  132. >right?) and pay attention to how it helped him dig himself in royally!
  133. >I can easily see *why* the FillChar() bug flowed from his type declarations
  134. >and naming non-conventions.
  135.             ^^^^^^^^^^^^^^^^
  136.  
  137. *OUCH*  If you can, from a 5-line declaration header _example_, deduce my
  138. naming convention then either you are a psychic, or full of yourself.
  139.  
  140. "Your" naming convention is not new to me; I use it when I write Turbo Vision
  141. programs, because that is the way Borland wants us to go.  It would be foolish
  142. to use something else in a Turbo Vision program, because the code simply
  143. wouldn't flow when merged when Turbo Vision's numerous objects.
  144.  
  145. Now, it would also be really foolish of me to throw away my naming convention
  146. I have been using since Turbo Pascal 3.0, before Turbo Vision came to be.  I
  147. stick to it because it passed the test of time, it still works for me, and I
  148. can go back and write old code I wrote years ago and still understand it.
  149. More so, people that read my code usually can follow my style pretty easily.
  150. Isn't that what's important with a naming convention?
  151.  
  152. Objects don't equate to Turbo Vision; my example uses objects, but it's far
  153. from being a Turbo Vision package, so I didn't see the need to use TV naming
  154. convention.
  155.  
  156. >And he was *positive* it was a spurious bug in the compiler--definitely, this
  157. >time, for sure.  :^)  Well, we all do it.  It's just a question time until
  158. >we get smart and quite doing it...or move on to some other way to earn a living.
  159.  
  160. Again, the old foot-in-the-mouth.  Don't assume I "didn't get smart" yet
  161. because I don't use _your_ (or Turbo Vision's) naming convention.  I penalized
  162. enough students because they don't use significant variable names to know what
  163. I am talking about.  And they is always the ones that think that overdoing it
  164. means better programming.  Not true.
  165.  
  166. >
  167. >Steve
  168. >---
  169. >+------------------------------------------------------------------+
  170. >|     In person:  Steve Modena     AB4EL                           |
  171. >|     On phone:   (919) 515-5328                                   |
  172. >|     At e-mail:  nmodena@unity.ncsu.edu                           |
  173. >|                 samodena@csemail.cropsci.ncsu.edu                |
  174. >|                 [ either email address is read each day ]        |
  175. >|     By snail:   Crop Sci Dept, Box 7620, NCSU, Raleigh, NC 27695 |
  176. >+------------------------------------------------------------------+
  177. >         Lighten UP!  It's just a computer doing that to you.    (c)
  178. >OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
  179.  
  180. Steph.
  181. Hey, I can make mistakes too.
  182.  
  183.