Computer Science 171
Introduction to Computer Programming

Dr. Stephen Bloch

office 113A Alumnæ Hall
phone 877-4483
email sbloch@adelphi.edu
Web page http://www.adelphi.edu/sbloch/
Class Web page http://www.adelphi.edu/sbloch/class/171/
office hours 9:00-12:00 Wednesday, 3:00-6:00 Tuesday & Thursday
January 21, 2004

1  Subject Matter -- Overview

Computers do many of the same things people do, only faster, more accurately, and without getting bored. Accordingly, the task of programming a computer is essentially the task of figuring out exactly how you would solve a particular problem, and then explaining it to the computer. Unfortunately, computers are literal-minded and completely devoid of intuition, so your explanation must be much more precise and unambiguous than if you were explaining things to a human being. This course, therefore, is about how to analyze a problem, figure out precisely and unambiguously how to solve it, and present this explanation to a computer.

In a broader sense, this course is about problem-solving, and about a particular way of approaching the world which we may call algorithmic thinking. I consider computer science a "liberal art" providing training in how to think, regardless of whether you choose it as a profession.

2  Who Should Take This Course

This course assumes that you have either some previous programming experience (say, half a year with decent grades) or a strong mathematical background (this course doesn't actually use a lot of mathematics, but it often requires a mathematical way of thinking). If you have never written a program before, you might be better off in CSC 160, "A First Course in Computer Programming" instead; consult with the instructor. Aside from that, the course is open to computer science majors, minors, and others who just want to learn more about computer programming.

If you're a computer science or information systems major, you should take this course as early as possible, preferably in your first or second semester at Adelphi. If you're a computer science minor or a math major, you should take this course in your first two years at Adelphi. If you have no interest in writing programs of your own, but simply want to use Web browsers and search engines, spreadsheets, databases, word processors, etc. and perhaps write your own Web pages, you should take CSC 170 instead.

3  Subject Matter -- More Details

3.1  "Good" Programs

What distinguises a "good program" from a "bad program"? Obviously, a good program has to work correctly and reliably  -- a difficult goal in itself, as we'll see. But this is far from enough. In practice, very few programs are written once, used for a while, and discarded: much more often, a program is used until the need for it changes, the program is modified (often by a different programmer) to handle the new requirements, the modified program is used for a while, and the cycle repeats. Thus a "good program" must be not only correct the first time around, but structured in such a way that it can easily be modified to accomodate likely changes in requirements. To get across the point of modifiability, I may occasionally change the assignment slightly on the day that it's due. So whenever you get an assignment, you should immediately start thinking "how is Dr. Bloch likely to change this at the last minute?" and prepare for such a change. If implementing the change takes you an hour or more, you didn't design the program well for modifiability.

There are other criteria for a "good" program, in addition to corrctness and modifiability: fault-tolerance, efficiency, user-friendliness, etc. You'll learn more about these in subsequent computer science courses.

3.2  Kinds of Knowledge

A first programming course is in some sense an almost impossible task. In one semester, you'll be asked to learn several different kinds of knowledge:

  1. How to use the computers and the software on them

  2. The grammar, punctuation, and vocabulary of a programming language

  3. How to analyze a problem and design a program to solve it, so that the program is both correct and easy to write, read, modify, and repair

  4. How to plan your time, and what sequence of steps to go through, in designing, writing, testing and debugging a program

  5. Domain-specific knowledge (e.g. to write a program that draws geometric shapes on the screen, you have to know something about geometry.)

It is easy for a student (or a professor or a textbook author, for that matter) to get caught up in the details of the first two at the expense of the rest. I urge you not to fall into this trap, because the specific kinds of computers and software, and to some extent the language, you learn this semester will almost certainly be obsolete by the time you leave Adelphi. The much more interesting and lasting knowledge is at levels 3, 4, and 5 (and I'll try to minimize the time we spend on level 5 because it's not specific to computer science). In short, although all five kinds of knowledge are necessary in order to write a good program, I'll try to concentrate on levels 3 and 4.

3.3  Language and design recipes

Programming a computer requires that, to some extent, you learn the computer's language. Computers "understand" a lot of different languages, and the choice of language affects how you approach programming. This semester we'll be using the popular and powerful Java language; other students in other semesters may start in other languages such as Scheme, C++, Visual Basic, or Eiffel.

We'll pay a lot of attention to design patterns, which are step-by-step "recipes" for getting from a vague English-language description of a problem to a working computer program. Every year, some students skip the recipes when they're in a hurry, and invariably find themselves wasting more time as a result. To prevent this, you will be graded on, among other things, how well and thoroughly you use the recipes.

3.4  Knowing your Tools

If you wanted to learn carpentry, you would start by studying the characteristics and capabilities of each of the common tools carpenters use, so you use the right tool at the right time for things that it does well. In programming, although you have editors, compilers, etc. to help, your main tool is your mind; accordingly, it makes sense to study the characteristics and capabilities of your mind. Indeed, it can be studied and measured just as scientifically as a bouncing ball in Physics class. By the end of the semester, you should have a much better idea (backed up with hard numbers) of how you work as a programmer, and hence the ability to accurately estimate how long you will need to complete a specified programming task. This allows you to plan ahead and complete assignments on time -- an invaluable skill for a professional programmer, and applicable to the (non-programming) rest of your life as well!

4  Texts

We'll use the textbook Computing Concepts with Java Essentials, by Cay Horstmann (J. Wiley 2002, ISBN 0-471-24371-X) for most of the course material.

For more level-4 knowledge, we'll use Introduction to the Personal Software Process, by Watts Humphrey (Addison-Wesley 1996, ISBN 0-201-54809-7). This book discusses how to keep track of problems you encounter in programming, so as to prevent them in the future, and how to manage your time so as to finish programming assignments before they're due. (The easiest way to fail my class is to fail to turn in homework assignments!)

I've also arranged to use an on-line tutoring system called CodeLab, which provides a bunch of very short programming exercises that you can have graded automatically (so you don't have to wait for me); when you get something wrong, you can figure out why, fix it, and re-submit as many times as you like. You can try the system for free for the first ten days of class, after which (if you're still in the class) you'll need to pay $25 to continue using it.

You'll need to read, on average, around 40 pages a week. Make time in your schedule for this much reading, as well as for programming assignments. You are responsible for everything in the reading assignments, whether or not I discuss it in a lecture. You are also responsible for checking my class Web page at least once a week or so; I often post assignments, corrections to assignments, solutions to assignments, etc. there.

5  Grading

I expect to give eight programming assignments, one every two weeks or so. Most assignments are to be turned in by email, and will be considered late if the time stamp on the email is after midnight on the assigned due date. Assignments will lose credit Any homework assignment turned in after midnight, Tuesday, May 4 (the last day of class) will get a zero.

I also plan several brief in-class quizzes (say, 15 minutes each), mostly on level-2 language issues. Which I said I wasn't particularly interested in, but you do need to know it in order to do your assignments, and these quizzes seem the best way to make sure everybody learns the language. Each quiz will count for 2% of your semester grade. Quizzes cannot be made up; if you're not there the day I give the quiz, you get a zero on it.

You are expected to work through a number of (very short) self-grading exercises in CodeLab in the course of the semester. About 10% of your semester grade is based on what fraction of them you complete successfully. Remember, you can re-submit a CodeLab problem as many times as you wish, and you'll know immediately whether it was correct, so this may be the easiest 10% of your grade.

We'll have a two-hour final exam from 1:00-3:00 on May 13, weighted the same as two programming assignments. I'll also assign a "brownie points" grade, weighted the same as one programming assignment.

Thus if there are 6 quizzes and 8 programming assignments, then each quiz will be worth 2% (for a total of 12%), the CodeLab exercises will be 11% (to make the numbers work out nicely), each programming assignment will be worth 7%, the final exam will be worth 14%, and the "brownie points" (my purely subjective judgment of how seriously you're taking the course) another 7%. The precise numbers may vary a little from this. The final exam must be taken at the scheduled time, unless arranged in advance or prevented by a documented medical or family emergency. If you have three or more exams scheduled on the same date, or a religious holiday that conflicts with an exam or assignment due date, please notify me in writing within the first two weeks of the semester in order to receive due consideration. Exams not taken without one of the above excuses will be recorded with a grade of 0.

6  Program standards

Every program must contain, in the first few lines, a comment indicating the name(s) of the student(s) working on it and which assignment it is. Programs not containing this information, clearly visible, will get a zero.

Every program must be accompanied by test cases, so I can see how it actually works. Programs with inadequate or poorly-chosen test cases will lose points (we'll discuss how to choose good test cases); programs turned in with no test runs at all will lose lots of points.

Having done my share of programming, I know that sometimes you hit a brick wall and cannot get the thing to work for love or money. If this happens, turn in the program together with a detailed description of how the program fails, what you've tried in your attempts to fix it, and how those attempts didn't succeed. You won't get full credit, but if I'm convinced that you're working on it diligently, you'll get partial credit. Note that "how the program fails" does not mean saying "I got an error message": you need to tell me which error message you got, when you saw it, and what you think the error message means. Similarly, if the program fails by producing wrong answers, you need to tell me when it produces wrong answers (are they all wrong, or just in a few cases?), how they are wrong (e.g. are all the numbers consistently higher than you expected, are they the negatives of the correct answers, or are they all over the place with no apparent pattern?), and your speculations on how such an error might have arisen. I'm requiring all this not because I'm mean and horrible, but because by the time you've written all this down, you may have enough information to actually fix the problem, which is much better than turning it in incomplete.

I also expect you to maintain a log of what kinds of errors you encountered, how you discovered them, how long it took you to fix them, and what the actual problem was. This log must be turned in with each homework assignment. I've written some Web-based forms to make it easy to record this stuff, or you may just keep track of it yourself.

7  Ethics

Most homework assignments in this course involve writing, testing, and debugging one or more programs. Some of these programs are to be written individually; for others, you are to work in teams of two students, switching teams from one assignment to the next, if at all possible. (If you have a really terrible schedule and can't get together with a partner, talk to me and we'll arrange something.)

When I say "teams of two students", I don't mean "you write the first half of the assignment, and I'll write the second half"; I want both students working together on all of the assignment, using the techniques of Pair Programming (on which I'll give you a reading assignment). I expect people to switch partners from one assignment to the next, so you get experience working with different people.

It's hard to define what constitutes "cheating" in this sort of course. Students are encouraged to help one another with level-1 and level-2 difficulties ("how do I save this file?", "what's the syntax for declaring a variable?", etc.), regardless of whether they're on the same team, but designing, coding, testing, and debugging should be done by the one or two people whose names are on the assignment.

It's remarkably easy for a professor to notice when three different teams have turned in nearly-identical programs; if that happens, I'll grade it once and divide the credit among the three, so the best any of them can hope for is 33%. I don't try to figure out who copied from whom; it is your responsibility to not let anyone copy your homework. Among other things, that means don't leave it on the "Universal Share" drive, because anyone at Adelphi can copy it and even delete it.

All work on the final exam and the quizzes must be entirely the work of the one person whose name is at the top of the page. If I have evidence that one student copied from another on an exam or quiz, both students will be penalized; see above.

8  Schedule

This class meets every Tuesday and Thursday in Science 227, from 1:40-2:55 PM.

All dates in the schedule are tentative, except those fixed by the University; if some topic listed as taking one lecture in fact takes two lectures to cover adequately, or vice versa, the schedule will shift. I'll try to keep this information up to date on the class Web page.

I expect you to have read the reading assignments (an average of 20 pages per lecture) before the lecture that deals with that topic. This way I can concentrate my time on answering questions and clarifying subtle or difficult points in the textbook, rather than on reading the textbook to you, which will bore both of us. Please read ahead!

When I say "read" above, I mean an active process, involving not only the textbook but pencil, scratch paper, and a notebook for writing down key points. Finally, and perhaps most importantly, you'll need a computer for trying out the new ideas you find in your reading. Just as you cannot learn about cooking or driving a car just by reading about it, you cannot learn about programming just by reading about it. In short, every time you read about a new programming idea, try it!

Last modified: Wednesday, January 21st, 2004
HTML conversion by TeX2page 2003-08-03