📄 lib0128.html
字号:
<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Bug-Fighting Guidelines</title>
<link rel="STYLESHEET" type="text/css" href="images/xpolecat.css">
<link rel="STYLESHEET" type="text/css" href="images/ie.content.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle" alt="Team LiB"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="LiB0127.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0129.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr></table>
<br>
<div class="chapter">
<a name="ch20"></a>
<div class="section">
<h2 class="first-section-title"><a name="635"></a><a name="ch20lev1sec2"></a>Bug-Fighting Guidelines</h2><p class="first-para">
<b class="bold">Always fix root errors first.</b> I distinguish between root and derivative errors. A derivative error happens because of an unexpected condition caused by some other error. That other error is the root error. If you fix the root error, the derivative error often disappears without your having to fix it directly.</p>
<p class="para">For example, I once received reports that an application was exceeding the maximum number of database connections with one of the connection pools. It turned out that this error was derivative. The real problem was that locking contention with a table made a transaction much longer than it should have been. As a result, the application was holding on to database connections longer than anticipated. Fixing the locking problem made the connection <a name="636"></a><a name="IDX-266"></a>pool errors disappear. Many would have been tempted to increase the connection pool size.</p>
<p class="para">
<b class="bold">Include tests for bugs in the test suite.</b> As stated earlier, making the regression test more robust enables you to identify problems earlier. XP advocates would use stronger terms and advise testing for all bugs in the test suite. The reality is that some bugs, like those that cause display defects, are difficult to code into a test case. Sometimes the cost of producing the test far outweighs its benefits. Support staff will have to evaluate the need for a bug-inspired test on a case-by-case basis.</p>
<p class="para">
<b class="bold">Declare war on derivative error.</b> A <span class="fixed">NullPointerException</span> is a good example of a derivative error—a problem that is reported well after it occurred. As discussed in <a href="LiB0111.html#536" target="_parent" class="chapterjump">chapter 17</a>, you can reduce derivative exceptions by checking the validity of argument values in public methods.</p>
<p class="last-para">
<b class="bold">Continually refine error reports to be more useful and descriptive.</b> If you receive an error report that doesn't provide enough information to solve the problem, you have two bugs: the one causing the error report and the other causing the incomplete report. It's usually worthwhile to fix both problems. If you continually enhance the information in error reports, you will notice a decrease in the amount of time it takes to investigate bugs and diagnose problems.</p>
</div>
</div><br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/teamlib.gif" width="62" height="15" border="0" align="absmiddle" alt="Team LiB"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href="LiB0127.html"><img src="images/previous.gif" width="62" height="15" border="0" align="absmiddle" alt="Previous Section"></a>
<a href="LiB0129.html"><img src="images/next.gif" width="41" height="15" border="0" align="absmiddle" alt="Next Section"></a>
</div></td></tr></table>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -