[Tutor] Two Problems (databases, and branching)

Lloyd Kvam lkvam@venix.com
Sat, 27 Apr 2002 09:20:10 -0400


Some of the old programming languages (BASIC, COBOL, RPG, FORTRAN66)
fit a narrative style of programming.  You start at the beginning
and simply plow along until you reach the end.  This works OK for
small programs and makes these small programs fairly easy to follow.
An occasional branch or GoTo can be understood in context, especially
with some comments to assist.

However, "War and Peace" really is a narrative.  A program is not.  Some
lines are executed more often than others.  Short blocks of repeated
code can be used with 'for' or 'while' loops.  Bigger blocks should get
pushed off into functions.  Blocks of lines that get written repeatedly
also get split off into functions.  You wind up with a manageable
narrative of what the program is trying to do while effectively
pushing chunks off into appendices.

Object oriented programming tends to break the narrative among the
actors.  It becomes sort of a play where each actor nudges the next
one to say the proper lines.  The lines are organized actor by actor
and it is hard to see the overall narrative.  This organization makes
it is easier to focus on each little piece of "script" and get it right.

Sometimes (for instance with multiple threads) there is no narrative.
The challenge is to write a program that is understood by both the
computer that executes it and the person who reads it.

dman wrote:

> On Sat, Apr 27, 2002 at 01:29:12AM -0300, Spotacus Macell wrote:

.....

> have manageable code.  Break the "goto" habit as fast as you can!
> 
> 
> How about posting that 80-odd line script and letting someone with
> some spare cycles refactor it to give you a concrete example of how it
> works?
> 
> 
> -D
> 
> 


-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice: 
603-443-6155
fax: 
801-459-9582