12 Key Steps to Fixing Bugs
boss: So, how long will it take you to fix this bug?
Inexperienced programmer: Give me an hour? Two hours at most? I can get it done right away!
Experienced Programmer: Let’s put it this way, it takes me as long as it takes to catch a fish? !
How long it will take to fix the bug is difficult to know in advance, especially if you are unfamiliar with the code, the situation will be even more confusing. In the book "The Art of Agile", James Shore clearly points out that if you want to fix a problem, you must first know what the problem is. The reason why we can't accurately estimate the time is because we don't know how long it will take to find the crux. Only by knowing this, can we reasonably estimate the time it will take to fix the bug. However, I am afraid that the day lilies are already cold at this time. Steve McConnell once said:
"Find the problem - understand the problem - this is 90% of the programmer's job."
Many bugs only need to change a certain line of code. But what requires a lot of time is that we have to figure out what is correct later - just like when we are fishing, we have to know where to put the bait, when the fish is easy to take the bait, etc. It is said that there are four types of bugs: the first type is easy to find and easy to fix, the second type is hard to find and easy to fix, the third type is easy to find and hard to fix, and the fourth type is hard to find and hard to fix. The most tragic thing is the last type. Not only is it "searching and searching, but it is desolate and desolate", even if it finally breaks through the stone after all the hard work, one can only scratch one's head and scratch one's head involuntarily, sighing helplessly: "The road is long and long." ". It can be said that unless it is freshly released code, looking for bugs is like a blind man feeling for an elephant - you are confused and don't know which bug type it belongs to.
Finding and fixing bugs
Do you know what “finding and fixing bugs” means? That’s right, it’s debugging! Constant debugging, countless debugging! Through extensive work, Paul Butcher summarized the following structured steps:
1. Clarify the purpose. Carefully review the exception report to determine whether it is a bug, find various useful information, discover the crux of the problem, and reproduce it. Check again for duplication with the report. If duplication occurs, see how the people involved dealt with it.
2. Preparation - Find the correct code and clean up the work area with elimination.
3. Match the test environment. This process can be skipped if the customer is working on computer configuration.
4. Clarify the purpose of the code and ensure that everything is working properly with existing testing tools.
5. Okay, now you can go fishing - reproduce and diagnose the error. If you can't reproduce it, you can't prove you've done the repair work.
6. Write test cases, or catch bugs through ready-made test cases.
7. Enter repair mode - make sure it does not affect any other parts. However, before you start fixing it, you may want to do the refactoring because only then you can mess with the code without fear. And post-regression testing can also ensure that you will not add any new bugs.
8. Organize the code. Make your code easier to understand and safer through step-by-step refactoring.
9. Find someone else to review it, the authorities will be confused and the onlookers will understand.
10. Check this repair process again.
11. Try not starting from the main line to check whether these bugs will affect other branches. Merge these changes, handle differences in the code, review all reviews and tests, etc.
12. Think. Think carefully about what went wrong and why? Why does your fix work? Where else would this type of bug appear? In the book "The Pragmatic Programmer", Andy Hunt and Dave Thomas also pointed out that "if a bug costs you a lot of time, then you must find out why." In addition, we also need to think about how to learn from experience and lessons so that we will no longer stumble on similar issues in the future. And, is there anything that can be improved in the methods and tools we use? and the impact and severity of these bugs.
Which one takes more time, finding the bug or fixing it?
Perhaps the time required to set up a test environment, reproduce the problem and test the bug is far more than the time to find the bug and fix the bug. But for a small number of obvious bugs, finding them is easy—but fixing them may be less than ideal.
In the book "Making Software", there is a chapter that mainly discusses "the source of most software vulnerabilities". Dewayne Perry analyzed that compared to repairing, the time required to discover bugs (including understanding bugs and reproducing bugs) longer. Studies have shown that most bugs (almost 3/4) are both easy to find and easy to fix: 5 days or less (this is based on large-scale real-time systems through heavy-duty SDLC, extensive review and testing). But there are also very disgusting bugs. Even if you can catch it easily, you still have to work hard to fix it.
Discover/Repair Repair time5 days
Can reproduce the problem 72.5% 18.4%
Difficult or impossible to reproduce 5.9% 3.2%
So if you bet You fix bugs quickly, and most of the time you're right. But when you lose the bet, then, hey, it means you're in big trouble.
So, next time, when the boss asks when the bug will be fixed, don’t answer stupidly “it will be done soon”.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
