A Sigma 7 system |
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.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.
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.
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:
Post a Comment