Monday, November 28, 2011

Consistency

A Sigma 7 system
Here's a short, funny (or maybe just mildly amusing) story I remember from our introductory programming course in college. Yes, back in 1970, most of us didn't learn to program a computer until we got to college. And then, it was on a large computer that everyone had to share. No one had a personal computer at that time and there were not even minicomputers in any of the departments. Our school, Bucknell University, was more advanced than most, though. There were computer terminals all around the campus for us to use to interact with the main computer, a Scientific Data Systems Sigma 7. SDS was later bought by Xerox.

We first learned programming using BASIC and once we got to needing to write larger programs, we switched to FORTRAN. That was FORTRAN IV. I remember one of my big hurdles to learning FORTRAN was that you didn't need a line number for every line like you did for BASIC.

Anyway, our teacher was writing down three qualities of a good subroutine. I'll list them similarly to how he listed them. The explanations are my ideas from what I know now (this all happened 41 years ago - I'm lucky to remember that he made three points!). Back then, he just wrote three words and then explained in the lecture what he meant.
1) A subroutine should be reusable. The idea was to not have to rewrite code and a subroutine allowed you to use one piece of code over and over. While it might help to organize your code to write a subroutine for a piece of code that was only used once, you generally didn't want to do that.

2) A subroutine should do only one thing and do it well. This meant it should be simple to understand and simple to test. This allowed you to use it with confidence in other places.

C) A subroutine should be consistent. For instance, you shouldn't have a bunch of subroutines that take their arguments in degrees (for angles, not temperature) and then have one subroutine that takes its arguments in radians.
A few people noticed the problem and then, in a matter of seconds, everyone was enjoying the joke. Everyone but the professor! He didn't see the problem until one of the students pointed out the in-consistency of his list. But once he saw it, he, too, enjoyed the extra joke that the error would come on the Consistent item.

By the way, the picture here is from the CR4 Blog entry "On This Day" in engineering history for October 29, 1969. It talks about what many consider the first message sent between computers on the U.S. Department of Defense's Advanced Research Projects Agency network (ARPANET) - the precurosr to the Internet. The message was between a SDS Sigma 7 and a SDS 940.

No comments: