10 Debugging and scheduling small recommendations _ other integrated

Source: Internet
Author: User
Tags bug tracking system comments

Open a new text in a blank text editor, with no line of code in sight, a project full of possibilities and hopes. However, when thousands of lines of code are written, the entire project is crushed by the emergence of bugs, let alone add new features ... This may be the biggest blow to programmers, pouring cold water on full enthusiasm. In fact, the best software programmers know how to find and fix these bugs, and at the beginning of programming, the best way to reduce the probability of bugs is through software engineering.

Few programmers can write code that doesn't have a bug, but the solution is always much more difficult. A lot of practice and determination is the key to success, so that you can write clean code to ensure the reliability of the software system.

Here's a look at the toolbox that can crack down on bugs.

1. Output statements

The primary tool for code debugging is to insert a reliable, authentic output statement. When the output statement is large and not easy to manage, it is an equivalent good scheme to use the recording system appropriately in the output statement. Many programming languages are equipped with ready-made class libraries, such as the library built in Python.

Output statements are the quickest, simplest, and most straightforward way for programmers to check data values and variable types. Efficient output statements can help programmers track data flow through a piece of code and quickly identify the source of the bug. Although there are many advanced debugging tools, but if you want to debug a piece of code, this ordinary output statement method should be the first way programmers consider.

2. Debugger

The source debugger uses logical inference in the output language method. This allows the programmer to step through the code one line at a time and monitor every move from the value of the variable to the underlying virtual machine. In addition, most programming languages have multiple debuggers that can provide different functions, including graphical interfaces, breakpoint settings for terminating programs, and execution of arbitrary code within the environment.

In many cases, the debugger can be said to be overqualified, but if properly utilized, the debugger is definitely an efficient tool. More debugger features See the Python debugger: PDB.

3. Bug Tracking System

In some of the more significant software projects, it is necessary to use a bug tracking system. If you're not using a bug tracker, the most typical situation is that programmers need to sort out old emails or chat logs to find bugs, and worse still, programmers don't remember anything else, a document with a little bug in their memory. Once this happens, bugs will inevitably flood the entire code, and, more seriously, it's hard to identify the bugs and determine their location.

A simple text file can be used as the initial bug tracking system in the project. As the code base continues to grow, it doesn't take too long for bugs to derive from a text file. There are a number of commercial and open source bug tracking software solutions that can be considered, and the first and foremost part of choosing which bug tracking software is to ensure that programmers are able to quickly use the bug tracking system in programming projects.

4. Linter

In some programming languages, Linter can perform static analysis of code to identify problem areas before code is written and run, and in some other programming languages, linter tools are helpful for grammar checking and enhancement of style. When programming a Linter program in an editor, or passing code through Linter before code is written and run, it helps programmers find and correct more errors before they use the software. Therefore, using Linter can help you find out the source of bugs caused by grammatical errors, typos, or data type errors while saving valuable time.

To find out what kind of linter is best for you, look at Python's Linter tool: Pyflakes.

5. Version control

The use of version control systems should not be overlooked in any major software project. For example, versioning such as git,mercurial and SVN allows different versions of the code base to be separate on a different basis.

Different versions of the control can be merged together, so multiple programmers can run the same code base at the same time. Versioning is also important in code-scheduling, allowing programmers to roll back and modify older versions of the code to fix bugs in the code base before they occur.

6. Modular

Code that lacks schema is the main source of trouble fixing bugs. As long as the code is easy to understand and theoretically work, it is not a tricky thing for programmers to find and fix bugs quickly. On the other hand, the more important the code is, the greater the chance of error, and it is relatively difficult to find the error.

The components of software design often need to consider the so-called Code modularity, code modularity can help programmers better in two ways to understand the software system. First, modularity can create a level of abstraction that can be imagined without fully understanding all the details. For example, a programmer is building a business system that might take into account the credit card processing module and then see what the module has to do with the rest of the code, without considering all the details of the credit card processing module. Second, the detailed description of the module, this detailed description is not to be confused with the contents of other modules, as each card has only one card number is the same.

7. Automated Testing

Unit tests and other types of automated testing have a lot to do with modularity, which can be said to be complementary. An automated test is a piece of code that runs software with a special input value to test whether the program runs as expected.

Unit tests are primarily used to detect the functionality of a single feature, but functional testing is used to check for special program performance and to combine unit tests to check the overall part of a software system. There are many test frameworks that can be used to write test programs, and most popular test frameworks are derived from the JUnit libraries written by Kent Bent, and Kent Bent is one of the earliest proponents of the test-driven development approach. The Python standard class library includes a junit version of Python called the Pyunit or UnitTest Unit test framework.

8. Teddy Bear Method (Rubber Duck debugging)

In the software programming world, you have to mention the legendary brain Kernighan and Rob Pike, the teddy Bear debugging method stems from a university computer center where students can first explain the problem to the teddy bear on the table before they turn to the teacher or TA for help. Therefore, sometimes only talk with bears can solve the problem. This debugging method really works, so popular in the entire software engineering industry, like the print statement on the side, regardless of those complex tools how surging, Output statement This method is still popular today.

A method similar to the teddy Bear debugging method is called the Rubber Duck debugging method, when you explain to the rubber duck that is always silent, you will find that your thoughts, ideas, ideas and actual code deviate, so you find the bug in the code. Once a problem has been fully described in detail, the solution is also obvious. Do you think this method is too "stupid", too "retarded"? Yes, it looks like there's something wrong with the brain. But what I'm going to tell you is that this method does work. Because, this is "Code Review" embryonic!

9. Write code comments

The function of annotations is to interpret code at a more understandable level and write as much as possible: what each line of code is doing and how to do it, these questions should be easy to find when you read through the code. In addition, giving a reasonable name to each function and variable also helps simplify the process of code implementation. Fill in the blanks at the bottom of the line to answer why you use special implementations, or how a piece of code interacts with the rest of the program, and so on.

Writing detailed annotations can be said to be a reliable step in software engineering, even in code without bugs. This way, even if a bug comes up, there's no need to worry about it, and the notes will save you hours of scheduling errors.

10. Writing Documents

Code comments are written by programmers in a simple and personal way, while writing software documents is used to describe the functionality of the software system, and users can also see the software documentation. Depending on the type of software, the document can be used to detail the program interface, graphical interface, or workflow.

One of the benefits of writing a document is that you can demonstrate your understanding of the software system, and point out that the software system is not well developed or may be part of the source of the bug.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.