Computer Science; Software Engineering
Debugging is the process of identifying and addressing errors, known as “bugs,” in computer systems. It is an essential step in the development of all kinds of programs, from consumer programs such as web browsers and video games to the complex systems used in transportation and infrastructure. Debugging can be carried out through a number of methods depending on the nature of the computer system in question.
Computer programs consist of long strings of specialized code that tell the computer what to do and how to do it. Computer code must use specific vocabulary and structures in order to function properly. As such code is written by human programmers, there is always the possibility of human error, which is the cause of many common bugs. Perhaps the most common bugs are syntax errors. These are the result of small mistakes, such as typos, in a program's code. In some cases, a bug may occur because the programmer neglected to include a key element in the code or structured it incorrectly. For example, the code could include a command instructing the computer to begin a specific process but lack the corresponding command to end it.
Bugs fall into one of several categories, based on when and how they affect the program. Compilation errors prevent the program from running. Run-time errors, meanwhile, occur as the program is running. Logic errors, in which flaws in the program's logic produce unintended results, are a particularly common form of bug. Such errors come about when a program's code is syntactically correct but does not make logical sense. For instance, a string of code with flawed logic may cause the program to become caught in an unintended loop. This can cause it to become completely unresponsive, or freeze. In other cases, a logic error might result when a program's code instructs the computer to divide a numerical value by zero, a mathematically impossible task.
Bugs may interfere with a program's ability to perform its core functions or even to run. Not all bugs are related to a program's core functions, and some programs may be usable despite the errors they contain. However, ease of use is an important factor that many people consider when deciding which program to use. It is therefore in the best interest of software creators to ensure that their programs are as free of errors as possible. In addition to testing a program or other computer system in house prior to releasing them to the general public, many software companies collect reports of bugs from users following its release. This is often done through transfers of collected data commonly referred to as memory dumps. They can then address such errors through updates known as software patches.
While bugs are an inconvenience in consumer computer programs, in more specialized computer systems, they can have far more serious consequences. In areas such as transportation, infrastructure, and finance, errors in syntax and logic can place lives and livelihoods at risk. Perhaps the most prominent example of such a bug was the so-called Y2K bug. This bug was projected to affect numerous computer systems beginning on January 1, 2000. The problem would have resulted from existing practices related to the way dates were written in computer programs. However, it was largely averted through the work of programmers who updated the affected programs to prevent that issue. As the example of the far-reaching Y2K bug shows, the world's growing reliance on computers in all areas of society has made thorough debugging even more important.
The means of debugging vary based on the nature of the computer program or system in question. However, in most cases bugs may be identified and addressed through the same general process. When a bug first appears, the programmer or tester must first attempt to reproduce the bug in order to identify the results of the error and the conditions under which they occur. Next, the programmer must attempt to determine which part of the program's code is causing the error to occur. As programs can be quite complex, the programmer must simplify this process by eliminating as much irrelevant data as possible. Once the faulty segment of code has been found, the programmer must identify and correct the specific problem that is causing the bug. If the cause is a typo or a syntax error, the programmer may simply need to make a small correction. If there is a logic error, the programmer may need to rewrite a portion of the code so that the program operates logically.
Different types of programs or systems often require different debugging tools. An in-circuit emulator is used when the computer system being tested is an embedded system (that is, one located within a larger system) and cannot otherwise be accessed. A form of debugging known as integration testing is often used when a program consists of numerous components. After each component is tested and debugged on its own, they are linked together and tested as a unit. This ensures that the different components function correctly when working together.
Foote, Steven. Learning to Program. Upper Saddle River: Pearson, 2015. Print.
McCauley, Renée, et al. “Debugging: A Review of the Literature from an Educational Perspective.” Computer Science Education 18.2 (2008): 67–92. Print.
Myers, Glenford J., Tom Badgett, and Corey Sandler. The Art of Software Testing. Hoboken: Wiley, 2012. Print.
St. Germain, H. James de. “Debugging Programs.” University of Utah. U of Utah, n.d. Web. 31 Jan. 2016.
“What Went Wrong? Finding and Fixing Errors through Debugging.” Microsoft Developer Network Library. Microsoft, 2016. Web. 31 Jan. 2016.
Zeller, Andreas. Why Programs Fail: A Guide to Systematic Debugging. Burlington: Kaufmann, 2009. Print.