Myths about static analysis. The second myth – expert developers do not make silly mistakes

Today we will talk about the second myth about static analysis.


The first myth – a static analyzer is a single-use product

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 these articles. 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.

2 thoughts on “Myths about static analysis. The second myth – expert developers do not make silly mistakes

  1. Pingback: Myths about static analysis. The third myth – dynamic analysis is better than static analysis | How Not To Code

  2. Pingback: Myths about static analysis. The fifth myth – a small test program is enough to evaluate a tool | How Not To Code

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.