For my relatively little work experience (about 6 years), I often heard phrases of experienced and novice programmers - “I feel that this should work”, “I have a feeling that this method will not work”, “Let's do an intuitive intuitive interface "and so on. All this is a manifestation of intuition in the process of development and programming.
About her and go on to talk.
Taken from oprah.comTo begin with, I would like to define the very concept of “intuition”.
Intuition (late lat. Intuitio - "contemplation", from the verb intueor - I look closely) - a method for solving problems through a single-step subconscious inference, based on imagination, empathy and previous experience, "sense", insight .
')
Wikipedia
Intuition (from the Latin. Intueri - closely, carefully look) - the thinking process, which consists in almost instant finding solutions to the problem with a lack of awareness of logical connections.
Intuition (from the Latin. Intueri - closely, watch carefully) - knowledge that arises without awareness of the ways and conditions of its receipt, whereby the subject has it as a result of "direct discretion"
The basis of these definitions is that intuition is some kind of decision-making method. There may be several reasons for this method: this includes previous experience, imagination, irrational "flair", etc.
And each of these methods is reflected in the programming process, and can have both positive and negative effects.
Therefore, first of all, I would like to divide the “intuitive” programming into 2 components: -
optimistic and pessimisticOptimistic intuitive programming
Its essence lies in the optimistic or positive influence of intuition on the process of creating code. In this case, the intuition is an assistant, "good friend", a tool in the hands of the developer.
Experience based intuition
The main idea here is that in the process of accumulating development experience we form certain stereotypes and associations associated with the code, which we are able to determine without going into the thought process.
Dmitry Chepel from Acronis described a large number of examples of using such intuition in work processes in his
article on Habré . If you have not read, be sure to read.
I would like to offer you another example experiment. Below is a sample code in the Sidef language (I hope not many of you know it). Try not really delving into the details, guess what it is:
loop { var swapped = false { |i| if (arr[i-1] > arr[i]) { arr[i-1, i] = arr[i, i-1] swapped = true } } * arr.end swapped || break } return arr
AnswerThis is a classic bubble sort.
Perhaps some of you guessed what was going on, seeing familiar parts in the code, maybe some not. I tried to conduct this experiment on a small group of my fellow programmers and the result is as follows - more than half (about 65%) of people could understand what was going on in a very short time.
I asked them how they were able to guess - and the most popular answer was:
"We saw familiar pieces of code and immediately assumed what it is."
Thus, by accumulating experience, our brain is able to make decisions very quickly without additional mental effort regarding the code with which we work.
It is because of this that it seems to us that more experienced programmers have a certain “sense” about a project or some programming language.
Logic-based intuition
Try to continue the next row:
1, 3, 5, 7, 9, 11, ...
Surely you never for a second thought about what number will be next.
This is a simple example of a pattern that we can literally continue.
But what if you take for example the following piece of Python code:
def sum(a, b): ... def mult(a, b): ... def subtract(a, b): ... def divide(a, b): ... def calculate(a, b, strategy): ... calculate(4, 2, sum)
Even without seeing the source code, we "intuitively" feel what the result of the last function in the list will be.
This is due to the fact that we analyze the names of the functions, compare them with the result, and thus build some patterns, assumptions about the code being analyzed. Thus, we connect our intuition, backed up by logic, to read such code.
Here I would like to note that the code that corresponds to our assumptions, our intuition, we usually call “readable”, “understandable” code. This is due to the fact that we use not only the resource of our brain, but also our intuition, thereby simplifying the reading and understanding of the code.
Intuitive interface
And now I would like to turn to such an often used expression as “an intuitive interface”. This applies to both software and user interface.
Given the above points, we can say that the intuitive interface is an interface that meets the user's expectations, be it a programmer or an end user.
These expectations are formed on the basis of 2 components - our previous experience and logical laws and assumptions.
If on all the pages of your website the menu was on top, but on the Feedback page of the menu on the left, then the end user may be confused because “his intuition” tells him that the menu should be on top.
But why sometimes, when we go to a website with an original design or a new mobile application, do we get the feeling that this website looks cool or awful?
Intuition as irrational
The basis of such a judgment is that often intuition is born as just a feeling of something, not supported by any conclusions, logic or experience.
This kind of intuition is the most dangerous in development, but at the same time it is a way to quickly solve complex problems.
This is exactly what is called "magic" in programming - we change the value of a single variable or flag and miraculously our code starts working, although this decision was made absolutely instinctive. And just this kind of intuition is its true manifestation.
Pessimistic instinctive programming
But intuition can be negative in development.
As mentioned above, the “irrational” intuition is both a lifesaver and a dangerous tool in the hands of a programmer.
Based on such instinctive decisions, we lose confidence in the code we write, in which "magic" begins to occur.
Importantly, such decisions form some level of concern when making subsequent decisions. The predominance of feelings, sensations, irrational when developing leads to the impossibility of justifying everything with the help of logic, and as a result - complicating the understanding of the code, loss of readability.
As a conclusion
In general, the issue of intuition when developing software is raised not for the first time.
This is due to the fact that the problem of the influence of processes unrelated to logic and thinking on the process of writing code will remain relevant, since this process is occupied by a person with feelings, prejudices, “irrational”.
PS For those who are interested in the topic of intuition in software development, I advise you to read
Peter Nauer's report “Intuition in software development”Thank!