<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Daily Build &#187; reviews</title>
	<atom:link href="http://blog.bstpierre.org/category/reviews/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.bstpierre.org</link>
	<description>Software Development, version 3.0</description>
	<lastBuildDate>Wed, 26 May 2010 16:08:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>One Simple Step for Avoiding Shallow Reviews</title>
		<link>http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews</link>
		<comments>http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews#comments</comments>
		<pubDate>Wed, 25 Nov 2009 13:55:55 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[reviews]]></category>
		<category><![CDATA[codereview]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[software-engineering]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=209</guid>
		<description><![CDATA[It's your job as a reviewer to find as many defects as possible. If you're not finding defects, you're wasting time.


Related posts:<ol><li><a href='http://blog.bstpierre.org/who-else-wants-better-short-term-memory' rel='bookmark' title='Permanent Link: Who Else Wants Better Short Term Memory?'>Who Else Wants Better Short Term Memory?</a> <small> In &#8220;Talent is Overrated&#8221;, Geoff...</small></li><li><a href='http://blog.bstpierre.org/3-easy-ways-to-stick-to-a-coding-standard' rel='bookmark' title='Permanent Link: 3 Easy Ways to Stick to a Coding Standard'>3 Easy Ways to Stick to a Coding Standard</a> <small> When you&#8217;re writing python, you...</small></li><li><a href='http://blog.bstpierre.org/must-have-tools-software-teams' rel='bookmark' title='Permanent Link: 9 &#8220;Must-Have&#8221; Tools for Software Teams'>9 &#8220;Must-Have&#8221; Tools for Software Teams</a> <small> The items below are useful...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve all been guilty of giving a shallow review: &#8220;Looks ok.&#8221;</p>
<p>Given typical defect densities, any non-trivial design or code is going to contain some errors. Even seemingly trivial maintenance fixes are likely to be defective.</p>
<p><strong>It&#8217;s your job as a reviewer to find as many of these defects as possible. </strong>If you&#8217;re not finding defects, you&#8217;re wasting your time on reviews.</p>
<p>That &#8220;one simple step&#8221;? Remind yourself that there are almost certainly defects in the work product you&#8217;re reviewing, and then find them. It&#8217;s all about attitude.</p>


<p>Related posts:<ol><li><a href='http://blog.bstpierre.org/who-else-wants-better-short-term-memory' rel='bookmark' title='Permanent Link: Who Else Wants Better Short Term Memory?'>Who Else Wants Better Short Term Memory?</a> <small> In &#8220;Talent is Overrated&#8221;, Geoff...</small></li><li><a href='http://blog.bstpierre.org/3-easy-ways-to-stick-to-a-coding-standard' rel='bookmark' title='Permanent Link: 3 Easy Ways to Stick to a Coding Standard'>3 Easy Ways to Stick to a Coding Standard</a> <small> When you&#8217;re writing python, you...</small></li><li><a href='http://blog.bstpierre.org/must-have-tools-software-teams' rel='bookmark' title='Permanent Link: 9 &#8220;Must-Have&#8221; Tools for Software Teams'>9 &#8220;Must-Have&#8221; Tools for Software Teams</a> <small> The items below are useful...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Five Things That Do Not Belong In A Review Checklist</title>
		<link>http://blog.bstpierre.org/five-things-that-do-not-belong-in-a-review-checklist</link>
		<comments>http://blog.bstpierre.org/five-things-that-do-not-belong-in-a-review-checklist#comments</comments>
		<pubDate>Tue, 27 Jan 2009 22:09:32 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[reviews]]></category>
		<category><![CDATA[codereview]]></category>
		<category><![CDATA[process]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=104</guid>
		<description><![CDATA[This is the second half of an article I posted about using a checklist to prevent security errors. There, I said that you have 15 checklist items max, and you shouldn&#8217;t waste any of those questions on silly things like &#8220;Does the code follow the coding standard?&#8221;.
Jason Cohen pointed to an article of his in [...]


Related posts:<ol><li><a href='http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews' rel='bookmark' title='Permanent Link: One Simple Step for Avoiding Shallow Reviews'>One Simple Step for Avoiding Shallow Reviews</a> <small>It's your job as a reviewer...</small></li><li><a href='http://blog.bstpierre.org/who-else-wants-better-short-term-memory' rel='bookmark' title='Permanent Link: Who Else Wants Better Short Term Memory?'>Who Else Wants Better Short Term Memory?</a> <small> In &#8220;Talent is Overrated&#8221;, Geoff...</small></li><li><a href='http://blog.bstpierre.org/pid-file-race' rel='bookmark' title='Permanent Link: An Interesting pid File Race'>An Interesting pid File Race</a> <small> ISC&#8217;s dhcpd uses this code...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>This is the second half of an article I posted about <a href="http://blog.bstpierre.org/how-to-use-a-checklist-to-prevent-security-errors">using a checklist to prevent security errors</a>. There, I said that you have 15 checklist items max, and you shouldn&#8217;t waste any of those questions on silly things like &#8220;Does the code follow the coding standard?&#8221;.</p>
<p><a href="http://blog.asmartbear.com/">Jason Cohen</a> pointed to an <a href="http://embedded.com/columns/guest/208803162">article of his</a> in which he said <strong>&#8220;List no items that can be automated.&#8221;</strong> (His emphasis, but I second the motion.)</p>
<p>In the context of the SANS paper, let&#8217;s look at five items that should be automated so that no human has to find the defects:
<ol>
<li><a href="http://cwe.mitre.org/data/definitions/665.html">CWE-665</a>: Improper Initialization. As the write-up for CWE-665 suggests, you could use a programming language that forces you to explicitly initialize all variables before use. Or, if you&#8217;re stuck with something like C, make sure you turn on the warnings in your compiler, or use a static analysis tool (e.g. lint) to verify that all variables are initialized before being used. Tools like Coverity can be very sophisticated in their static analysis.</li>
<li><a href="http://cwe.mitre.org/data/definitions/119.html">CWE-119</a>: Failure to Constrain Operations within the Bounds of a Memory Buffer. Same goes for this one. First, use a programming language that doesn&#8217;t require attention to every tiny little detail of string handling. Failing that, apply static analysis. It&#8217;s also worth performing runtime analysis (e.g. electric fence, Purify) with appropriate test cases to verify that you&#8217;ve avoided buffer overflows.</li>
<li><a href="http://cwe.mitre.org/data/definitions/404.html">CWE-404</a>: Improper Resource Shutdown or Release. Even garbage collected languages can have problems with resource release. First, some GC systems have problems with circular references. Second, GC systems are typically worried about releasing memory. You also have to worry about database handles, file handles, and sockets. Configure your static analysis tool to track resources like these so that you don&#8217;t have to do it manually.</li>
<li>The write-up for CWE-404 also mentions in passing that you should &#8220;wash your garbage before you dispose of it&#8221;. This is useful for two reasons: first, an attacker won&#8217;t have access to the contents of previously used memory, and second, it often makes debugging memory problems easier if you write a known value into freed memory. (I modified malloc() at my last job to write 0xcacacaca into freed memory so that we would know right away when someone stepped on a turd, um, I mean used freed memory.) Configure your libraries to shred objects before you free them and you won&#8217;t have to worry about it on a line-by-line basis in the code you review.</li>
<li><a href="http://cwe.mitre.org/data/definitions/362.html">CWE-362</a>: Race Condition. I&#8217;m typically worried less about security than the nightmare of isolating and debugging race conditions. I haven&#8217;t seen any tools that detect race conditions well, but Coverity does a decent job of telling you when you&#8217;ve mishandled a race condition in a couple of cases: first, it warns you when you fail to release a lock, and second, it warns you when you access a resource that is statistically accessed from within a lock. So you still have to beware of race conditions (at the design level is the bset place to find these), but there is an option for finding tedious errors in the mechanics of dealing with races.</li>
</ol>
<p>And now I&#8217;m going to throw out everything above.&nbsp; Remember that the tools are built to detect common errors. If it is really important that you find a certain class of bug, put it on your checklist. In fact, if it&#8217;s super critical, make it a checklist of length one. For example, I&#8217;ve gone over codebases with the single-minded focus of finding race conditions. When you perform a review like this, it&#8217;s amazing how many defects you might find in areas that you never suspected.</p>


<p>Related posts:<ol><li><a href='http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews' rel='bookmark' title='Permanent Link: One Simple Step for Avoiding Shallow Reviews'>One Simple Step for Avoiding Shallow Reviews</a> <small>It's your job as a reviewer...</small></li><li><a href='http://blog.bstpierre.org/who-else-wants-better-short-term-memory' rel='bookmark' title='Permanent Link: Who Else Wants Better Short Term Memory?'>Who Else Wants Better Short Term Memory?</a> <small> In &#8220;Talent is Overrated&#8221;, Geoff...</small></li><li><a href='http://blog.bstpierre.org/pid-file-race' rel='bookmark' title='Permanent Link: An Interesting pid File Race'>An Interesting pid File Race</a> <small> ISC&#8217;s dhcpd uses this code...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/five-things-that-do-not-belong-in-a-review-checklist/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Use A Checklist to Prevent Security Errors</title>
		<link>http://blog.bstpierre.org/how-to-use-a-checklist-to-prevent-security-errors</link>
		<comments>http://blog.bstpierre.org/how-to-use-a-checklist-to-prevent-security-errors#comments</comments>
		<pubDate>Fri, 23 Jan 2009 17:23:10 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[reviews]]></category>
		<category><![CDATA[codereview]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=98</guid>
		<description><![CDATA[The 2009 CWE/SANS Top 25 Most Dangerous Programming Errors has been out for a while now. Maybe you&#8217;ve already eliminated all of these errors from your code. In case you haven&#8217;t, this post will help you develop a checklist that you can use to eliminate these errors starting at the architecture level and moving through [...]


Related posts:<ol><li><a href='http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews' rel='bookmark' title='Permanent Link: One Simple Step for Avoiding Shallow Reviews'>One Simple Step for Avoiding Shallow Reviews</a> <small>It's your job as a reviewer...</small></li><li><a href='http://blog.bstpierre.org/must-have-tools-software-teams' rel='bookmark' title='Permanent Link: 9 &#8220;Must-Have&#8221; Tools for Software Teams'>9 &#8220;Must-Have&#8221; Tools for Software Teams</a> <small> The items below are useful...</small></li><li><a href='http://blog.bstpierre.org/using-pythons-ctypes-to-make-system-calls' rel='bookmark' title='Permanent Link: Using Python&#8217;s ctypes to Call Into C Libraries'>Using Python&#8217;s ctypes to Call Into C Libraries</a> <small>The ctypes module makes loading and...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>The <a title="2009 CWE/SANS Top 25 Most Dangerous Programming Errors" href="http://www.sans.org/top25errors/">2009 CWE/SANS Top 25 Most Dangerous Programming Errors</a> has been out for a while now. Maybe you&#8217;ve already eliminated all of these errors from your code. In case you haven&#8217;t, this post will help you develop a checklist that you can use to eliminate these errors starting at the architecture level and moving through design, code, and testing. Before we get to the security aspect, first let&#8217;s take a quick detour through the mechanics of a review checklist.</p>
<h3>Why A Review Checklist is Essential</h3>
<p>Most (all?) experts recommend the use of a checklist for performing design and code reviews. It&#8217;s more effective to ask a set of questions about the item being reviewed than to simply stare at a bunch of code looking for problems. The checklist focuses your attention on aspects that are most important.</p>
<p>If you want to perform a broader review, develop two or three checklists with different foci and give the lists to separate reviewers. The defect lists from each reviewer will have less overlap than if you gave everyone the same list.</p>
<h3>What Your Review Checklist Should Look Like</h3>
<p>The following advice is partly based on advice from <a href="http://www.amazon.com/Software-Inspection-Tom-Gilb/dp/0201631814/">&#8220;Software Inspection&#8221; by Gilb and Graham</a>. A good checklist is a list of questions. For practical purposes, I&#8217;m strongly in favor of a checklist that does not exceed one side of a printed page — at normal font size. For me this means a checklist of about 15 items, 20 as an absolute maximum. Remember, we&#8217;re <em>focusing</em>, which means looking harder for just a few types of items. If you&#8217;re using online checklists, I&#8217;d extend this to mean that it should fit on the screen without scrolling. Either way, I don&#8217;t think you should have more than 20 questions or so at the max. Fewer is probably better, more is too overwhelming.</p>
<p>Checklist items are yes/no questions. They should all be phrased such that a &#8220;no&#8221; answer means something is broken.</p>
<p>When reviewing, proceed through the entire item under review (the entire code listing or design) with each question. Don&#8217;t work linearly, this is a horrible way to review code. I prefer to review on paper, simply because I can make little notes and marks all over the paper as I go through it. For the first question, you might work mostly front-to-back. Then the second question might send you backwards through the code. After a couple of passes over the code you have some familiarity with it, so the third question might send you straight to a location that has potential problems.</p>
<h3>How To Choose Questions for the Review Checklist</h3>
<p>Since the whole point of the checklist (and reviews in general) is to find defects, the questions should focus on finding the highest value defects. Why waste valuable checklist real estate on a question like &#8220;Does the code conform to formatting conventions?&#8221; Duh. If your team has a formatting convention, and you look at a piece of code that doesn&#8217;t conform, it&#8217;s going to jump off the page and bite you in the nose. You don&#8217;t need a checklist question for this!</p>
<p>Back to the specific problem at hand: security errors. SANS has done a great job of sifting through tons of security errors and boiling them down to the top 25. We could probably develop a 100 question review checklist from their Top 25 list, but it would be too big to be usable. So let&#8217;s <em>focus</em> on the most important for our application.</p>
<p>For this exercise, our application is a blog like Wordpress but much simpler: no plugins, no comments, single author. This is not a hosted application like Blogger, so we are less concerned about vulnerabilities like cross-site scripting, SQL injection, and OS command injection. We do need to make sure that only the author is allowed to post, so let&#8217;s look at the &#8220;Porous Defenses&#8221; category.</p>
<ul>
<li>CWE-285: Improper Access Control (Authorization)</li>
<li>CWE-327: Use of a Broken or Risky Cryptographic Algorithm</li>
<li>CWE-259: Hard-Coded Password</li>
<li>CWE-732: Insecure Permission Assignment for Critical Resource</li>
<li>CWE-330: Use of Insufficiently Random Values</li>
<li>CWE-250: Execution with Unnecessary Privileges</li>
<li>CWE-602: Client-Side Enforcement of Server-Side Security</li>
</ul>
<p>The entry for CWE-285: Improper Access Control lists the following for prevention and mitigation:</p>
<blockquote><p>For web applications, make sure that the access control mechanism is enforced correctly at the server side on every page. Users should not be able to access any information that they are not authorized for by simply requesting direct access to that page. One way to do this is to ensure that all pages containing sensitive information are not cached, and that all such pages restrict access to requests that are accompanied by an active and authenticated session token associated with a user who has the required permissions to access that page.</p></blockquote>
<p>Here are some straightforward checklist questions we can extract from that description:</p>
<ol>
<li>Does every administrative page enforce access control on the server side?</li>
<li>Are unauthenticated (anonymous) users prevented from accessing administrative pages?</li>
<li>Is caching disabled for administrative pages?</li>
<li>Does every administrative page validate the session token properly?</li>
</ol>
<p>Now you can go walk through your design and/or code to verify that you can say &#8220;yes&#8221; to each of these questions.</p>
<p>If you found this post helpful, <a href="http://blog.bstpierre.org/feed/rss2">subscribe to The Daily Build</a> to get updates as they are posted. Thanks!</p>


<p>Related posts:<ol><li><a href='http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews' rel='bookmark' title='Permanent Link: One Simple Step for Avoiding Shallow Reviews'>One Simple Step for Avoiding Shallow Reviews</a> <small>It's your job as a reviewer...</small></li><li><a href='http://blog.bstpierre.org/must-have-tools-software-teams' rel='bookmark' title='Permanent Link: 9 &#8220;Must-Have&#8221; Tools for Software Teams'>9 &#8220;Must-Have&#8221; Tools for Software Teams</a> <small> The items below are useful...</small></li><li><a href='http://blog.bstpierre.org/using-pythons-ctypes-to-make-system-calls' rel='bookmark' title='Permanent Link: Using Python&#8217;s ctypes to Call Into C Libraries'>Using Python&#8217;s ctypes to Call Into C Libraries</a> <small>The ctypes module makes loading and...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/how-to-use-a-checklist-to-prevent-security-errors/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Code Review Tools</title>
		<link>http://blog.bstpierre.org/code-review-tools</link>
		<comments>http://blog.bstpierre.org/code-review-tools#comments</comments>
		<pubDate>Wed, 31 Dec 2008 18:07:00 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[reviews]]></category>
		<category><![CDATA[codereview]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=13</guid>
		<description><![CDATA[Yesterday I posted twenty reasons to do code reviews, and I promised a list of code review tools. Here they are, in no particular order. I have not used all of them, so I can&#8217;t comment on their relative merits. If there are some I missed, please leave a comment and I&#8217;ll update this list.

Codestriker [...]


Related posts:<ol><li><a href='http://blog.bstpierre.org/must-have-tools-software-teams' rel='bookmark' title='Permanent Link: 9 &#8220;Must-Have&#8221; Tools for Software Teams'>9 &#8220;Must-Have&#8221; Tools for Software Teams</a> <small> The items below are useful...</small></li><li><a href='http://blog.bstpierre.org/data-vs-code' rel='bookmark' title='Permanent Link: Data vs Code'>Data vs Code</a> <small> I&#8217;ll take an array over...</small></li><li><a href='http://blog.bstpierre.org/if-the-comments-are-ugly-the-code-is-ugly' rel='bookmark' title='Permanent Link: If the comments are ugly, the code is ugly'>If the comments are ugly, the code is ugly</a> <small> If the comments are ugly,...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Yesterday I posted <a href="http://blog.bstpierre.org/twenty-reasons-to-do-code-reviews">twenty reasons to do code reviews</a>, and I promised a list of code review tools. Here they are, in no particular order. I have not used all of them, so I can&#8217;t comment on their relative merits. If there are some I missed, please leave a comment and I&#8217;ll update this list.</p>
<ul>
<li><a href="http://codestriker.sf.net/">Codestriker</a> Open source, web based, written in perl I think.</li>
<li><a href="http://smartbear.com/codecollab.php">Code Collaborator</a> Commercial.</li>
<li><a href="http://www.review-board.org/">Review Board</a> Open source, web based, appears to be python/Django.</li>
<li><a href="http://code.google.com/appengine/articles/rietveld.html">Rietveld</a> Open source from Google. Guido van Rossum&#8217;s 2nd pass at a code review tool. You get three guesses on the implementation language&#8230;</li>
<li><a href="http://www.atlassian.com/software/crucible/">Crucible</a> Commercial from Atlassian.</li>
</ul>
<p>Bottom line: don&#8217;t try to do this by hand, you&#8217;ll be wasting a bunch of time packaging patches and tracking defects when a tool can do it automagically for you.</p>


<p>Related posts:<ol><li><a href='http://blog.bstpierre.org/must-have-tools-software-teams' rel='bookmark' title='Permanent Link: 9 &#8220;Must-Have&#8221; Tools for Software Teams'>9 &#8220;Must-Have&#8221; Tools for Software Teams</a> <small> The items below are useful...</small></li><li><a href='http://blog.bstpierre.org/data-vs-code' rel='bookmark' title='Permanent Link: Data vs Code'>Data vs Code</a> <small> I&#8217;ll take an array over...</small></li><li><a href='http://blog.bstpierre.org/if-the-comments-are-ugly-the-code-is-ugly' rel='bookmark' title='Permanent Link: If the comments are ugly, the code is ugly'>If the comments are ugly, the code is ugly</a> <small> If the comments are ugly,...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/code-review-tools/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Twenty Reasons To Do Code Reviews</title>
		<link>http://blog.bstpierre.org/twenty-reasons-to-do-code-reviews</link>
		<comments>http://blog.bstpierre.org/twenty-reasons-to-do-code-reviews#comments</comments>
		<pubDate>Tue, 30 Dec 2008 18:06:00 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[reviews]]></category>
		<category><![CDATA[codereview]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=12</guid>
		<description><![CDATA[Update [2008-12-31]: I posted the list of code review tools as promised below.
I tweeted this article on Five Reasons to Do Code Reviews from CIO.com last week,and realized that there are much more than the five reasons they give. So I came up with 20 more over the rest of the day. This is a [...]


Related posts:<ol><li><a href='http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews' rel='bookmark' title='Permanent Link: One Simple Step for Avoiding Shallow Reviews'>One Simple Step for Avoiding Shallow Reviews</a> <small>It's your job as a reviewer...</small></li><li><a href='http://blog.bstpierre.org/data-vs-code' rel='bookmark' title='Permanent Link: Data vs Code'>Data vs Code</a> <small> I&#8217;ll take an array over...</small></li><li><a href='http://blog.bstpierre.org/must-have-tools-software-teams' rel='bookmark' title='Permanent Link: 9 &#8220;Must-Have&#8221; Tools for Software Teams'>9 &#8220;Must-Have&#8221; Tools for Software Teams</a> <small> The items below are useful...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p><span style="font-weight: bold;">Update [2008-12-31]: </span>I posted the list of <a href="/code-review-tools">code review tools</a> as promised below.</p>
<p>I <a href="http://twitter.com/bstpierre/status/1076228386">tweeted</a> <a href="http://www.cio.com/article/472377/_Reasons_for_Software_Developers_to_Do_Code_Reviews_Even_If_You_Think_They_re_a_Waste_of_Time_">this article on Five Reasons to Do Code Reviews</a> from CIO.com last week,and realized that there are much more than the five reasons they give. So I came up with 20 more over the rest of the day. This is a collection of those tweets, with a little more detail given here.</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076435522">Code review reason 1</a>: Feedback comes back fast enough to give you whiplash.</strong> Since code review is done after coding and before integration or system tests, developers don&#8217;t have to wait as long to get feedback on code quality. By providing specific, timely feedback, developers can adjust their coding practices to avoid common mistakes.</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076448295">Code review reason 2</a>: Find more bugs than testing alone.</strong> This is obvious: Testing finds bugs. Code review finds different bugs. When combined they find more bugs than you would otherwise remove before shipping to customers.</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076643709">Code review reason 3</a>: A million monkeys sometimes produce valid syntax, even if it doesn&#8217;t make any sense. Compilers can&#8217;t catch this. </strong>Sometimes you&#8217;ll make a syntax error that produces valid syntax so the compiler can&#8217;t catch it. The classic here is in C, = (assignment) versus == (boolean equality operator); in this case most compilers can issue a warning but there are other examples. A code review will catch this error quickly, but finding this during testing can be hard to track down.</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076645011">Code review reason 4</a>: Find and kill bugs where they live, instead of finding turds and having to track them back to the nest.</strong> When you get defect reports from a code review, you have in-hand the exact line number and problem description. When you get reports from system test or (horrors!) a customer, you get — at best — a reproducible set of steps to trigger the bug. It&#8217;s then up to you to work backwards to the actual defect in the code, which is often time consuming, especially since the code may have been written weeks or months earlier. (See reason #1.)</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076699581">Code review reason 5</a>: Indoctrinate the n00bs.</strong> Code reviews are an effective training tool. First, new software engineers who participate in code reviews get to look at code produced by other engineers and thus get a feel for the coding standard and documentation style. Second, inexperienced engineers will get feedback on their code before they have a chance to infect the system with inferior code. (Because we all know that the code we wrote 10 years ago probably sucks — unless we were fortunate enough to have it reviewed by more senior engineers. If you haven&#8217;t already been coding for several years, keep in mind that everything you&#8217;re writing today probably sucks but you won&#8217;t be able to acknowledge that for another few years; see reason #6.)</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076706526">Code review reason 6</a>: Uses developer egos to boost quality of code from the beginning.</strong> The theory here is that because developers know their code is going to be publicly scrutinized by a group of peers, they will take extra care in coding to avoid the embarrassment caused by having others find all kinds of bugs in their code.</p>
<p>Guest contributor <strong><a href="http://twitter.com/kyletolle">@kyletolle</a>: <a href="http://twitter.com/kyletolle/status/1076701951">Code review reason [7]</a>: Explaining code makes sure they understand it well. Will fix the &#8220;Uhh, b/c I always do it that way&#8221; remarks.</strong> After you have to answer this question a few times during a review, you&#8217;ll probably ask the question of yourself while coding. (See reason #6.)</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076724807">Code review reason 8</a>: Makes testing go faster. Heck, it makes the entire development cycle go faster.</strong> There are multiple root causes for this. First, since code review finds and fixes defects at the site of the defect (see reason #4), less time is spent fixing these defect. Second, fewer bugs are found by testers so they spend less time writing up issues and the engineering team spends less time tracking and managing issues. Third, testers don&#8217;t have to re-run regression tests so many times because fewer release candidates will be needed.. Last, it is less likely that testers will be blocked waiting for fixes to bugs.</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076737034">Code review reason 9</a>: Fewer angry phone calls means happier tech support staff.</strong> Proof: Fewer bugs in shipping code (see reason #2). Customers not disrupted by bugs as often. They don&#8217;t get angry as often. So when they call, it&#8217;s with songs of praise. QED. (Ok, maybe that singing part isn&#8217;t true, but you get the picture.) To prove this from another angle: if you&#8217;re spending less time fixing bugs, you can spend more time implementing features that customers are requesting.</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076763127">Code review reason 10</a>: (Anti-reason) You&#8217;ll pay more sales commissions because you&#8217;ll be selling more product&#8230;wait, that&#8217;s a good thing!</strong> When customers sing your praises because your product is so reliable, it&#8217;s easier both to sell to new customers and to sell more product to your existing customers. Sure, your sales commissions might go up, but I&#8217;ve never really heard anyone complain about this too loudly.</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076785579">Code review reason 11</a>: There are tools that reduce the annoyance factor of old school review processes.</strong> After I tweeted this, <a href="http://twitter.com/kyletolle/status/1076797657">@kyletolle </a>asked for some recommendations. I will follow up this post with several tools that I&#8217;ve found. Stay tuned. (Look at my timeline starting <a href="http://twitter.com/bstpierre/status/1076816304">here</a> for now).</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076899696">Code review reason 12</a>: There&#8217;s zero risk. Even not-super-effective reviews beat testing.</strong> If I spent a little time I could probably dig up some published research to back this up. But my personal data says my personal code reviews are about four times as effective as unit testing. So even if I perform a half-hearted review, I&#8217;m still going to be more effective than testing. (See reasons #2 and #4, also keep in mind reason #5 which doesn&#8217;t have an immediate measurable effect.) There might be data out there that says code reviews are a waste of time. Flying reindeer might also exist.</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076933029">Code review reason 13</a>: (Anti-reason) Testers bored from not finding as many bugs&#8230; Oh yeah! They could focus on stress/perf tests.</strong> This would be a good problem to have&#8230;</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076933691">Code review reason 14</a>: Reviewing code is good practice for reviewing code. You&#8217;ll get better.</strong> Your team&#8217;s review effectiveness will improve over time. This means that the long term risk of failure is even lower than the short term risk (see reason #12 for why the risk of failure is zero or very close to zero).</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076934530">Code review reason 15</a>: It&#8217;s a great way to build a really useful code review checklist.</strong> This is kind of stretching, a useful code review checklist doesn&#8217;t really matter to the customer. (I should probably come up with a couple of bonus reasons to account for the &#8220;artificial fillers&#8221;&#8230; Hey, I tweeted this during the 3pm slump before my afternoon cup of tea.)</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076975312">Code review reason 16</a>: Out on a speculative limb: better staff retention because developers spend less time fixing annoying bugs. </strong>I&#8217;m not sure about anyone else, but I&#8217;ve stayed at a job that was otherwise not-so-great because of the quality of the team I was on and the people around me. Being part of a well-oiled machine feels good. It&#8217;s motivating to go to work everyday knowing that you&#8217;re going to produce a high quality product and your coworkers are there to back you up.</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076978947">Code review reason 17</a>: Reduces schedule risk because product quality is higher as it enters downstream phases.</strong> Your testers won&#8217;t get blocked as much (see reason #8) and testing won&#8217;t drag out. Since you get feedback relatively early in the schedule (see reason #1) you have a good idea of how long testing will take.</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076979963">Code review reason 18</a>: Feedback (especially from peers) at the source level means you will stop making the same mistakes over and over. </strong>(See reason #6.) This also stems from the fact that each engineer will have data in-hand about the types of defects he makes and he can come up with ways to prevent this defect from happening to begin with. And this is really when the magic occurs: when you can start thinking about preventing entire classes of defects.</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076980274">Code review reason 19</a>: Improves the quality of documentation / comments as well as executable code.</strong> (See reason #7.) Developers will include better comments to avoid having to answer too many questions from reviewers. If reviewers are looking for inconsistencies between comments and code, this is extra motivation to make sure that code documentation is up to date. Lastly, I suspect that overly complex code will become scarce since this will be scrutinized and questioned more than simple code passages.</p>
<p><strong><a href="http://twitter.com/bstpierre/status/1076980819">Code review reason 20</a>: Customers won&#8217;t find as many bugs in their soup.</strong> This is maybe redundant to reason #9, but helping customers is why we exist, right? So I&#8217;ll allow this one to stand and — like I said above — I&#8217;ll work on a couple of bonus reasons to add to this list.</p>


<p>Related posts:<ol><li><a href='http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews' rel='bookmark' title='Permanent Link: One Simple Step for Avoiding Shallow Reviews'>One Simple Step for Avoiding Shallow Reviews</a> <small>It's your job as a reviewer...</small></li><li><a href='http://blog.bstpierre.org/data-vs-code' rel='bookmark' title='Permanent Link: Data vs Code'>Data vs Code</a> <small> I&#8217;ll take an array over...</small></li><li><a href='http://blog.bstpierre.org/must-have-tools-software-teams' rel='bookmark' title='Permanent Link: 9 &#8220;Must-Have&#8221; Tools for Software Teams'>9 &#8220;Must-Have&#8221; Tools for Software Teams</a> <small> The items below are useful...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/twenty-reasons-to-do-code-reviews/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The cost of (not) testing software</title>
		<link>http://blog.bstpierre.org/the-cost-of-not-testing-software</link>
		<comments>http://blog.bstpierre.org/the-cost-of-not-testing-software#comments</comments>
		<pubDate>Wed, 24 Dec 2008 13:31:00 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[process]]></category>
		<category><![CDATA[reviews]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=11</guid>
		<description><![CDATA[Great post on the cost of (not) testing software. The take-home lesson is &#8220;find defects early&#8221;.
The main thing missing from the discussion is that there are better techniques for finding defects than testing. Like design and code reviews, and especially more attention to requirements. Catch defects as early as possible and reduce costs even further.


Related [...]


Related posts:<ol><li><a href='http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews' rel='bookmark' title='Permanent Link: One Simple Step for Avoiding Shallow Reviews'>One Simple Step for Avoiding Shallow Reviews</a> <small>It's your job as a reviewer...</small></li><li><a href='http://blog.bstpierre.org/must-have-tools-software-teams' rel='bookmark' title='Permanent Link: 9 &#8220;Must-Have&#8221; Tools for Software Teams'>9 &#8220;Must-Have&#8221; Tools for Software Teams</a> <small> The items below are useful...</small></li><li><a href='http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less' rel='bookmark' title='Permanent Link: Open an SSH Tunnel in Four Seconds or Less'>Open an SSH Tunnel in Four Seconds or Less</a> <small>As I mentioned in a previous...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Great post on <a href="http://jessenoller.com/2008/09/17/the-cost-of-not-testing-software/">the cost of (not) testing software</a>. The take-home lesson is &#8220;find defects early&#8221;.</p>
<p>The main thing missing from the discussion is that there are better techniques for finding defects than testing. Like design and code reviews, and especially more attention to requirements. Catch defects as early as possible and reduce costs even further.</p>


<p>Related posts:<ol><li><a href='http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews' rel='bookmark' title='Permanent Link: One Simple Step for Avoiding Shallow Reviews'>One Simple Step for Avoiding Shallow Reviews</a> <small>It's your job as a reviewer...</small></li><li><a href='http://blog.bstpierre.org/must-have-tools-software-teams' rel='bookmark' title='Permanent Link: 9 &#8220;Must-Have&#8221; Tools for Software Teams'>9 &#8220;Must-Have&#8221; Tools for Software Teams</a> <small> The items below are useful...</small></li><li><a href='http://blog.bstpierre.org/open-an-ssh-tunnel-in-four-seconds-or-less' rel='bookmark' title='Permanent Link: Open an SSH Tunnel in Four Seconds or Less'>Open an SSH Tunnel in Four Seconds or Less</a> <small>As I mentioned in a previous...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/the-cost-of-not-testing-software/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Five Reasons to Slow Down</title>
		<link>http://blog.bstpierre.org/five-reasons-to-slow-down</link>
		<comments>http://blog.bstpierre.org/five-reasons-to-slow-down#comments</comments>
		<pubDate>Mon, 15 Dec 2008 18:22:00 +0000</pubDate>
		<dc:creator>Brian St. Pierre</dc:creator>
				<category><![CDATA[process]]></category>
		<category><![CDATA[reviews]]></category>
		<category><![CDATA[timelog]]></category>

		<guid isPermaLink="false">http://blog.bstpierre.org/?p=9</guid>
		<description><![CDATA[Here are five reasons you should wait before moving on to the next phase of your software development process:

Get the requirements right. It&#8217;s so often repeated that it&#8217;s almost a cliché to say that requirements errors will cost 10x or more to fix during coding or testing. But it&#8217;s true, so I can risk repeating [...]


Related posts:<ol><li><a href='http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews' rel='bookmark' title='Permanent Link: One Simple Step for Avoiding Shallow Reviews'>One Simple Step for Avoiding Shallow Reviews</a> <small>It's your job as a reviewer...</small></li><li><a href='http://blog.bstpierre.org/insist-on-tests' rel='bookmark' title='Permanent Link: Insist on Automatic Tests'>Insist on Automatic Tests</a> <small> At some point your team...</small></li><li><a href='http://blog.bstpierre.org/who-else-wants-better-short-term-memory' rel='bookmark' title='Permanent Link: Who Else Wants Better Short Term Memory?'>Who Else Wants Better Short Term Memory?</a> <small> In &#8220;Talent is Overrated&#8221;, Geoff...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Here are five reasons you should wait before moving on to the next phase of your software development process:</p>
<ol>
<li><strong>Get the requirements right.</strong> It&#8217;s so often repeated that it&#8217;s almost a cliché to say that requirements errors will cost 10x or more to fix during coding or testing. But it&#8217;s true, so I can risk repeating it here. Spend a little more time getting the requirements right, and you&#8217;ll <em>get every second back, with interest</em> during the testing phase. The risk here is overanalysis, but if you tend to be the impatient type &#8212; jumping into design or coding with very thin requirements &#8212; then you&#8217;re unlikely to suffer paralysis.</li>
<li><strong>Get the design right.</strong> It doesn&#8217;t have to be an elaborate 500 page document. One of the best designs for a complex system that I&#8217;ve ever seen was a state machine described in a two-page document with a big matrix on the first page. Remember, a written design is a <em>communication tool</em>. Just like the rest of your software, it can be <a href="http://c2.com/xp/DoTheSimplestThingThatCouldPossiblyWork.html">the simplest thing that will work</a>. Marker on a whiteboard works, if your team decides that is an effective way to communicate. An extra hour spent preparing and reviewing the design will save at least two hours in testing. Really. I&#8217;ve seen too many designs that were rushed (and clearly broken upon review) because of an unexplainable urgent desire to get a document into review so that coding can begin. The state machine I just mentioned went through probably 20 man-hours of reviews in maybe three passes, and we must have found at least 50 defects in it. Those defects took a few seconds each to fix (some may have taken a few minutes), but if there had been code and tests based<br />
on this broken design it would have taken hours to fix some of them.</li>
<li><strong>Get the code right.</strong> I used an Extreme Programming mantra above (&#8220;the simplest thing that will work&#8221;), but I think XP overall often leads to bad practices &#8212; primarily an overemphasis on testing. I agree that automated regression tests are a valuable tool. However, it is important to recognize that testing has limits. It takes an immense effort to achieve full branch coverage, and even this can&#8217;t be considered &#8220;complete&#8221; testing. Testing must be used in conjunction with other tools: code review and static analysis are two such tools for removing defects from code. And before you&#8217;re at the point where code is ready for review or even the compiler, take the time to consult a reference when you&#8217;re unsure how to use an API. I don&#8217;t know how many bugs I&#8217;ve fixed (including some of my own!) that were a few lines down from a <tt>/*TBD: how is this supposed to work?*/</tt> comment. Instead of putting in that comment, take the time to figure out how it is supposed to work.</li>
<li><strong>Get the tests right.</strong> Ever waste time on a bogus bug report? Testers telling you a feature is broken when they&#8217;re just doing the wrong thing? It&#8217;s not their fault if you failed to communicate how the feature is supposed to work. In the same way your test team should be insisting on some written communication from you about the feature set, you should insist on some written communication from them about what they&#8217;re going to test. Again, this &#8220;test plan&#8221; doesn&#8217;t have to conform to an ISO/IEEE standard that requires it be 1200 pages long and six inches thick. Like with the design, a whiteboard works just fine. Whatever communication method you use, if it helps head off problems then it is working. If you&#8217;re finding too many problems late in the game, then maybe you need to have something a little more formal &#8212; try posting short documents to an internal wiki.</li>
<li><strong>Are you keeping score?</strong> A <em>little</em> bit of measurement can do great things for you. I <a href="http://blog.bstpierre.org/2008/12/ten-reasons-to-use-time-tracking-tool.html">track time</a>, lines of code, and defects. I was reviewing one of my designs this morning and this data helped me decide: (a) how many defects I should expect to find in my design and (b) how long it should take me to find those defects. All because I have historical data that tells me how many defects I find per hour of design review, and how many defects I make per hour while designing. I also know how much testing time this is likely to save&#8230; so I don&#8217;t feel any particular rush to start coding from a buggy design. I&#8217;d rather get the design right first.</li>
</ol>
<p>As I mentioned above, the risk to getting into the habit of waiting is that you spend too much time analyzing the current phase and don&#8217;t just get on with it. But if you start from good requirements, it should be obvious when you&#8217;re done with design and coding. And if you&#8217;re keeping score, you&#8217;ll know how much time to devote to reviews to keep them efficient.</p>


<p>Related posts:<ol><li><a href='http://blog.bstpierre.org/one-simple-step-for-avoiding-shallow-reviews' rel='bookmark' title='Permanent Link: One Simple Step for Avoiding Shallow Reviews'>One Simple Step for Avoiding Shallow Reviews</a> <small>It's your job as a reviewer...</small></li><li><a href='http://blog.bstpierre.org/insist-on-tests' rel='bookmark' title='Permanent Link: Insist on Automatic Tests'>Insist on Automatic Tests</a> <small> At some point your team...</small></li><li><a href='http://blog.bstpierre.org/who-else-wants-better-short-term-memory' rel='bookmark' title='Permanent Link: Who Else Wants Better Short Term Memory?'>Who Else Wants Better Short Term Memory?</a> <small> In &#8220;Talent is Overrated&#8221;, Geoff...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.bstpierre.org/five-reasons-to-slow-down/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
