home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / pascal / 5213 < prev    next >
Encoding:
Text File  |  1992-09-07  |  1.6 KB  |  34 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!world!art
  3. From: art@world.std.com (Al Thompson)
  4. Subject: Re: TP units question
  5. In-Reply-To: stone@cunixb.cc.columbia.edu's message of Fri, 4 Sep 1992 14:12:03 GMT
  6. Message-ID: <ART.92Sep5134221@world.std.com>
  7. Sender: art@world.std.com (Al Thompson)
  8. Organization: The World Public Access UNIX, Brookline, MA
  9. References: <1992Sep4.141203.28370@news.columbia.edu>
  10. Date: Sat, 5 Sep 1992 18:42:21 GMT
  11. Lines: 21
  12.  
  13. In article <1992Sep4.141203.28370@news.columbia.edu> stone@cunixb.cc.columbia.edu (Glenn Stone) writes:
  14.  
  15.    If a procedure/function is only used within the implementation section
  16.    of a unit, it doesn't have to be declared in the interface section,
  17.    but is there any disadvantage to doing so?  I'm using TP 5.5.
  18.  
  19. Disadvantage?  No, a great advantage.  One of the major motivations
  20. behind the units concept is that of information hiding.  So, if a
  21. procedure is ONLY used in the implementation section it should NOT appear
  22. in the interface section.  Any program or unit that imports this unit
  23. will be able to use that procedure, and you obviously don't want that.
  24.  
  25. Another issue is the "working" philosophy of units.  The interface
  26. section defines how the unit looks to the outside world.  The
  27. implementation section defines how the unit performs its functions.  The
  28. idea is that I can change my implementations any time the spirit moves
  29. me.  The only(?) thing I need to do is to be 100% certain that the new
  30. implementation produces exactly the same behavior as the old.  That is,
  31. the interface predicates must be invariant from implementation to
  32. implementation.
  33.  
  34.