﻿# Myths about static analysis\. The second myth \- expert developers do not make silly mistakes

While communicating with people on forums, I noticed there are a few lasting misconceptions concerning the static analysis methodology\. I decided to write a series of brief articles where I want to show you the real state of things\.

The second myth is: "Expert developers do not make silly mistakes that are mostly caught by static code analyzers"\.

This is how this statement looks in discussions on forums \(this is a collective image\):

_I,_ _a_ _skilled_ _developer_, _haven't_ _had_ _any_ _problems_ _with_ _memory_ _spoiling_, _object_ _lifetime,_ _etc_\. _for_ _N_ _years_\. _Static_ _analysis_ _is_ _a_ _tool_ _for_ _"McDonald's"_, _and_ _here_ _\(on_ _a_ _professional_ _forum\)_ _there_ _are_ _only_ _geeks_\. _Now_ _I_ _mostly_ _face_ _problems_ _with_ _difficult\-to\-test_ _algorithms_ _and_ _integration_ _with_ _other_ _developers_ _using_ _implicit_ _contracts_ _on_ _object_ _states\._ 

It sounds as if typos and inattentive mistakes were solely the work of amateurs\. Professional developers have not made them for a long time and now mostly deal with such complex errors like synchronization issues or complex data processing algorithms\.

It is not so\. All the programmers make silly mistakes\. I know that you haven't heard me, so I repeat this heretical thought once again: all the programmers make silly mistakes\. It doesn't matter how skillful they are\. To err is human\. Errors they make are most often very simple\.

Programmers take my statement about errors with great unfriendliness\. In their opinion, they are those who haven't made such mistakes for many years\. I think it is the effect of an interesting aspect of our psyche that sifts memories about unpleasant moments of the programming practice\.

Let's digress from our subject a bit and recall why various horoscopes are so enduring\. The first reason is very vague formulas that one can easily apply to oneself\. But we are interested in the second point: people do not remember cases when a prophecy didn't come true\. But they do remember and tell the others about those cases when some situation in their life coincided with one described in a horoscope\. So it turns out that when we speak about and recall horoscopes, we find N evidences that they work and do not remember about N\*10 cases when they did not work\.

Something like that happens to a programmer when searching for errors in code\. You remember complex and interesting errors very well and can discuss them with your colleagues or write a blog\-post about them\. But when you notice that you have written 'BA' variable instead of 'AB', you will simply fix the bug and the fact will slip from your memory\. Freud noticed one peculiarity of our memory: one tends to remember positive statements about oneself and forget negative statements\. If a person fights a complex error in an algorithmic task, when he finally fixes it, he considers himself a hero: this fact is worthy remembering and even telling the others\. But when a programmer finds a silly bug, there is no reason and wish to remember it\.

What proofs do I have? Although most misprints and bugs get fixed finally, some of them remain unnoticed in programs\. A lot of examples of these you may find in [this](https://pvs-studio.com/en/blog/posts/cpp/a0077/) article\. You will see that it were not novices who made the mistakes cited in the article, but skilled programmers\.

The conclusion is: programmers spend much more time on fixing misprints than they think\. Static analysis tools can help to significantly save developers' efforts, detecting some of these errors before the testing stage\.