© Michael Stueben 2018
Michael StuebenGood Habits for Great Codinghttps://doi.org/10.1007/978-1-4842-3459-4_7

7. Step-Wise Refinement

Michael Stueben1 
(1)
Falls Church, Virginia, USA
 
  • Only stories are really readable.—Rudolf Flesch, The Art of Readable Writing (Collier MacMillan, 1949), page 74.

One way to self-document your code is to use top-down design , a form of structured programming also called step-wise refinement.1 In this style,2 the main function contains function calls with descriptive English names—e.g., enterData(), computeData(), and printData(). The function calls will form an outline of what the code does. They tell a story.

When you follow one of these calls, you again may get mostly an outline of sub-calls that describe what ...

Get Good Habits for Great Coding: Improving Programming Skills with Examples in Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.