I was new at work and I have introduced a bug in production which took time to fix. I have made a silly mistake in removing a line of code which causes not sync data in production. It was later found after 3 months. It is kinda depressing to see data discrepancies grew day by day. I talked to my supervisor and he gave me tips to cope with the feeling of uselessness and regret.
When you make mistakes, you are traversing the right path
I realized that I am on the right path. Making mistakes means you are trying to do something you have not tried before. Mistakes make you stronger. If you encounter the same problem over and over again, you should start evaluating your processes.
Introducing a bug in production doesn’t mean the end of the world. Realize that a big project is a team effort. You work as a team, and when something went wrong, it is on the whole team, not yours alone. Also, writing a bug-free application is a myth. There will always bug that will sprout, due to untested codes, upgraded dependencies, and unchecked code dependencies. There will be times that, if your application has upstream, and your team was not updated when there are enhancements on their side, causing unexpected behavior on your end.
We noticed that there has been lapsed in the quality assurance testing and code review process. Also, even practicing test-driven development, codes are not fully covered by the test since most of the codes are legacy and it is hard to add a test in every part of untestable codes. We have deadlines to meet and lack resources. What we did was, to improve our testing process. We considered all possible scenarios that may happen.
We also added test to trivial parts of codes, which may seem sound silly, but we noticed a significant amount of reduction of bugs.
I become meticulous in checking the output of the codes, rechecked all common codes that being used by other transaction. It is better safe than sorry. What you can do when you are faced with a bug is to discuss it with your team and handle it immediately. Proactively monitor logs for any errors that your application may encounter. Improve your application logging and create tools that will alert developers when unexpected behavior is encountered.
General Rule: Do not repeat the same mistakes.
Making a mistake is okay, it doesn’t mean you suck as a developer. You are still growing in the years to come. So pick up yourself and improve your process to prevent it from happening again. Nothing will happen if you cry over a bug. Someday, you will become numb, grow, respond quickly and treat all the bugs as a challenge to improve yourself.