Article From:https://www.cnblogs.com/momoweiduan/p/8111974.html

As a developer, if he can’t solve Bug, his value will be greatly reduced. But to solve a Bug, we must first learn how to locate the Bug, so code debugging is a quality and skill that a programmer must possess.

Then I will talk about the most basic code debugging according to my own experience.

We all know the reasons why the project is wrong, such as the reasons for the IDE tools, the reasons for the tomcat, the cause of the plug-in, the code Bug, the database cause, the front end and so on, but here I mainly explain the front end code and the back end code debugging. Because I am myselfIn the actual work, the backend mainly uses Eclipse, the front end browser uses Chrome, so these two kinds of explanations.

Back end debugging:

1.Output debug: for beginners, use System.out.println () directly, output key statement code, debug. But the debugging method is inefficient.

2.LogLog output debugging: in the general project, the log output will be configured, such as the slf4j log: public final Logger log = LoggerFactory.getLogger (this.getClass ());Then output according to the log object method. The method is still inefficient

3.Breakpoint debugging, this method should be the most effective and intuitive method of debugging, and can be in-depth understanding of the source code.

  - > Write the interface, then mark the breakpoint on the key code: Toggle breakpoint

  - > Then the interface can be directly accessed from the browser, and the code can reach the breakpoint. The problem of the code can be judged by the upper and lower information of the breakpoints.

Front end debug:

The most intuitive understanding of project problems is that the visual interface process is not feasible, or the actual implementation results do not meet expectations. Therefore, we should first adjust the front page.

 – > HTMLPage: debugger debug, add the “debugger” code in JS code to achieve the breakpoint of JS code.

 – > jsOutput: in the JS code block of the Html page, the output statement is provided: console.log (), which is used to output the key values in the JS code, but can be opened in the debug mode of the front end browser

 – > Browser debug mode: access the page in the browser, then open the “check” (Chrome browser) mode, find the code of the page, then the JS code block interrupts, and then execute the front end operation to debug.

Link of this Article: From zero to one: code debugging

Leave a Reply

Your email address will not be published. Required fields are marked *