🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sw.components
Article #333

Re: Guidelines for writing reusable C and Assembly code.

#333
From: peter da silva
Date: Thu, 10 Sep 1992 18:04
42 lines
2379 bytes
In article <1992Sep9.151622.11062@lmpsbbs.comm.mot.com> yossi@mcil.comm.mot.com (Yossi Cohen-Shahar) writes:
> In order to complete this handbook, we are seeking 
> for information / handbook / guidelines that describes
> how to write C code and Assembly code in "reusable manner",
> meaning how to write code in a way it would be easier
> to reuse it in the future.

Ah! This is one of my hot buttons. I'm really upset about some of
the supposedly reusable code I've seen. It's usually way too application
specific or depends too much on other parts of an application to really
reuse it.

The main rules I use in designing code (or a tool) for reuse are:

	1.	How much can I generalize this without losing
		efficiency. For example, in a symbol table for
		a text based application I allowed the use of
		any arbitrary chunk of data in the target, rather
		than simply a text string.

	2.	How can I simplify the interface without losing
		efficiency. In the case of this symbol table, I
		only use four basic routines: create a symbol
		table, look up an entry, execute a subroutine for
		each element, and destroy a symbol table. Lookup
		automatically creates an entry if none exists,
		simplifying external code design: it's not hard to
		check explicitly, but it's something more to forget.

	3.	How can I AVOID using other reusable tools in this
		tool. If I build a tool that's dependent on MY
		private code library other people are unlikely to
		be able to use it. It means I may take more time,
		but it's time well spent. If I can't avoid it, I
		document what the tool I'm referencing does so it
		can be reimplemented by a third party if it's
		missing.
-- 
Peter da Silva                                               `-_-'
Ferranti Intl. Ctls. Corp.                                    'U` 
Sugar Land, TX  77487-5012
+1 713 274 5180                                   Har du kramat din varg idag?
Technical Details
Message-ID: <id.U44T.2C7@ferranti.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!menudo.uh.edu!sugar!ficc!peter
References: <1992Sep9.151622.11062@lmpsbbs.comm.mot.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.sw.components
Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!menudo.uh.edu!sugar!ficc!peter
From: peter@ferranti.com (peter da silva)
Subject: Re: Guidelines for writing reusable C and Assembly code.
Message-ID: <id.U44T.2C7@ferranti.com>
Organization: Xenix Support, FICC
References: <1992Sep9.151622.11062@lmpsbbs.comm.mot.com>
Date: Thu, 10 Sep 1992 18:04:15 GMT
Lines: 42