Writing a definitive Coding Standard based on Logic would seem, at first, to be a daunting task. Even starting to put down new Coding Standards, in the wake of some others, like the PEAR Coding Standards, or the WordPress Coding Standard, or the Fellowship Technologies Coding Standards, is an humbling experience.
Nonetheless, I have come to realize the importance of a Coding Standard based on Logic. PEAR is based on Readability, WordPress is based on Cooperation (and Readability) and Fellowship Technologies has extensive Code Standards for HTML, CSS, and C, but has none for PHP!
Fortunately the concept of “Tightly Aligned Integrated Technology” (T.A.I.T. or TAIT) has been around since NASA launched Mariner 4 in the Mariner Mars Program in 1964. “TAIT” helped prevent the loss of Mariner 4, and enabled that spacecraft to beam to earth the first ever close up photos of another planet.
About 1972, a “TAIT-COMS” check prevented astronautical engineers from making errors with computer programmers working with the HAL and HAL/S systems.
It was 1971 that saw the beginning of the “TAIT Style” (or “T8” as we sometimes call it). It was on a high school field trip, sponsored by Bell Telephone, when a thought was presented that by structuring code, “goto” statements could almost be avoided while improving a number of factors in the program. In 1971 the whole TAIT Style was, “Don’t use “goto” statements, unless absolutely necessary!”
For everything there is a beginning…
David Tait ~ June 1972
The TAIT Style
Being based solely on Logic and what is Logical, T8 needs to have a way of coming to a conclusion to what is logical and what is not. To believe, for example, that every piece of code should be wrapped in parenthesis is not in and of its self logical. The fact that the code may execute perfectly, in an acceptable amount of time, for the purpose it was created, is not enough to say that the code is logical.
The TAIT Style has basically seven tests for whither a code is Logical. These form a kind of hierarchy or priority system in which NOTHING is unimportant. These seven tests are:
Poetry in Motion
Notice that Functionality is at the top, you could call this usefulness for a purpose. It is pointless to write code that does not work! Likewise Enjoyment is at the bottom. What is significant is not that Enjoyment is on the bottom, but that enjoyment is on the list! My friends over at WordPress say, “Code is Poetry!” Actually, that so inspired me that I actually wrote some small poetry as if it were computer code!
Code is Artwork!
I have found in my life that doctors and artist often occupy significant numbers on my friends list. Back before my enlightenment, I believed I had “no artistic bone in my body!” However, back in the early 80’s, a friend named Granny Bruns, saw me working on a computer output of a biorhythm program I’d been working on. I was highlighting each of the mapped waves on a print out about 3 feet long. You know, the cycles of mental, physical, and emotional energy we all go through. I was using different colors of highlighters in a sort of a “connect that dots,” fashion when Granny Bruns walked through (by the way, she was not related to me!). She saw it and thought it was beautiful. In time, I would make her a chart like this and she would have it framed and hanging in her dining room! Solid proof that computer programing is artwork!
Without a doubt we are pretty sure everyone reading this would agree Functionality is the number one priority on this list. Consider what kind of person would intentionally sit down to write code they expected to not work. Code that does not work is usually called “broken” and who would sit down to write some broken code?
Others would say ask why even include that? Here is the reason.
Functionality is actually “usefulness for a purpose!” In other words, in defining a Logic Coding Standard, it has to be useful for a purpose!
By defining the goals in your purpose, you will define when your code meets the test of functionality. Just remember that a Goal is both Specific and Measurable – more on that will come!
Logical Code Functions Well!
After Functionality has to be Maintainability. If you do not believe that, just head on over to any package site, like WordPress, phpBB, and SMF just to name a few, or your favorite program or CMS. You will see lots and lots of people complaining about broken code. Things change, it is Logical to anticipate these changes with code that can be maintained easily.
Logical Code is Easy to Maintain!
Within execution, one must consider speed. To be frank about it, we are not fans of the idea of speed for its own sake. If one code takes a few microseconds more or less than another code, when run a Zillion (that is a huge number) of times in a second, what difference does that make to my code? Far more Logical would be if there were really large differences in execution times. Likewise, people who work so hard for “one liners” … they usually inflate, or add extra code, to put on one line what I would use 10,000 lines for! (I only wish that was a joke!)
Execution needs to include things like Density (line complexity or number of statements per line), line volume (number of lines for broken statements. or line length (or shortness). All of these factor into execution and Logic.
Logical Code Executes Well!
If debugging is the process of removing bugs,
then programming must be the process of putting them in.
I had the opportunity to speak to Prof. Dijkstra and in a moment he changed the way I thought. I discovered that much of life, including programming, is largely base on what we do. The method we use to write programs, if it is logical or not, will determine how much debugging we will do on the same program.
Logical Code Prevents Errors!
The topic of readability of code is something that is getting a lot of talk. However, they are not really things you can separate. Execution depends in part on readability. It has been said that the best documentation is actually the code itself (therefore the code must be human readable!). Many people get joy from how readable their code is or enjoyment when the whole package comes together.
To understand how humans read, people can easily relate to the fact that virtually no one reads a line of a beloved novel at the same speed as reading the same length line of a complex mathematical equation! We are fairly certain that reading a line of computer code is likely easier than that mathematical equation. Likewise, we are equally certain that it is more difficult to read a line of computer code than to read the same length line of a novel or history textbook.
Therefore, it is only logical to assume that complex mathematical equation, computer code, and lines of a novel should, indeed, must be written in different ways for maximum understanding.
Logical Code is Readable!
Truthfully, I have never seen anyone coding away, mumbling to themselves, “I sure wish I could finish this program so I could start the fun of documentation!” We just do not like to go back and write documentation. Yet, the usefulness and longevity of any program is really built into the documentation. Having a good Code Standard for documentation is just one way of saying we actually do care about the quality of our code.
If you do not like to document you code and you think it is a huge waste of time… Then my prayer for you is that you get an excellent paying job maintaining code written by other people, as a company that discourages people to document. On the other hand, I do not know of any company like that!
Logical Code is Documented Code!
Finally, it seems to use that if you are not enjoying your coding, there is something drastically wrong! For 40 years I have been enjoying writing code, there is so much in code because code represents life itself.
Some have suggested that code and the bible are both so logical that a computer can easily understand them both. When you bend you mind, lend it to the way to code is, you begin to see life in new ways. If you are a fan of the movie, the matrix, do not try to bend the spoon! Just bend your own thinking!
You Will Enjoy Logical Code!
A Logical Beginning
We realize that the seven logical concepts of Functionality, Maintainability, Execution, Error Prevention, Readability, Documentation, and Enjoyment, are likely not what you are used to when reading about Coding Standards. Yet, that is exactly what the TAIT Style is based on.
THE LESSER-KNOWN PROGRAMMING LANGUAGES #10: SIMPLE
SIMPLE is an acronym for Sheer Idiot’s Monopurpose Programming Language Environment. This language, developed at the Hanover College for Technological Misfits, was designed to make it impossible to write code with errors in it. The statements are, therefore, confined to BEGIN, END and STOP. No matter how you arrange the statements, you can’t make a syntax error.
Programs written in SIMPLE do nothing useful. Thus they achieve the results of programs written in other languages without the tedious, frustrating process of testing and debugging.