Knowing When
In the 70’s I learned computer programming on my own. I used an acoustic coupler and a 300 baud modem calling from Northern Virginia Community College to the University of Virginia via a campustie line. My ‘terminal’ was an ASR33 commonly used for comuters and Telex messages. Programs and text could be stored on the punched tape reader/punch. That was your backup!
I started with Time Shared Basic, learned Fortran, COBOL, SPL, PL1, assembly and a few other languages. I was not an expert in any of them but could get by. I never flowcharted a program though. Flowcharting is a way of dicumenting how the flow of actions in the program work. A flowchart of a lightbulb is includd here so that non-computer people will get it.
In computer programs you might have an input where you accept data from somewhere and check to see if it meets certain criteria and then either display an error message and ask again, or continue with the data to another step. The flowchart allows the programmer and others to see general steps which are or could be taken.
So I took on the task fairly early in my programming experience of creating an Inventory System for a live TV event hosted by a Public TV Station. Later I wrote utilities and other fun programs and started working for a company making a graphics program.
In the 80’s I was working for Hewlett Packard which was a major computer manufactorer. I was a System Manager tasked with keeping the computers running. I had no college degree and as I say, mostly self-taught with a couple courses at the community college.
After a numbet of years a programmer came to me with a problem. He needed to find a way to speed up his program which took a value from the user and searched a large database for that value. It always took a lot longer than he expected. You should know that there were multiple ways to search the database. One would have been very quick which he could not do. That might be saying I want to find Account Number 123. Since the master record for 123 would be a unique entry (no two people had the same account number), that would be a quick search and many computer programmes would make a a key so that you could just go directly to that location. That is sort of like going to the Post Office and going directly to your mailbox because you know exactly where it is. The second way is to do a sequential search, similat to what you might do driving down a new street, looking at house addresses. That sequential read takes longer. There are other searches such that if you know there are 100 boxes and you want number 76, you could jump to the middle box and eliminate the first half, and so on.
So anyway, this guy had a search for an item which was unique but not in a specific order. Imagine Bank Accounts numbered 1 to 1,000 in order, but you are looking at the owners last name field and you know that there is only 1 account per person. So account 1 might have a last name of SMITH and account 2 having JONES and so on. Now you see what he was doing.
His problem was that the search was searching hundreds of thousands of records fo that one item hidden in the records and he told me that it should not take that long every time.
In seconds I suspected what he did wrong and looking at his code I was able to fix it in just a minute or so.
The search should be something like this in simple terms:
—
Accept name to search for
GET THE NEXT RECORD
Is the name in the record the same as the one I am looking for?
If there is no more records, go to EXIT PROGRAM
If the name is not there, got to GET THE NEXT RECORD
If the name is found, copy the data to the printer and go to EXIT PROGRAM
EXIT PROGRAM
—
Since the search took forever (almost the same time every name) I knew the problem even without looking at a flowchart.
The search took ‘forever’ in computer time every time he ran it. He had forgotten the statement that said once he found the data and copied it to ectually exit the program. He was letting it run through all records even after he had found the one and only match many records earlier.
You see, it is easy to get started with something and just keep going. The real skill is knowing when to stop!
It reminds me of asking a guy what time it is and he tells you home to build a watch.