Program By Design - Functional Programming, Computing and Design in Programming 101

Functional Programming, Computing and Design in Programming 101

For the introductory curriculum on programming, the ProgramByDesign project emphasizes that courses should focus on the role of systematic design. Even if students never program again, they should see how helpful a systematic approach to problem solving is. This should help them whether they become programmers or doctors or journalists or photographers. Thus, an introductory course in programming would not be perceived as a place where students learn about the syntax of the currently fashionable (and soon-to-be-obsolete) programming languages, but a place where they can learn something widely applicable.

The key design element of the ProgramByDesign curriculum is the design recipe. It has two dimensions: the process dimension and the data dimension.

Along the process dimension students learn that there are six steps to designing a (simple) program, before they can run it and others can use it:

  • problem analysis with the goal of describing the classes of data that go into the program and come out;
  • the reformulation of the problem statement as a concise purpose statement;
  • the creation of examples that illustrate the purpose statement and that serve as criteria for success;
  • the organization of givens, also called a template or inventory;
  • coding;
  • and the creation of a test suite from examples to ensure the program works properly on small inputs.

Note that, as in test-driven development, test cases are written before coding, as part of requirements analysis, rather than afterward as part of testing.

Almost any human endeavour can benefit from clearly understanding the problem, defining criteria for success, analyzing the available resources/givens, developing a proposed solution, and checking it against the criteria, in that order. A journalist, for example, benefits from a similar process: figuring out the major concepts in a story; coining a headline; lining up examples and specific data; organizing the article about the story around 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 scary and mysterious, is simply the application of already-learned techniques 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.

How to Design Programs is the text book authored by the core of the ProgramByDesign group.

Read more about this topic:  Program By Design

Famous quotes containing the words functional, design and/or programming:

    In short, the building becomes a theatrical demonstration of its functional ideal. In this romanticism, High-Tech architecture is, of course, no different in spirit—if totally different in form—from all the romantic architecture of the past.
    Dan Cruickshank (b. 1949)

    Teaching is the perpetual end and office of all things. Teaching, instruction is the main design that shines through the sky and earth.
    Ralph Waldo Emerson (1803–1882)

    If there is a price to pay for the privilege of spending the early years of child rearing in the driver’s seat, it is our reluctance, our inability, to tolerate being demoted to the backseat. Spurred by our success in programming our children during the preschool years, we may find it difficult to forgo in later states the level of control that once afforded us so much satisfaction.
    Melinda M. Marshall (20th century)