CPSC 100: Principles of Computer Science
Spring 1997
Week 7 Reading Guide

This is the seventh of the weekly reading guides for Computer Science 100.

Week 7 (May 12 to May 16)

The reading for this week is Chapter 7. However, we will not cover Section 7.4. And from Subsection 7.1.2, the only thing that we will cover is the term local variable.

In Chapter 6, the built-in subroutines of xTurtle were introduced. These are true black boxes that you can use without any understanding of their implementation. However, as you know, being able to build new black boxes is the real key to creating complex systems. In the case of xTurtle programs, the programmer can create new subroutines using SUB and END SUB.

Chapter 7 is about subroutines and the ways that they can be used to build complex programs. A subroutine is just a chunk of code for performing a certain task, which has been turned into a black box and given a name. The subroutine can then be called by name, whenever that task needs to be performed. Communication between a subroutine and the rest of the program can take place through parameters. When a subroutine is declared, dummy parameters are used in its definition as place holders for actual parameters that are provided from outside the subroutine, when the subroutine is called.

Section 4.2 looks more carefully at the process of developing complex programs. Large, complex programs have a life cycle, referred to as the software life cycle. This cycle includes specification of what the program should do; analysis of the problem and design of a solution, coding of that solution into code written in some programming language; testing of the program to discover and correct bugs; and then maintenance of that program for years afterwards as more bugs are found and new requirements are imposed. Large programs are made up of modules -- just another name for black boxes in this context. More formally, a module is a relatively self-contained component of a system that interfaces with other parts of the system in simple, clearly defined, easy-to-understand ways.

Section 4.3 looks at one of the nicest applications of subroutines: recursion. A subroutine is called recursive if it calls itself, either directly or indirectly through another subroutine. Recursion turns out to be very powerful and important, but for now we just investigate its use in drawing pretty pictures in xTurtle.

Concept List for Week 7: