[Tutor] Planning out your program

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Fri, 13 Sep 2002 23:38:15 -0700 (PDT)


On Fri, 13 Sep 2002, Kirk Bailey wrote:

> I tend to program in a top down approach, which is proceeding from most
> abstracte and generalized to most specific.
>
> 1. conceive of a program to do something.
> 2. Rough out the details of what it is going to do, without lapsing into
> extreme detail.
> 3. outline the steps it has to go through to accomplish this. Flow charting
> may    be useful here.
> 4. build a skeleton program, and import a few modules you know you will need.
> 5. Run it. See if it bombs. Fix it. COMMENT it!
> 6. Start fleshing out the program. Write functions to accomplish specific
> tasks,    or import them from code you already have written. COMMENT IT!
> 7. Run it again, and pay attention to the error reports. COMMENT IT!

At the same time, the counterpoint needs to be offered:  if the code is
complicated enough that every line needs annotation, that's a possible
sign that the code really is doing too much work.  *grin*

But seriously, like all things taken to extremes, overcommenting can be
detrimental: comments can discourage people from simplifying code.



> > > I made a very crude little text adventure in Python a few months
> > > ago. However, as I began to add on functionality to it, it became
> > > apparent that a lot of the underlying code wasn't capable of being
> > > improved.

Hmmm... if you don't mind, would it be ok to show us what the program
looks like?  It might not be necessary to toss the whole thing in the
fire: it may be salvagable.  And it would help a lot of us here on the
Tutor list because it would give us an opportunity to practice the Art of
Revising.


Gotta go to sleep now.  Talk to you later!