Thursday, April 9, 2020

Art of Programming - [ PTQ ] == [IPO]

During this modern era of technology, many are seeking computing skills. One of the most prized of those skills is computer programming.

The author had his first experiences programming a computer during his fourth grade summer. This was with the BASIC language. And, that was during 1979. The wisdom of a hoary head and decades of coursework plus professional software development experiences has taught three simple concepts: PTQ or equivalently IPO.

From his early days, in formal computing courses at Vanderbilt among the dorms in the freshman quadrangle during the Spring of 1989, he saw something simple. intrinsic, and fundamental in the construction of all computer programs.

These primitive and fundamental parts were P, the preconditioned input, T, the transformations on the input that occur in the internal portions of the program, and Q, the post-conditioned output. In fact, during those days of his Pascal course, well-taught by a female graduate students whose name he has long forgotten, he penned some notes in his primary red Mead notebook, intended for his prose fiction course, concerning this.

He noticed that programs have three basic parts, I - input, P - processing, and O - output. The input can be null or the output can be null. But, some form of "processing" or "work" must be done, otherwise one would not make use of the computer program.

The first program that most students of software development learn is "Hello, World!". It is a program which will simply place this output on the computer's, tablet's, or phone's screen.

Once a student has learnt how one places output on the console, he has mastered one of the three abstract and primary skills which he must have in his toolkit for a career as a successful software developer.

The second skill one must learn is how one reads in input. Every computing language has numerous means for reading input. This could be from the console, from a file on the computer's file system, or a source on the computer's network such as a web-page. The mechanisms for doing so are similar within a language. Usually, most students first learn how one reads input from the computer screen, the console.

So, the second step in writing a "standard" program is reading input from the screen and simply outputting it again. This might be a program that reads in a person name, such as "Millicent", and printing a message, such as "Hello, Millicent! We are keeping up appearances!"

Yet, simply reading in data and echoing it on the screen, even if it has some interesting textual annotation, is not highly useful.

In comes the process. Processing takes the input which has been supplied and transforms this data so it is in a meaningful form. Then, this altered data, in the form of new, relevant information, is output.

So, when one is faced with writing a program, he must ask himself treat basic questions first.


  1. What is the input and where can it be obtained from the console, a file, the network, or etc?
  2. What information should be output once the input data is obtained?
  3. Finally, how must the input data be processed and transformed so it produces accurate and useful output information?


Input. Process. Output [ IPO ]

So, this answers some questions about the art of programming, but what is this PTQ acronym.

The P stands for precondition. For most, if not all programs, the supplied input must be in a valid range of values. If a teacher were entering grades in a program which will determine a semester's average, a input grade less than zero or greater than one hundred would be out of range. Plus, this input should be numeric and not alphabetic. If creating a well-written and robust program that most likely will not crash while processing, one should check any input and make sure that it is in an acceptable range for any internal computation which will be done.

Yet, one "got-ya" exists with checking preconditions. They require more programming instructions. And, these commands which validate the input by checking its range might be erroneously written.

The T in PTQ is a synonym for the P in IPO. It is simply the internal computations which one uses when working with the input and producing the output. These transformations can be drawn from the pool of commands built-in a computer programming language or the many libraries and packages of commands composed from various combinations of these built-in instructions which are available with these "built-ins" in all modern programming languages.

Finally, the Q is a symbol commonly used in logic courses for post-conditions when discussion proofs about reasoning. So, we use it here, since a program is an instance of logical reasoning represented in a language which a computer can understand. After we have produced output, we can verify that it is in a valid range of acceptable and expected values. So, in the example of a teacher entering assessment scores from the semester, the final grade for the term should be between zero and hundred.

Checking these conditions, both on the "entry" and "exit" of a computing routine when validating input and verifying output, is a crucial part of producing robust programs.

So, after one asks himself the three questions about IPO above, he should ask himself the following questions.


  1. What are the valid ranges of values for the inputs?
  2. Will the chosen processing transform the input properly and produce the expected output?
  3. Is the output produced in an acceptable range of values and reasonable based upon the input and chosen transformations?

And, with a hand-waving summary including a flourish of wild gesticulations, that is basically the general abstraction at the center of the art of computer programming.

No comments:

Post a Comment