Code Textures


No, this is not a typo. In this note, we are not talking about structures, namely, textures of program code.
To explain what it is and why this concept is important to me, I will tell you a story.
It was a long time ago, in the late seventies of the twentieth century. We then programmed one large system. The concept of IDE (Integrated Development Enviropment) did not yet exist and we used the Editor to enter the program code. The editor we used had one interesting feature. By loading a file with program text from a disc, it first showed it, “scrolling” on the monitor screen from the first line to the last. The loaded text ran very quickly before my eyes, so it was difficult to recognise the individual lines on fly.
One morning, my colleague, working at a nearby table, suddenly loudly said: “Oh, what a beauty!”.
He was not very emotional, and so we went to his table with interest, in order to understand the reason for this enthusiasm.
It turned out that on the eve he received a task to slightly correct the program written earlier by one of our gurus. For the audience behind him, he again turned on the loading of the program text from the disk. And the lines from the bottom up quickly swam on screen. But these were completely different textures from dots and dashed lines than those to which we are accustomed. They were full of harmony and some kind of magic. They were really rare beautiful and literally mesmerized. I thought then: “Can such a code be wrong?”
Clearly, maybe. Since then, I have looked through, sometimes analyzed, sometimes corrected or written millions of lines of code in a variety of programming languages. And in most cases I was convinced that good programmers give out “beautiful” code and high-class ones – not just “beautiful”, but also some “optically harmonious” code.
However, I must make a reservation. This rule applies only to manually written code. Generators sometimes give out a very structured, but full of bugs code.

Code structures and textures

Well, we almost agreed on the concepts. Unlike the classical structure of the program code, which is defined by splitting it into component parts and the format of individual parts, by the texture of the program code, we mean the visual representation on the screen.
It is clear that the textures that we saw then, in the seventies, or which can now be seen on modern high-resolution monitors, are ultimately a reflection of the structure of the program code.
When we think about to code structures, almost automatically the patterns (patterns) of programming come to the head.
In my opinion, the use or non-use of classical programming patterns has little effect on whether the code will turn out to be “beautiful”.
The beauty of the code is influenced by very different structures.
These structures can be divided into several hierarchical levels.
The first level is provided today by well-configured code editors built into the IDE. They automatically truncate indents, add forgotten brackets and other symbols, and also generate correctly formatted skeletons for code of standard methods or functions.
The structures of the second level depend on the choice of responsibility for individual program blocks (for example – classes or methods), the implementation of inheritance and the grouping of small blocks into large ones. It is these second-level structures that decisively influence the texture of the code and its “beauty.”
Obviously, the optical beauty of code is not the goal of professional programming. And yet, when I see optically elegant code constructs, I often want to scroll the code on the screen further and maybe see a couple of nice code textures.

Instead of concluding

So what did I want to say with this note? And here’s what:

The structure of the code reflects the structure of thought.
Code textures represent code structures.
Thus: Texture code – this is one of the materializations of thought.

If the code turned out to be optically beautiful, then the creator’s thoughts were also elegant.
And elegance and style of thinking are indispensable signs of high professionalism.
And in the end – my appeal to programmers:

Pay attention and enjoy the beautiful code textures, if any, you will meet. This pleasure is only available to the people of our profession.