ProgramByDesign: Difference between revisions

Content deleted Content added
m Disambiguating links to Program (link changed to Computer programming) using DisamAssist.
m Fixed a typo found with Wikipedia:Typo_Team/moss.
Line 68:
For example, a journalist benefits from a similar process: figuring out the major concepts in a story; creating a headline; lining up examples and specific data; organizing the article about the story of the givens and how the story unfolded; writing; and fact checking.
 
The data dimension can be summarized by the maxim ''the shape of the data determines the shape of the code and tests.'' For example, if the input or output data type has three variants, a test suite should have at least one test case from each variant, and program code will probably contain a three-way conditional (whether explicit or hidden in a polymorphic dispatch). If the input or output data type has three fields, a test suite will have to specify values for those three fields, and program code will have to refer to those three fields. If the input or output data type has a simple ''base case'' and one or more self-referential variants, the test suite should include a base case and one or more non-base cases, and the program code will probably have a base case and one or more self-referential cases, isomorphic to the data type. The technique of [[recursion]], rather than being mysterious and scary, is simply applying already-learned methossmethods to a self-referential data type.
 
Organizing the givens is the task of translating the descriptions of data into a program skeleton. Each form of description determines a specific form of program organization. The transformation is nearly mechanical and helps the students focus on the creative part of the task.