home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / pascal / 5193 < prev    next >
Encoding:
Text File  |  1992-09-04  |  2.1 KB  |  42 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!utcsri!torn!news.ccs.queensu.ca!mast.queensu.ca!dmurdoch
  3. From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
  4. Subject: Re: TP units question
  5. Message-ID: <dmurdoch.123.715622406@mast.queensu.ca>
  6. Lines: 30
  7. Sender: news@knot.ccs.queensu.ca (Netnews control)
  8. Organization: Queen's University
  9. References: <1992Sep4.141203.28370@news.columbia.edu>
  10. Date: Fri, 4 Sep 1992 16:00:06 GMT
  11.  
  12. In article <1992Sep4.141203.28370@news.columbia.edu> stone@cunixb.cc.columbia.edu (Glenn Stone) writes:
  13. >If a procedure/function is only used within the implementation section
  14. >of a unit, it doesn't have to be declared in the interface section,
  15. >but is there any disadvantage to doing so?  I'm using TP 5.5.
  16.  
  17. There are a few kinds of disadvantages:
  18.  
  19. From an efficiency point of view, putting a procedure in the interface
  20. section automatically makes it a "far" procedure; calls to those are
  21. slightly slower and take a few more bytes in your program.
  22.  
  23. From a maintenance point of view, putting a procedure in the interface
  24. section means that other code can use it; this ties you down to the
  25. particular way it works.  If you decide you want to change it, you'll have
  26. to track down every use of it outside that unit in order to make sure
  27. they're compatible with the new way.  Generally programs are easier to
  28. maintain if they're "loosely coupled", i.e. the different units function
  29. almost independently of each other.
  30.  
  31. From the point of view of a user, interfacing it can have both positive and 
  32. negative points.  It makes the unit easier to understand if it only 
  33. interfaces a few routines.  I've got a few units that work perfectly with 
  34. *nothing* interfaced; they're a joy to use, because they're so simple. (They 
  35. do things like initialization and exit handling.)  On the other hand, a 
  36. simple interface can't be flexible.  You may not like the particular high 
  37. level interface to a library unit; if the low-level interface isn't hidden 
  38. from you, you can construct your own high level interface in a new unit, 
  39. without messing up the implementation of the old unit.
  40.  
  41. Duncan Murdoch
  42.