Skip to main content

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.

Here comes the solution!


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 your 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 your code.

Thank you for attention! Good code to you all!

Comments

Popular posts from this blog

Caching strategies

One of the easiest and most popular ways to increase system performance is to use caching. When we introduce caching, we automatically duplicate our data. It's very important to keep your cache and data source in sync (more or less, depends on the requirements of your system) whenever changes occur in the system.
In this article, we will go through the most common cache synchronization strategies, their advantages, and disadvantages, and also popular use cases.

How to Build TypeScript App and Deploy it on GitHub Pages

Quick Summary In this post, I will show you how to easily build and deploy a simple TicksToDate time web app like this: https://zubialevich.github.io/ticks-to-datetime.

Classify BBC news headlines with Microsoft ML.NET

This sample tutorial illustrates using ML.NET to create a multiclass classifier via a .NET Core console application using C# in Visual Studio 2017.

Fundamentals of Testing for Programmers

Testing is an important part of a software development. Testing is tightly coupled with development and many teams include not only developers but also testers (or even whole testing department). Because of this tight coupling, it is nice when testers and developers can share a common dictionary. With this goal, I'm posting here my notes on this topic.

In this post, I will try to highlight what is testing, how it's connected with quality assurance and quality management. And also will describe seven testing principles and will path you through a fundamental test process.