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

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!news.cs.indiana.edu!noose.ecn.purdue.edu!mentor.cc.purdue.edu!biomac1d.bio.purdue.edu!user
  3. From: pf@bilbo.bio.purdue.edu (Paul Furbacher)
  4. Subject: Re: TurboVision Question (w/ example)
  5. Message-ID: <pf-230193203518@biomac1d.bio.purdue.edu>
  6. Followup-To: comp.lang.pascal
  7. Sender: news@mentor.cc.purdue.edu (USENET News)
  8. Organization: Purdue University
  9. References: <727633957.AA01183@contrast.wlink.nl> <lm2b5fINNprv@earth.cs.utexas.edu>
  10. Date: Sun, 24 Jan 1993 02:12:58 GMT
  11. Lines: 84
  12.  
  13. At the risk of beating a dead horse ... or as
  14. Bob Beauchaine would have, trying the cat experiment
  15. for the 500th time....
  16.  
  17. In article <lm2b5fINNprv@earth.cs.utexas.edu>, 
  18. preavley@cs.utexas.edu (Paul Reavley) wrote 
  19. with regards to Berend de Boer's suggestion dispensing
  20. with SetData() and GetData() overrides to effectively change 
  21. the string pointed to by the TStaticText field "Text".
  22. De Boer wrote:
  23.  
  24. > >The other writers used the Set- and GetData methods. Another thing
  25. > >might be to override the Draw method of some selfmade View. That Draw
  26. > >method can be display different texts by drawing some global variable
  27. > >(most simple, not very TV-ish).
  28. > etc....
  29.  
  30. To which Reavley replied:
  31.  
  32. >   Check out the TIndicator object at the bottom left hand corner
  33. > of TEditWindow s in tvedit.pas.  I believe it uses the Draw method
  34. > for such a purpose.  I expanded TIndicator to display overwrite/
  35. > insert mode, pagenumber, column number, line number and line
  36. > spacing.
  37.  
  38. It doesn't do what you suggest; instead, it uses a procedure called 
  39. TIndicator.SetValue(). If you ponder this, it is just another
  40. flavor of SetData().  But in order for it not to be confused 
  41. with the latter which is primarily associated (conceptually)
  42. with setting the data of a subview within a group, such as an
  43. static text view within a dialog box, the TV designers probably
  44. chose a different method name.  They also may have decided not 
  45. to override the SetData method which typically takes an untyped 
  46. record (basically a pointer) as a parameter.  Here, SetValue()
  47. has two parameters: "aLocation and "aModified".
  48.  
  49. In addition, SetValue() forces a DrawView which violates the
  50. spirit of SetData().  There may have been other reasons for 
  51. creating a separate but nearly identical method, but only 
  52. your TV authors know.
  53.  
  54. As you can see, TIndicator is not an example of what de Boer
  55. suggested, that is, to have the Draw method pop the contents 
  56. of a global string into a TDrawBuffer and display it.  His
  57. notion was that the global string would be accessible from
  58. anywhere in the program, and when the static text had to 
  59. redraw itself it would take as its text that held in
  60. the global string variable.  He is correct in suggesting
  61. that this violates the object-oriented paradigm of data and
  62. methods which together form an encapsulated object.  Instances 
  63. should receive messages which prompt action based on the content
  64. of the message.  Therefore, global variables shouldn't be 
  65. necessary, but they are not always avoidable.  In this case,
  66. however, a global variable is completely avoidable, and 
  67. many would recommend not using one.  
  68.  
  69. Rather, as S.A. Modena pointed out in an earlier 
  70. post in this thread, override the correct methods, 
  71. typically the HandleEvent() method of the descendent 
  72. view to receive and send informative messages.  
  73. Through messages which inform as to which 
  74. command, and give the what or the where of the 
  75. information, object instances "talk" to one another without
  76. having to know each other (i.e., directly reference each other).
  77. As Modena pointed out in his repost to Pollet, this is the 
  78. preferred, and cleanest implementation given the language 
  79. you are currently working with.   
  80.  
  81. [My goal has not been to criticize de Boer.  He knows that
  82. he has made many good contributions to this discussion 
  83. group.  And just yesterday, he wisened me up to something 
  84. I had overlooked when giving advice on a TV question.  It 
  85. turned out I was out in left field and he kindly set me 
  86. straight.]
  87.  
  88. To those who are getting a little bored with this discussion,
  89. thanks for reading the TV manual and  all the source 
  90. code -- gobs of megabytes -- and thinking hard about what
  91. TV and object-oriented programming is all about.  If more 
  92. poured their hearts and souls into the endeavour, our discussions
  93. would be more enlightening.  Perhaps.
  94.  
  95. Paul Furbacher
  96. pf@bilbo.bio.purdue.edu
  97.