No, this is not a typo. This post is not about structures, but about code textures.
To explain what it is and why this concept is important to me, I will tell you one story.
It was a long time ago, in the late seventies of the twentieth century. We then programmed one large (at that time) system. The concepts of IDE (Integrated Development Enviropment) did not exist yet and we used the Editor to enter the program code.
The Editor we used had one interesting feature. Downloading a file with program text from the disk, he first showed it, “scrolling” on the monitor screen from the first line to the last. The downloadable text ran very quickly before my eyes, so it was difficult to make out individual lines at that time.
')
One morning, my colleague, who worked at the next table, suddenly said loudly: "Oh, what a beauty!". He was not a very emotional person, and therefore we were interestedly went to his table in order to understand the reason for this delight.
It turned out that on the eve he received the task to slightly correct the program, written earlier by one of our gurus. For viewers who had gathered behind him, he turned on the loading of the program text from the disk again. And lines of program code quickly floated across the screen from bottom to top. But these were completely different textures from dots and dashed lines than those we are used to. They were full of harmony and some kind of magic. They were really rarely beautiful and literally fascinated. I thought then: “Can such code be wrong?”
Clear maybe. Since then, I have reviewed, sometimes analyzed, sometimes corrected or wrote millions of lines of program code in various 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 kind of “optically harmonious”.
However, I must make a reservation. This rule applies only to hand-written code. Generators produce sometimes very structured, but full of error code.
Code Structures and Textures
Well, we almost agreed on the concepts. In contrast to the classical structure of the program code, which is defined by splitting it into its component parts and the format of individual parts, by the texture of the program code we mean its visual presentation on the screen.
It is clear that the textures that we saw then, in the seventies, or which today can be seen on modern high-resolution monitors, are ultimately a reflection of the structures of the program code.
When it comes to software code structures, programming patterns (patterns) almost automatically come to mind.
In my opinion, the use or non-use of classical programming patterns has little effect on whether the code is “beautiful”.
Very different structures affect the beauty of the code. These structures can be divided into several hierarchical levels.
The first level today is provided by well-configured code editors built into the IDE. They automatically trim indents, add forgotten brackets and other characters, and also generate properly formatted skeletons of the code of standard methods or functions.
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 have a decisive influence on the texture of the code and its “beauty”.
Obviously, the optical beauty of the code is not the goal of professional programming. And yet, when I see optically elegant code designs, I am often drawn to scroll the code further on the screen and, maybe, to see a couple more nice code textures.
Instead of conclusion
So what did I want to say with this note? Here's what:
Code structures reflect thought structures.
Code textures display code structures.
Thereby: The texture of a code is one of the materializations of thought.
If the program code turned out to be optically beautiful, it means that the creator's thoughts were elegant. And elegance and thinking style are inalienable signs of high professionalism.
And in the end - my appeal to programmers:
Pay attention and enjoy the beautiful code textures, if any. This pleasure is available only to people of our profession.