Concept
How can software development practices help prevent bugs?
ComputerScienceOne / Error Handling
"There are a variety of reasons for why bugs make it into systems. Bugs could be the result of a fundamental misunderstanding of the problem or requirements. Poor management and the pressure of time constraints to deliver a project may make developers more careless. A lack of proper testing may mean many more bugs survive the development process than otherwise should have. Even expert programmers can overlook a simple mistake when writing thousands of lines of code. Given the potential for error, it is important to have good software development methodologies that emphasize testing a system at all levels. Working in teams where regular code reviews are held so that colleagues can examine, critique, and catch potential bugs are essential for writing robust code. Modern coding tools and techniques can also help to improve the robustness of code. For example, debuggers are tools that help a developer debug (that is, find and fix the cause of an error) a program. Debuggers allow you to simulate the execution of a program statement-by-statement and view the current state of the program such as variable values. You can “step through” the execution line by line to find where an error occurs in order to localize and identify a bug. Other tools allow you to perform static analysis on source code to search for potential problems. That is, problems that are not syntax errors and are not necessarily bugs that are causing problems, but instead are anti-patterns or code smells. Anti-patterns are essentially common bad-habits that can be found in code. They are an attempted solution to a commonly encountered problem but which don’t actually solve the problem or introduces new problems. Code smells are “symptoms” in a source code that indicate a possible deeper design or implementation flaw. Failure to adhere to good programming principles such as properly initializing variables or failure to check for null values are examples of smells. Static analysis tools automatically examine the code base for potential issues like these. For example, a lint (or linter) is a tool that can examine source code suspicious or non-portable code or code that does not comply with generally accepted standards or ways of doing things."
Related Ideas
- How are software testing, debugging, and program failures described?ComputerScienceOne · Glossary
- How do software design practices and development terms describe code quality and collaboration?ComputerScienceOne · Glossary
- Why are functions useful in programming?ComputerScienceOne · Functions
- What is an if-else-if statement with a bug?ComputerScienceOne · An if-else Statement
- How can a quadratic roots function return error codes?ComputerScienceOne · Error Handling By Design
- What types of errors can occur when processing files?ComputerScienceOne · Error Handling
- How do you catch and handle an exception in Java?ComputerScienceOne · Catching Exceptions
- Where is Error Handling covered?ComputerScienceOne · Error Handling