INTRODUCTION TO COMPUTER PROGRAMMING: COURSE SPECIFICATION Gary T. Leavens Department of Computer Science, Iowa State University Ames, Iowa 50011-1040 USA leavens@cs.iastate.edu June 28, 1993 ABSTRACT Computer Science 227 is an introduction to computer programming that focuses on exploring computing through computer programming, and on writing concise, general, and easily understood programs through reading and extensive practice. This document specifies the course's general and specific objectives. The specific objectives are specified in enough detail to determine the kinds of questions that will appear on homeworks and tests. 1. INTRODUCTION Computer Science 227 is a course that teaches beginning computer programming. The discipline of computer programming seeks to answer the following questions: * What kinds of problems can be solved on a computer? * What are good ways to solve a problems with a computer? * How can one arrive at a good solution surely and quickly? * How well does each solution work? How can it be made better? Com S 227 addresses all of these questions, although we will not focus on all of the many efficiency and human factors aspects of the last question. 1.2 COURSE DESCRIPTION This class is designed to explore computing and to show you some of the art of computer programming. You will see some of what computers can do and how hard or easy it is to do certain things. You will develop a sense of style and aesthetics for programs that will help your programming. You will learn some of the design principles for writing good programs. You will learn a number of programming idioms---standard ways of doing things. Finally we hope to share our sense of the joy and fun in computer programming. The ISU catalog description of the course is as follows: An introduction to computer programming. Symbolic and numerical computation. Recursion and iteration. Modularity and data abstraction. Functional and interactive programming. Imperative programming. Emphasis on principles of programming and program design through extensive practice in writing, running, and reasoning about programs. This course is designed for majors. (3 credits). Numeric computation involves numbers (200+27), while symbolic computation involves letters and other symbols (although we have no plans for teaching graphics yet). Recursion and iteration are two ways of repeating computations. Modularity means designing a program in parts that can be separately understood and tested---the parts are called modules. For example, a bicycle has as modules wheels, frame, brakes, and so on. Functional, interactive, and imperative programming are all styles of programming. Functional programs only use expressions (2+3) and function calls (f(x)) to accomplish their work. Interactive programs talk to the user. Imperative programs add to functional programs a notion of a time-varying state; you can think of the program's state as a piece of paper with data written on it; changing the state is like changing what is written on the paper. It is important to distinguish programming a computer from using a computer; a programmer designs new programs in much the same sense that an architect designs houses. Another analogy is that a programmer is like someone who writes a cookbook, as opposed to a cook. To clarify a common misconception---we do not teach C++ in Com S 227. You will learn C++ in Com S 228X, but not in this course. This is not a course about Scheme, it is a course for you to explore computer programming, and Scheme happens to be a good vehicle for that. 1.2 ACKNOWLEDGEMENTS The specification for the course described here was developed with the help of professors Baker, Fernendez-Baca, Gadia, and Oldehoeft. Many other faculty in the Computer Science department at ISU have contributed ideas and discussions. Thanks to George Springer of Indiana University for discussions and various phrases stolen from his course description. 2. PREREQUISITES The formal prerequisite for Com S 227 in the ISU catalog is ``2 years of high school algebra and 1 year of high school geometry.'' In terms of ISU math placement tests, this means that you should have placed out of Math 140. Also since Math 165 is a co-requisite of Computer Science 228X, you are advised to not take Com S 227 unless you can complete Math 165 by the end of next term. That means that you should either be taking trigonometry (Math 141 or 142) this term or have placed out of it. You must talk with me if you don't meet the prerequisites. One reason for these prerequisites is that both programming and math involve problem solving. You won't get the maximum benefit from Com S 227 if you haven't done enough math problem solving. Another reason is that there are various mathematical subjects (e.g., polynomials) that are used in the textbook. 3. GENERAL OBJECTIVES The general objectives for Com S 227 are divided into two parts: a set of essential objectives and a set of enrichment objectives. The essential objectives will be helpful for your career as a computer scientist. You are encouraged to explore the enrichment objectives, both for their own sake and because learning more about those will help deepen your understanding of the essential objectives. 3.1 ESSENTIAL OBJECTIVES In one sentence the essential goal is for you to discover what computing and computer programming have to offer. To do that in a way that is not superficial you should: * Be able to quickly and creatively solve small programming problems. * Use good style in writing, improving, and modularizing programs. * Understand how to program at the right level of detail (data abstraction), how to do the same thing many times by breaking the process down into one step and other similar steps (recursion), how to deal with input and output (interactive programming), how to compute without making things in the computer change (functional programming), how to make things in the computer change (imperative programming), and how to prevent writing the same program over and over again (procedural abstraction). The main reason for having this course is to give you an insight into what computing is all about, so that you can be sure you have the right major. Assuming you will go on in computing, we also wish to give you a firm foundation for good programming practice and for later study in computer science or engineering. Hence the main skills we emphasize are those related to being a good programmer, at least in programming small problems. Good style is partly in the eyes of the beholder, but that you should have some sense of style can hardly be argued. I believe that the best way to enjoy programming, and thus in the long run to excel at it, is to try to make one's programs beautiful. The concepts of data abstraction, recursion, imperative programming are fundamental to computer science. Functional programming is used as a teaching tool, to gradually introduce concepts and to allow more formal reasoning early on in the study of programming. It is a potentially important paradigm for future programming as well. Procedural abstraction is important because you should only write code once; and because it allows you to encapsulate and name plans that they have used several times. 3.2 ENRICHMENT OBJECTIVES Enrichment objectives could be multiplied endlessly. Listed here are those that would be easy to teach based on the text. * Be able to convincingly argue the correctness of your solution to a functional programming problem. The ability to argue the correctness of a program, convincingly but not formally, is important so that you do not have to always program by trial and error. Debugging is also a useful skill, but one that is not emphasized in 227. * Be able to exploit the correspondence between the recursive structure of data and the structure of a recursive program. * Understand the basics of object-oriented programming. * Understand the basics of sorting and searching. 3.3 SPECIFIC OBJECTIVES In general we will adopt the objectives of the course text. How these will appear on homeworks and tests is described below. 4. CONVENTIONS FOR EVALUATION OF ANSWERS To ensure more objectivity in grading essay and programming questions, we establish the following conventions here. 4.1 SHORT ANSWER AND ESSAY QUESTIONS Short answer questions will be graded on the basis of completeness (did you list all the relevant parts of the answer?) soundness (did you make any errors of fact or contradict yourself?) and clarity. You can help ensure clarity by giving examples where possible. For essays, critical justifications, and the like there may be no one right answer; so the criteria for judgement will be whether your essay is: * clear (you use examples where appropriate, you write clear sentences, diagrams, and you avoid excess verbosity), * sound (you start from facts or reasonable assumptions, your logic is convincing), and * complete (you consider relevant aspects of the problem and alternatives). Extra consideration will be given to answers that are especially creative. 4.2 PROGRAM QUESTIONS You are encouraged to use helping procedures. For programming problems, there is usually more than one right answer, hence it is important to write a clear solution. Answers to programming questions will be scored with the following breakdown of points: * 60% for correctness (whether your program solves the given problem correctly in the given subset of the language) * 40% for elegance and clarity (using relevant techniques to modularize the solution, making good use of language features, the creativity of your solution) You should try to eliminate all syntax errors from your programs, as they affect both the correctness and clarity of your solution; you may receive no points for programs with major syntax errors. Checking of external inputs, and other conventions for dealing with humans are not important (for this class), unless the problem says so. 5. TESTS Test questions will be similar to, but not the same as, the problems in the book from the chapter in question. The problems will only involve programming ideas that are discussed in the textbook, perhaps from earlier chapters that we have covered. The specific ideas needed will not be stated, and to solve some problems two or more ideas may need to be combined. Problems may be stated by giving a specification and requiring that the entire solution be developed, or by giving a partial solution and requiring the completion of the unfinished parts of the solution. The specifications will be given in careful English, augmented with either concrete examples or axioms as needed to remove ambiguity. In all tests you will be limited to solving the problems using a list of procedures and special forms that have been introduced in class. This allows us to ask you to program built-in procedures and places more emphasis on how well you can put together parts instead of how many convenience procedures you remember from the manual (of whatever Scheme you use). 6. DISCLAIMER The details of this course are subject to change as experience dictates. You will be informed of any changes.