From: iainf@spider.com (Iain A F Fleming)
Newsgroups: comp.editors,comp.sys.transputer
Subject: Re: Folding editors
Date: 03 Nov 1998 16:37:03 +0000
Organization: Spider Software Ltd
Sender: iainf@belhaven.spider.com
Distribution: inet
Message-Id: <6rvhkw20nk.fsf@belhaven.spider.com>
References: <36374B57.168B9492@pact.srf.ac.uk>
    <71aj0c$oc$1@fangorn.moria.de> <6r1znq7264.fsf@belhaven.spider.com>
    <3639BEFD.2CC25E3C@esgem.com> <6r4ssm59ay.fsf@belhaven.spider.com>
    <QuruoDADsfO2Ewhc@cawley.demon.co.uk>
    <y4n26clw5i.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>
    <6rhfwi4ee6.fsf@belhaven.spider.com> <363EEB84.5CAD538B@roke.co.uk>
In-Reply-To: Richard Beton's message of Tue, 03 Nov 1998 11:39:48 +0000
Xref: ukc comp.editors:32112 comp.sys.transputer:8912


The entity calling itself Richard Beton wrote:
> 
>  Iain A F Fleming wrote:
> 
>  > The Jan Vorbrueggen wrote:
>  > >
>  > >  My experience exactly. It's also great for starting a program,
>  > >  document,...:
>  >
>  > Exactly my point: folding is great for *starting* a program, but lousy
>  > for maintaining it.
> 
>  I tend to disagree. Especially with languages like Java, program outlining
>  is a great benefit. So folding has a considerable value when it comes to
>  maintaining such programs.

Maybe it's because we're dealing with different kinds of programs?  I'm a
(embedded) systems programmer - I do compilers, operating systems, and
communication protocols. This kind of code tends to be both very non-linear,
and also very very long lived. And frequently it also needs to have part of
it cleanly extracted to be used somewhere else, or else modified to behave
in a subtly different way.
Again, in short, my objection to folding is that it hinders clean and
complete functional decomposition. It can also produce code with awful
complexity metrics - it's very easy, when folding, to produce loops with
loops within conditionals -- to several levels. And have several of these in
a function. I have seen such functions, stretching over screens and screens.
When bereft of folds, such functions are inscrutable.

>  So folding has a considerable value when it comes to maintaining such
>  programs.

Yes and no: yes because you can quickly get a good overview of a program
with folds, both no because you lose if you want to extract a deeply nested
operation that really should have been partitioned off in a function.

The best thing to be said for folding, in my experience, is that it
encourages good error checking. Programmers, by and large, dislike having
error checking and handling take up more than about 40% of code. Folding
gets over this hurdle by hiding the error check code.

Finnaly, if we do need to change the programming paradigm, I feel that tools
such as CWEB provide a far better means of moving away from flat source
code.

-- 
 Iain A F Fleming               http://www.spider.com/
 Spider Sofware Ltd  Leith  Scotland  +44.131.475.7045

