C Programming Style -- New thought ("writing code")

M.J.Shannon mjs at eagle.UUCP
Thu Jul 25 23:21:22 AEST 1985


> General question: does anybody "write code" on paper first any more?
> -- 
> Ed Nather

I used to "do it" on paper as recently as a year or so ago, but have succumbed
to the paperless age.  For new programs, I now take a top-down approach,
entering a skeletal main() which either mucks with arguments itself or calls a
routine to do so.  Then it calls the main function of interest.  This routine
is then coded as was main(), mostly a skeleton detailing the algorithm, with
functions called for operations I haven't yet defined.  At this point, most of
the data structures are defined (modulo choices of storage management, such as
whether to use arrays, linked lists, quadtrees, etc.), since I've outlined the
algorithm sufficiently to understand what data types are involved.  My
experience with this method indicates that main() only changes to account for
changes in options or dealing properly with multiple file arguments, etc.  As I
discover "holes" in the algorithm, appropriate code is added, then the low-
level routines I used are defined.  I find this to be a rather effective method
for constructing programs -- more so than pencil & paper because I can see the
current version of the algorithm (usually on one screen) without having to
decipher my illegible scribbling over holes in the paper (from excessive
erasing).  Hope this helps some of you out there.  It has helped me (the
method, not this posting!).  Comments appreciated, flames ignored.
-- 
	Marty Shannon
UUCP:	ihnp4!eagle!mjs
Phone:	+1 201 522 6063



More information about the Comp.lang.c mailing list