<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:series="http://unfoldingneurons.com/"
		>
<channel>
	<title>Comments on: On Code Commenting And Technical Debt</title>
	<atom:link href="http://www.brandonsavage.net/on-code-commenting-and-technical-debt/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/</link>
	<description>The personal blog of Brandon Savage. Contains entries of a personal and professional nature focusing on PHP, Apple, LAMP, MySQL and Washington, DC.</description>
	<lastBuildDate>Thu, 18 Mar 2010 20:17:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/#comment-1792</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Thu, 29 Oct 2009 12:51:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=383#comment-1792</guid>
		<description>I&#039;ll give the book a read but I&#039;m skeptical that writing comments indicates bad code.</description>
		<content:encoded><![CDATA[<p>I&#8217;ll give the book a read but I&#8217;m skeptical that writing comments indicates bad code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/#comment-1791</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Thu, 29 Oct 2009 11:21:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=383#comment-1791</guid>
		<description>Read Clean Code by Uncle Bob Martin and then you will realise that comments are just there to disguise bad programming!!!</description>
		<content:encoded><![CDATA[<p>Read Clean Code by Uncle Bob Martin and then you will realise that comments are just there to disguise bad programming!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tibo Beijen</title>
		<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/#comment-485</link>
		<dc:creator>Tibo Beijen</dc:creator>
		<pubDate>Tue, 05 May 2009 12:22:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=383#comment-485</guid>
		<description>Code readability imho is improved by both good commenting and meaningful variable and method names. Comments should best focus on the &#039;why&#039;, clear code can take care of most of the &#039;what&#039;.

Commenting (in my experience) can help in determining what has to be done, like explaining a problem to a coworker can help in seeing the solution yourself. I think (I hope) most developers think first and then start coding. Writing comments can take place right in between. Not doing so but finding time to argue why comments aren&#039;t neccessary to me seem a bit odd...</description>
		<content:encoded><![CDATA[<p>Code readability imho is improved by both good commenting and meaningful variable and method names. Comments should best focus on the &#8216;why&#8217;, clear code can take care of most of the &#8216;what&#8217;.</p>
<p>Commenting (in my experience) can help in determining what has to be done, like explaining a problem to a coworker can help in seeing the solution yourself. I think (I hope) most developers think first and then start coding. Writing comments can take place right in between. Not doing so but finding time to argue why comments aren&#8217;t neccessary to me seem a bit odd&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: In Defense Of Commenting &#124; BrandonSavage.net</title>
		<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/#comment-479</link>
		<dc:creator>In Defense Of Commenting &#124; BrandonSavage.net</dc:creator>
		<pubDate>Mon, 04 May 2009 16:35:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=383#comment-479</guid>
		<description>[...] &#171; On Code Commenting And Technical Debt [...]</description>
		<content:encoded><![CDATA[<p>[...] &laquo; On Code Commenting And Technical Debt [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay Pipes</title>
		<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/#comment-474</link>
		<dc:creator>Jay Pipes</dc:creator>
		<pubDate>Fri, 01 May 2009 04:48:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=383#comment-474</guid>
		<description>David,

Hmmm, I think the code at the link you shown is poor.  It&#039;s all in C+ (note, not C++).  Basically, it&#039;s C-code masquerading as C++.  If you code in C++, I say, use C++ idioms and learn how to code in C++ properly, not just in C with a couple object-orientated things floating around...

As for &quot;self-documenting&quot; code...well, here is a piece of the streams.cpp file:

https://sauerbraten.svn.sourceforge.net/svnroot/sauerbraten/src/shared/stream.cpp

void finishwriting()
    {
        if(!writing) return;
        for(;;)
        {
            int err = zfile.avail_out &gt; 0 ? deflate(&amp;zfile, Z_FINISH) : Z_OK;
            if(err != Z_OK &amp;&amp; err != Z_STREAM_END) break;
            flush();
            if(err == Z_STREAM_END) break;
        }
        uchar trailer[8] =
        {
            crc&amp;0xFF, (crc&gt;&gt;8)&amp;0xFF, (crc&gt;&gt;16)&amp;0xFF, (crc&gt;&gt;24)&amp;0xFF,
            zfile.total_in&amp;0xFF, (zfile.total_in&gt;&gt;8)&amp;0xFF, (zfile.total_in&gt;&gt;16)&amp;0xFF, (zfile.total_in&gt;&gt;24)&amp;0xFF
        };
        file-&gt;write(trailer, sizeof(trailer));
    }

Yeah, completely clear and self-documenting.  Not.</description>
		<content:encoded><![CDATA[<p>David,</p>
<p>Hmmm, I think the code at the link you shown is poor.  It&#8217;s all in C+ (note, not C++).  Basically, it&#8217;s C-code masquerading as C++.  If you code in C++, I say, use C++ idioms and learn how to code in C++ properly, not just in C with a couple object-orientated things floating around&#8230;</p>
<p>As for &#8220;self-documenting&#8221; code&#8230;well, here is a piece of the streams.cpp file:</p>
<p><a href="https://sauerbraten.svn.sourceforge.net/svnroot/sauerbraten/src/shared/stream.cpp" rel="nofollow">https://sauerbraten.svn.sourceforge.net/svnroot/sauerbraten/src/shared/stream.cpp</a></p>
<p>void finishwriting()<br />
    {<br />
        if(!writing) return;<br />
        for(;;)<br />
        {<br />
            int err = zfile.avail_out &gt; 0 ? deflate(&amp;zfile, Z_FINISH) : Z_OK;<br />
            if(err != Z_OK &amp;&amp; err != Z_STREAM_END) break;<br />
            flush();<br />
            if(err == Z_STREAM_END) break;<br />
        }<br />
        uchar trailer[8] =<br />
        {<br />
            crc&amp;0xFF, (crc&gt;&gt;8)&amp;0xFF, (crc&gt;&gt;16)&amp;0xFF, (crc&gt;&gt;24)&amp;0xFF,<br />
            zfile.total_in&amp;0xFF, (zfile.total_in&gt;&gt;8)&amp;0xFF, (zfile.total_in&gt;&gt;16)&amp;0xFF, (zfile.total_in&gt;&gt;24)&amp;0xFF<br />
        };<br />
        file-&gt;write(trailer, sizeof(trailer));<br />
    }</p>
<p>Yeah, completely clear and self-documenting.  Not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Marrs</title>
		<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/#comment-473</link>
		<dc:creator>David Marrs</dc:creator>
		<pubDate>Thu, 30 Apr 2009 16:27:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=383#comment-473</guid>
		<description>Brandon Savage:
&quot;I think an obvious solution to comments being wrong is to expect your developers to update the documentation as they write new code and then enforce that. You must also give them the time to do so.&quot;

That&#039;s reasonable enough except developers make mistakes from time to time, get distracted by the telephone, or whatever, and now we have a disagreement between the code and the comment.  This is the worst kind of bug.  Most bugs are easy to solve; this kind isn&#039;t.

I&#039;m not saying that code shouldn&#039;t have comments in, but code *should* be self-documenting, and in my experience, all the best code is.

Here&#039;s a link to one of my favourite examples of good code: very few comments, but very easy to grok.

https://sauerbraten.svn.sourceforge.net/svnroot/sauerbraten/src</description>
		<content:encoded><![CDATA[<p>Brandon Savage:<br />
&#8220;I think an obvious solution to comments being wrong is to expect your developers to update the documentation as they write new code and then enforce that. You must also give them the time to do so.&#8221;</p>
<p>That&#8217;s reasonable enough except developers make mistakes from time to time, get distracted by the telephone, or whatever, and now we have a disagreement between the code and the comment.  This is the worst kind of bug.  Most bugs are easy to solve; this kind isn&#8217;t.</p>
<p>I&#8217;m not saying that code shouldn&#8217;t have comments in, but code *should* be self-documenting, and in my experience, all the best code is.</p>
<p>Here&#8217;s a link to one of my favourite examples of good code: very few comments, but very easy to grok.</p>
<p><a href="https://sauerbraten.svn.sourceforge.net/svnroot/sauerbraten/src" rel="nofollow">https://sauerbraten.svn.sourceforge.net/svnroot/sauerbraten/src</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/#comment-472</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Thu, 30 Apr 2009 14:17:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=383#comment-472</guid>
		<description>Amen!

I have decided to not work with ppl that do not document their code.

I had the pleasure to work with ppl who argued exactly like you said: we have speaking method names and the code explains itself. I was new to the programming language they used and I had a hard time figuring out what they were doing.

But then again, I had the pleasure to work with ppl who appreciate comments. A former employer mailed me just recently. They had to tweak something in an app that I wrote for them years ago. The employer said it was breeze thanks to my documentation.</description>
		<content:encoded><![CDATA[<p>Amen!</p>
<p>I have decided to not work with ppl that do not document their code.</p>
<p>I had the pleasure to work with ppl who argued exactly like you said: we have speaking method names and the code explains itself. I was new to the programming language they used and I had a hard time figuring out what they were doing.</p>
<p>But then again, I had the pleasure to work with ppl who appreciate comments. A former employer mailed me just recently. They had to tweak something in an app that I wrote for them years ago. The employer said it was breeze thanks to my documentation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith Casey</title>
		<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/#comment-471</link>
		<dc:creator>Keith Casey</dc:creator>
		<pubDate>Thu, 30 Apr 2009 13:57:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=383#comment-471</guid>
		<description>Actually, you bump into another good point that I&#039;ve written on... peer pressure.

If the system is well-documented when you get there, I *suspect* (aka no evidence to support this) that later developers will be a little more careful and respectful of the comments that are there, hopefully adding their own.  After all, few people want to be the guy that screwed things up.

And I&#039;ve been meaning to write on that quote for months.... alas.  ;)</description>
		<content:encoded><![CDATA[<p>Actually, you bump into another good point that I&#8217;ve written on&#8230; peer pressure.</p>
<p>If the system is well-documented when you get there, I *suspect* (aka no evidence to support this) that later developers will be a little more careful and respectful of the comments that are there, hopefully adding their own.  After all, few people want to be the guy that screwed things up.</p>
<p>And I&#8217;ve been meaning to write on that quote for months&#8230;. alas.  ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/#comment-470</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Thu, 30 Apr 2009 13:53:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=383#comment-470</guid>
		<description>That&#039;s a really great point, Keith. And one worth noting.

In my professional experience I&#039;ve only been the originator of a project once - that is, the person who started writing the first code for any given project. That means that all my other projects were written by other people, even if I was adding new code. I wanted to avoid personal anecdote in the blog posting, but this is something I&#039;ve experienced first hand. It&#039;s critical that a code base have a good set of documentation for those who come after.

Someone once said &quot;code as if the next guy to maintain your code is a homicidal maniac who knows where you live.&quot; I think it&#039;s a good rule to live by.</description>
		<content:encoded><![CDATA[<p>That&#8217;s a really great point, Keith. And one worth noting.</p>
<p>In my professional experience I&#8217;ve only been the originator of a project once &#8211; that is, the person who started writing the first code for any given project. That means that all my other projects were written by other people, even if I was adding new code. I wanted to avoid personal anecdote in the blog posting, but this is something I&#8217;ve experienced first hand. It&#8217;s critical that a code base have a good set of documentation for those who come after.</p>
<p>Someone once said &#8220;code as if the next guy to maintain your code is a homicidal maniac who knows where you live.&#8221; I think it&#8217;s a good rule to live by.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith Casey</title>
		<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/#comment-469</link>
		<dc:creator>Keith Casey</dc:creator>
		<pubDate>Thu, 30 Apr 2009 13:47:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=383#comment-469</guid>
		<description>One thing that is missing from your analysis but would tend to support it is the software lifecycle itself.

Depending on who you listen to, the development process itself is only 10-50% of the lifetime of that code.  The rest of the time spent on it will be maintenance... quite often not done by you.  So while you may be unlikely to see the longterm benefits of commenting, the people following after you will.  And since you&#039;re likely to follow after someone else elsewhere, it&#039;s a handy process to start and share.

Keep it up Brandon.</description>
		<content:encoded><![CDATA[<p>One thing that is missing from your analysis but would tend to support it is the software lifecycle itself.</p>
<p>Depending on who you listen to, the development process itself is only 10-50% of the lifetime of that code.  The rest of the time spent on it will be maintenance&#8230; quite often not done by you.  So while you may be unlikely to see the longterm benefits of commenting, the people following after you will.  And since you&#8217;re likely to follow after someone else elsewhere, it&#8217;s a handy process to start and share.</p>
<p>Keep it up Brandon.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/#comment-468</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Thu, 30 Apr 2009 13:16:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=383#comment-468</guid>
		<description>I think an obvious solution to comments being wrong is to expect your developers to update the documentation as they write new code and then enforce that. You must also give them the time to do so.

From a practical standpoint, I don&#039;t think faster delivery of a product constitutes a good reason to skimp on documentation or commenting where such is warranted. And, if you use evidence-based scheduling (http://joelonsoftware.com/items/2007/10/26.html) the time required to document and develop should actually end up inside your estimate of a ship date anyway.

Large block comments can be collapsed by most modern editors, so I&#039;m not entirely convinced that block comments are bad for humans. If you use vim or something similar this might be an issue, but I&#039;ve found that collapsing the comment is often the way to make the code more readable, once I understand what it&#039;s supposed to do.</description>
		<content:encoded><![CDATA[<p>I think an obvious solution to comments being wrong is to expect your developers to update the documentation as they write new code and then enforce that. You must also give them the time to do so.</p>
<p>From a practical standpoint, I don&#8217;t think faster delivery of a product constitutes a good reason to skimp on documentation or commenting where such is warranted. And, if you use evidence-based scheduling (<a href="http://joelonsoftware.com/items/2007/10/26.html" rel="nofollow">http://joelonsoftware.com/items/2007/10/26.html</a>) the time required to document and develop should actually end up inside your estimate of a ship date anyway.</p>
<p>Large block comments can be collapsed by most modern editors, so I&#8217;m not entirely convinced that block comments are bad for humans. If you use vim or something similar this might be an issue, but I&#8217;ve found that collapsing the comment is often the way to make the code more readable, once I understand what it&#8217;s supposed to do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Marrs</title>
		<link>http://www.brandonsavage.net/on-code-commenting-and-technical-debt/#comment-467</link>
		<dc:creator>David Marrs</dc:creator>
		<pubDate>Thu, 30 Apr 2009 12:15:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=383#comment-467</guid>
		<description>Here&#039;s my effort to further perpetuate that myth:

What happens when the comment doesn&#039;t match the code?  Is the code wrong or the comment?  If you&#039;re talking about understanding code, the only way you can truely do that is by reading it.  A comment is only as useful as it is accurate and usually it&#039;s not the glaring differences that are hardest to spot, it&#039;s the really subtle ones.  So if you&#039;ve got to read the code anyway, you might as well make it readable.  Viz. the code should be self-documenting.

I include comments to avoid ambiguities, like /* This line is duplicated here for a reason: don&#039;t remove it. */. In a real example I&#039;d explain what that reason is.

I also use them to point out where I think a weakness in the code (read: source of bugs) may occur, or where I&#039;ve had to make comprismises.  In short, comments are used to prop up weak code.  The better the code is, the fewer comments it should require.

The worst kind of code to read is API code, which always has a big header above every function describing its signature and purpose.  It&#039;s great for the documentation parser, but not so much fun for the human trying to read the code.</description>
		<content:encoded><![CDATA[<p>Here&#8217;s my effort to further perpetuate that myth:</p>
<p>What happens when the comment doesn&#8217;t match the code?  Is the code wrong or the comment?  If you&#8217;re talking about understanding code, the only way you can truely do that is by reading it.  A comment is only as useful as it is accurate and usually it&#8217;s not the glaring differences that are hardest to spot, it&#8217;s the really subtle ones.  So if you&#8217;ve got to read the code anyway, you might as well make it readable.  Viz. the code should be self-documenting.</p>
<p>I include comments to avoid ambiguities, like /* This line is duplicated here for a reason: don&#8217;t remove it. */. In a real example I&#8217;d explain what that reason is.</p>
<p>I also use them to point out where I think a weakness in the code (read: source of bugs) may occur, or where I&#8217;ve had to make comprismises.  In short, comments are used to prop up weak code.  The better the code is, the fewer comments it should require.</p>
<p>The worst kind of code to read is API code, which always has a big header above every function describing its signature and purpose.  It&#8217;s great for the documentation parser, but not so much fun for the human trying to read the code.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
