Just another way of fixing bugs
Every developer has to manage with bugs. We have to deal with this, because no one is able to write code without errors. Requirements are always changing, systems becoming more complex with time and in such situations it's hard to not make mistakes.
But how to avoid repetition of the same bugs when you edit a code? There's a good solution that will also save you some time while debugging the reasons of bugs.
Let's take a look at how usually developers start fixing bugs. At first you will try to reproduce the bug. This depends on the system you are working with, but usually it will be either making some network calls or clicking buttons on site in the correct order or whatever. Then if you are able to reproduce the bug you will try to debug the code to find what's causing a problem. And to do this you will again make network calls, click site or something like that.
Instead of making any movements after you were able to reproduce the bug try to write a unit test for this. After this you are free of bug reproduction, you can just debug your unit test.
As a bonus you will cover you code with a tricky case tests and won't let this bug be repeated in the future.
I know that it's not something new and it's great if you are already doing this but this thing should be told. Even the obvious things should be discussed because what is obvious to you can be not so obvious to your friends and vice versa.
It's hard to write good tests that will cover all cases from the first time. That's why it's important to continue writing them in future when you are using you code.
Thanks you for attention! Good code to you all!