Coding style (Re: FW: Browse that scrolls sideways...Yay!!!)

Jay R. Ashworth jra at baylink.com
Thu Mar 10 08:21:42 PST 2005


On Thu, Mar 10, 2005 at 10:59:24AM -0500, John Esak wrote:
> Ahh, that comes from an old system I still use.  I mark all my labels on the
> "if" line with an apostrophe (a comment).  Then I make sure never to put any
> code on the "then" line.  This way I can always add new things to the top of
> a routine without having to re-write the label and do all that work. 

John makes a very good general point here, and I'd like to drag it
further up into the light so no one misses it.

You (and the maintenance programmers who follow you) will find your
life much easier if you never put anything on a label line -- except a
logical condition that the label is supposed to take on a truth value
from.

It's not at all uncommon, at least in my experience, to need to add
something at the top of a routine, and if the first line of the routing
*is* the labeled line, then you have to do a bunch of copying and
pasting, or in vi, break the line and worry about colon counts.

My routines usually look something like this:

label:::
:: ' this routine demonstrates pretty code layout:
::do real work here:
::and here:
doesshe:dy ne "clairol"::
:hc eq "red" and doesshe:gosub washout    'right outta my hair:
::a little more work:
::return:
::':

with that 'blank' line at the end to make the code look prettier in vi,
where I do most of my work.

Obviously, if you start your routines with a comment -- and you should
:-) -- then you can't put the code on the label line, anyway.  One
other thought, which is mostly intended to make life easier for those
who *do* code in vi: don't put comments on both IF and THEN lines; the
code will wrap in vi and on paper (if printed out unformatted), making
it even harder to follow.

Cheers,
-- jra
-- 
Jay R. Ashworth                                                jra at baylink.com
Designer                          Baylink                             RFC 2100
Ashworth & Associates        The Things I Think                        '87 e24
St Petersburg FL USA      http://baylink.pitas.com             +1 727 647 1274

      If you can read this... thank a system adminstrator.  Or two.  --me


More information about the Filepro-list mailing list