home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sw / componen / 127 < prev    next >
Encoding:
Text File  |  1992-09-10  |  2.3 KB  |  53 lines

  1. Newsgroups: comp.sw.components
  2. Path: sparky!uunet!spool.mu.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!menudo.uh.edu!sugar!ficc!peter
  3. From: peter@ferranti.com (peter da silva)
  4. Subject: Re: Guidelines for writing reusable C and Assembly code.
  5. Message-ID: <id.U44T.2C7@ferranti.com>
  6. Organization: Xenix Support, FICC
  7. References: <1992Sep9.151622.11062@lmpsbbs.comm.mot.com>
  8. Date: Thu, 10 Sep 1992 18:04:15 GMT
  9. Lines: 42
  10.  
  11. In article <1992Sep9.151622.11062@lmpsbbs.comm.mot.com> yossi@mcil.comm.mot.com (Yossi Cohen-Shahar) writes:
  12. > In order to complete this handbook, we are seeking 
  13. > for information / handbook / guidelines that describes
  14. > how to write C code and Assembly code in "reusable manner",
  15. > meaning how to write code in a way it would be easier
  16. > to reuse it in the future.
  17.  
  18. Ah! This is one of my hot buttons. I'm really upset about some of
  19. the supposedly reusable code I've seen. It's usually way too application
  20. specific or depends too much on other parts of an application to really
  21. reuse it.
  22.  
  23. The main rules I use in designing code (or a tool) for reuse are:
  24.  
  25.     1.    How much can I generalize this without losing
  26.         efficiency. For example, in a symbol table for
  27.         a text based application I allowed the use of
  28.         any arbitrary chunk of data in the target, rather
  29.         than simply a text string.
  30.  
  31.     2.    How can I simplify the interface without losing
  32.         efficiency. In the case of this symbol table, I
  33.         only use four basic routines: create a symbol
  34.         table, look up an entry, execute a subroutine for
  35.         each element, and destroy a symbol table. Lookup
  36.         automatically creates an entry if none exists,
  37.         simplifying external code design: it's not hard to
  38.         check explicitly, but it's something more to forget.
  39.  
  40.     3.    How can I AVOID using other reusable tools in this
  41.         tool. If I build a tool that's dependent on MY
  42.         private code library other people are unlikely to
  43.         be able to use it. It means I may take more time,
  44.         but it's time well spent. If I can't avoid it, I
  45.         document what the tool I'm referencing does so it
  46.         can be reimplemented by a third party if it's
  47.         missing.
  48. -- 
  49. Peter da Silva                                               `-_-'
  50. Ferranti Intl. Ctls. Corp.                                    'U` 
  51. Sugar Land, TX  77487-5012
  52. +1 713 274 5180                                   Har du kramat din varg idag?
  53.