comp.lang.ada
 help / color / mirror / Atom feed
From: rjh@cs.purdue.EDU (Bob Hathaway)
Subject: Re: comments on comments
Date: 23 Feb 89 02:15:16 GMT	[thread overview]
Message-ID: <6093@medusa.cs.purdue.edu> (raw)
In-Reply-To: 9689@ihlpb.ATT.COM


(I write)
>|This seems to go backwards.  Programmers should first design
>|their software then implement it.  You seem to be advocating 
>|implementation then design.  The descriptive algorithm should 
>|come first, then the code.

In article <9689@ihlpb.ATT.COM>, nevin1@ihlpb.ATT.COM (Liber) writes:
>I have a problem with Top-Down programming (design then
>implementation); it happens to be the same problem I have with
>Bottom-Up programming (implementation then design).  You so eloquently
>point it out in your next sentence:  

Design then implementation is not necessarily top-down programming.
First some terminology.  Top-down design involves a functional view
starting at the top and working its way down.  Top-down implementation
is a programming methodology which begins coding (implementing the design)
at the top level procedures.   Bottom-up design also involves a 
functional (procedural) view but starts design with the bottom level
procedures and bottom-up implementation begins coding with the bottom
level procedures.  For the past several years (since my first program)
I began with an Adt, or more object oriented approach to design and
implementation.  I would study the problem and form an informal solution
and identify the Adts (objects in the system).  The informal solution
would be in a high level pseudo-code and was usually top-down for the
main program and within modules.  This provided a modular design with
abstract data types.  It could also be categorized as a top down design
with the data structures and functionally related subprogram units
encapsulated within modules.  The Adts provided an excellent starting point
for coding.  They could be separately tested and frequently the driver
program for these tests was most conveniently the original program and
after "testing" my Adts the program was finished.  The fact that I was
often done weeks early attested to the techniques success.  The informal
pseudo-code is refined into working code but since pseudo-code usually
offers a more informal description of an algorithm than working code,
it is easier to understand.

>|If the algorithm can be coded in a
>|truly self descriptive form no comments will be necessary but in
>|instances where the design and implementation are not the same,
>|comments help.

>But design and implementation should not differ!  If this is happening,
>one of the two is wrong!  In the case of Top-Down, I would guess that
>it is probably the design that is wrong; something wasn't taken into
>account until someone actually tried to implement the design.  The

I disagree.  Pseudo-code is much easier to read than programming code.
Comments reflect algorithms in an informal way that is more understandable
than programming code.  They are semantically equivalent, but if I think an
informal description is easier to read, I'll provide it (you can put me in
the conscientious category of programmer who is always trying to write better
software).  When an algorithm can be directly expressed in code (ie. just add
underscores) as is often the case, comments aren't necessary.

>problem with Top-Down (and Bottom-Up) programming is that there is no
>feedback mechanism.  What happens when an implementation discovers a
>bug in a design?  Does it happen that people go back and formally
>re-review an already approved design document?  Not nearly as often as
>it should, I suspect.  Or at least go back and change the design to
>match the implementation?  It gets even worse when there are many
>levels to the design.  There needs to be a feedback loop.

Any conscientious programmer will update the appropriate documents.  But
if put on a system where the comments are in doubt, I can always ignore
them.  When working with large C programs, I often waste a lot of time
trying to understand undocumented field declarations and incomplete function 
descriptions.  A correct comment would save time and it should be obvious
from the code if a comment isn't accurate.  As suggested in an earlier
article, large software projects with elaborate standards can hold design and
code reviews to insure correctness.

>|True, but requiring Joe Programmer to design his software first will help,
>|and the design can be included in the comments.

>Yes, but until we have good hypertext systems that will allow Joe
>Programmer to do this easily and painlessly, he basically has to
>maintain TWO design documents, and when a human being has to do it, it
>tends to get out of sync, and eventually useless.

Yes, thats why there are software development environments and APSE's and why
I keep asking for them:-)

|I think the poorly designed, poorly documented systems have caused most
|of the trouble, not out-of-date commenting.   Just follow the convention
|that when code is updated so are the comments.  The benefits of a well
|commented design far outweigh the costs.  Well documented code is easy
|to understand and modifications to the software can be done in terms of
|the higher-level design.  Since the design is directly implemented in the
|code, corresponding changes should be easy.

> The real question is:  what can we do to make this happen?

Be conscientious!

Bob Hathaway
rjh@purdue.edu

  parent reply	other threads:[~1989-02-23  2:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1813@goofy.megatest.UUCP>
1989-02-10 21:16 ` comments on comments Bob Hathaway
     [not found] ` <20233@agate.BERKELEY.EDU>
     [not found]   ` <9689@ihlpb.ATT.COM>
1989-02-23  2:15     ` Bob Hathaway [this message]
1989-02-23  7:22       ` Dave Jones
1989-02-23 22:50         ` Good Design Strategies <Was comments on comments> Bob Hathaway
1989-02-25  1:07           ` Dave Jones
1989-02-26 19:34             ` Rob Jellinghaus
1989-02-27  0:58               ` William Thomas Wolfe,2847,
1989-02-27 15:29                 ` John Baugh
1989-02-27 18:29                 ` Reuseable Ada components William Thomas Wolfe,2847,
1989-02-28  0:53             ` Good Design Strategies <Was comments on comments> Bob Hathaway
1989-02-28 22:13               ` Dave Jones
1989-03-03  5:45                 ` Bob Hathaway
1989-03-08 17:14                   ` David P. Schneider
1989-03-11 11:15                   ` Stuart H. Ferguson
1989-02-24  1:57         ` comments on comments William Thomas Wolfe,2847,
1989-02-23 20:41       ` comments on comments on reusability Rick Farris
1989-02-24  2:15         ` comments on comments on comments William Thomas Wolfe,2847,
1989-02-24  3:31           ` William A. Bralick
1989-02-24  9:24           ` Rick Farris
1989-02-25 14:28           ` Robert Claeson
1989-03-09 21:12           ` Rick Clements
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox