4 Cognitive Biases in Software Development
A cognitive bias is a systematic error in thinking. It affects our process of decisions and clouds our judgment. Nobody is imune to it. The best we can to avoid them is to understand them. With the right mental models, it becomes easier to identify situations where biases are driving the narrative.
Anchoring is type of bias where an initial piece of information - the "anchor" - heavily influences judgment, decision making and estimates.
When estimating the completion time of a task, we rely heavily on any number that has been mentioned before. If people are asked in order what they think the effort is, the person who says the first number sets a precedent to all subsequent estimates.
Techniques like planning poker, where participants flip a card with their estimate a the same time, help avoiding this type of bias.
◆ "She estimated 5 days to complete the task. After hearing it, the rest of the team all agreed on the same number."
Confirmation bias is the tendency to pay extra attention to sources that confirm our own beliefs and values.
When writing software tests, we typically follow a positive test strategy. That is, we tend to use inputs in our tests that favour our hypothesis of "this software works". Inputs that are inconsistent and likely to break the program are left out.
- "The tests were written only using consistent and nicely formatted data. We should have used inconsistent inputs."
It can also affect debugging. When resolving an issue, we tend to overlook anything that we belive is not the cause.
- "This microservice never broke in production before, so it cannot be the root cause of the problem."
We are more interested in solutions handcrafted by ourselves than existing options created by others. The effort of working on the solution is enough to create a bias towards it.
- "Instead of using a blogging platform, I am going write my own static site generator to create my blog from Markdown files."
- "I am writing the same SQL queries every time, I should create my own ORM library to avoid repetition."
Optmism bias is the tendency to be too optmistic and understimate the probability of negative events to happen.
When estimating how much time will be needed to complete a task, an optmism bias takes effect and causes us to understimate the time. This is known as the planning fallacy. What's interesting is that it only affects our own tasks — we tend to be pessimistic when estimating tasks for someone else.
- "I only have to fix the DNS issue on AWS and I'll open the pull request. It should be done tomorrow morning."