<?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/"
		>
<channel>
	<title>Comments on: On the use of comments in code</title>
	<atom:link href="http://compsci.ca/blog/on-the-use-of-comments-in-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://compsci.ca/blog/on-the-use-of-comments-in-code/</link>
	<description>Programming, Education, Computer Science</description>
	<lastBuildDate>Sun, 21 Feb 2010 14:53:51 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tony</title>
		<link>http://compsci.ca/blog/on-the-use-of-comments-in-code/comment-page-1/#comment-53740</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Sat, 22 Sep 2007 23:14:55 +0000</pubDate>
		<guid isPermaLink="false">http://compsci.ca/blog/on-the-use-of-comments-in-code/#comment-53740</guid>
		<description>Good point Mike, especially the last one! Todays hardware is fast, cheap, and scales easily - it is much better to have robust code that is easy to understand and maintain, than very clever code that runs faster because of some hack.</description>
		<content:encoded><![CDATA[<p>Good point Mike, especially the last one! Todays hardware is fast, cheap, and scales easily &#8211; it is much better to have robust code that is easy to understand and maintain, than very clever code that runs faster because of some hack.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Minutillo</title>
		<link>http://compsci.ca/blog/on-the-use-of-comments-in-code/comment-page-1/#comment-53261</link>
		<dc:creator>Mike Minutillo</dc:creator>
		<pubDate>Sat, 22 Sep 2007 03:03:52 +0000</pubDate>
		<guid isPermaLink="false">http://compsci.ca/blog/on-the-use-of-comments-in-code/#comment-53261</guid>
		<description>If ever you do find that you are leaving comments explaining what you are doing instead of why it is a good sign that the code needs refactoring. In fact, this is one of the no. 1 reasons I have found for refactoring code. When some programmer leaves a comment like &quot;The following line returns the value on the top of the stack and then decrements the stack counter but only if the stack isn&#039;t emtpy&quot;, I immediately get the chills. This is about 6 different concerns and should be split up.

I have also become a big fan of long method and field names which lead to so-called &quot;self-describing code&quot;. If you do this then y = x   z becomes weekly_salary = normal_weekly_salary   this_weeks_bonus and you won&#039;t need comments except where you explain an algorithm or a programmer decision to do things a certain way. It also is a good indicator for when thinsg should be split up. A method which takes an open file handle and is called calculate_sales_order_and_print_receipt_and_close_file looks silly and is primed for refactoring.

Big Hint of the day: You win more points in the field for maintainability over efficiency or cleverness. It is a hard lesson to take in but one well worth noting.</description>
		<content:encoded><![CDATA[<p>If ever you do find that you are leaving comments explaining what you are doing instead of why it is a good sign that the code needs refactoring. In fact, this is one of the no. 1 reasons I have found for refactoring code. When some programmer leaves a comment like &#8220;The following line returns the value on the top of the stack and then decrements the stack counter but only if the stack isn&#8217;t emtpy&#8221;, I immediately get the chills. This is about 6 different concerns and should be split up.</p>
<p>I have also become a big fan of long method and field names which lead to so-called &#8220;self-describing code&#8221;. If you do this then y = x   z becomes weekly_salary = normal_weekly_salary   this_weeks_bonus and you won&#8217;t need comments except where you explain an algorithm or a programmer decision to do things a certain way. It also is a good indicator for when thinsg should be split up. A method which takes an open file handle and is called calculate_sales_order_and_print_receipt_and_close_file looks silly and is primed for refactoring.</p>
<p>Big Hint of the day: You win more points in the field for maintainability over efficiency or cleverness. It is a hard lesson to take in but one well worth noting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mlankton</title>
		<link>http://compsci.ca/blog/on-the-use-of-comments-in-code/comment-page-1/#comment-50526</link>
		<dc:creator>mlankton</dc:creator>
		<pubDate>Sun, 16 Sep 2007 13:27:15 +0000</pubDate>
		<guid isPermaLink="false">http://compsci.ca/blog/on-the-use-of-comments-in-code/#comment-50526</guid>
		<description>If you are coding in a commercial setting, someone will be maintaining your code down the road. Make it easy on them and leave good comments.</description>
		<content:encoded><![CDATA[<p>If you are coding in a commercial setting, someone will be maintaining your code down the road. Make it easy on them and leave good comments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://compsci.ca/blog/on-the-use-of-comments-in-code/comment-page-1/#comment-47905</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Thu, 06 Sep 2007 18:49:03 +0000</pubDate>
		<guid isPermaLink="false">http://compsci.ca/blog/on-the-use-of-comments-in-code/#comment-47905</guid>
		<description>Spot on Aziz, you redeemed yourself!</description>
		<content:encoded><![CDATA[<p>Spot on Aziz, you redeemed yourself!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aziz</title>
		<link>http://compsci.ca/blog/on-the-use-of-comments-in-code/comment-page-1/#comment-47846</link>
		<dc:creator>Aziz</dc:creator>
		<pubDate>Thu, 06 Sep 2007 12:38:12 +0000</pubDate>
		<guid isPermaLink="false">http://compsci.ca/blog/on-the-use-of-comments-in-code/#comment-47846</guid>
		<description>Lazy in the sense I didn&#039;t want to find a good example to post, I was merely bringing up the style of outlining methods and their purpose (using comments) before writing the actual code.

I personally program in java, and thoroughly comment for javadoc. An &quot;add()&quot; method in a Fraction class may have a description of merely &quot;adds two Fraction objects&quot;, but can have more detailed notes such as whether or not the resulting Fraction is reduced or how it handles certain input.

Inside code blocks such as methods where javadoc isn&#039;t generated, I highly support self-documenting code. code such as z = x   y is self-explanatory in what it does, but perhaps not why. I agree that a comment &quot;z is sum of x and y&quot; is in most cases redundant, but a comment of &quot;adding the x and y values produces this object&#039;s z value because of their Freudian relationship&quot; (fake) or something similar. :)</description>
		<content:encoded><![CDATA[<p>Lazy in the sense I didn&#8217;t want to find a good example to post, I was merely bringing up the style of outlining methods and their purpose (using comments) before writing the actual code.</p>
<p>I personally program in java, and thoroughly comment for javadoc. An &#8220;add()&#8221; method in a Fraction class may have a description of merely &#8220;adds two Fraction objects&#8221;, but can have more detailed notes such as whether or not the resulting Fraction is reduced or how it handles certain input.</p>
<p>Inside code blocks such as methods where javadoc isn&#8217;t generated, I highly support self-documenting code. code such as z = x   y is self-explanatory in what it does, but perhaps not why. I agree that a comment &#8220;z is sum of x and y&#8221; is in most cases redundant, but a comment of &#8220;adding the x and y values produces this object&#8217;s z value because of their Freudian relationship&#8221; (fake) or something similar. <img src='http://compsci.ca/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://compsci.ca/blog/on-the-use-of-comments-in-code/comment-page-1/#comment-47698</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Thu, 06 Sep 2007 04:40:29 +0000</pubDate>
		<guid isPermaLink="false">http://compsci.ca/blog/on-the-use-of-comments-in-code/#comment-47698</guid>
		<description>Guys, you should be less lazy when it comes to comments. ;)

I can&#039;t comment on the usefulness of such docs with seemingly redundant descriptions - I&#039;ve never had to build them. Now, since this blog focuses more on the education level programming, I&#039;m going to maintain my original point - tell me &lt;em&gt;why&lt;/em&gt; you are coding a certain way!</description>
		<content:encoded><![CDATA[<p>Guys, you should be less lazy when it comes to comments. <img src='http://compsci.ca/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I can&#8217;t comment on the usefulness of such docs with seemingly redundant descriptions &#8211; I&#8217;ve never had to build them. Now, since this blog focuses more on the education level programming, I&#8217;m going to maintain my original point &#8211; tell me <em>why</em> you are coding a certain way!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bashar</title>
		<link>http://compsci.ca/blog/on-the-use-of-comments-in-code/comment-page-1/#comment-47690</link>
		<dc:creator>Bashar</dc:creator>
		<pubDate>Thu, 06 Sep 2007 04:00:29 +0000</pubDate>
		<guid isPermaLink="false">http://compsci.ca/blog/on-the-use-of-comments-in-code/#comment-47690</guid>
		<description>Aziz: This was the point I wanted to point but got lazy also.
Tony: Those comments would be useful when you build the RoR docs.</description>
		<content:encoded><![CDATA[<p>Aziz: This was the point I wanted to point but got lazy also.<br />
Tony: Those comments would be useful when you build the RoR docs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aziz</title>
		<link>http://compsci.ca/blog/on-the-use-of-comments-in-code/comment-page-1/#comment-47678</link>
		<dc:creator>Aziz</dc:creator>
		<pubDate>Thu, 06 Sep 2007 02:36:34 +0000</pubDate>
		<guid isPermaLink="false">http://compsci.ca/blog/on-the-use-of-comments-in-code/#comment-47678</guid>
		<description>I was going to mention this but was too lazy. I couldn&#039;t be bothered to come up with good examples. I was describing the way a book said to layout method blocks and comments before the code.

And I include redundant comments like that in code for building javadocs :). When I comment at all.</description>
		<content:encoded><![CDATA[<p>I was going to mention this but was too lazy. I couldn&#8217;t be bothered to come up with good examples. I was describing the way a book said to layout method blocks and comments before the code.</p>
<p>And I include redundant comments like that in code for building javadocs <img src='http://compsci.ca/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . When I comment at all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wtd</title>
		<link>http://compsci.ca/blog/on-the-use-of-comments-in-code/comment-page-1/#comment-47354</link>
		<dc:creator>wtd</dc:creator>
		<pubDate>Wed, 05 Sep 2007 01:13:16 +0000</pubDate>
		<guid isPermaLink="false">http://compsci.ca/blog/on-the-use-of-comments-in-code/#comment-47354</guid>
		<description>But, OJ, don&#039;t you know?  Everything must be commented.  ;)</description>
		<content:encoded><![CDATA[<p>But, OJ, don&#8217;t you know?  Everything must be commented.  <img src='http://compsci.ca/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://compsci.ca/blog/on-the-use-of-comments-in-code/comment-page-1/#comment-47012</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Mon, 03 Sep 2007 03:27:02 +0000</pubDate>
		<guid isPermaLink="false">http://compsci.ca/blog/on-the-use-of-comments-in-code/#comment-47012</guid>
		<description>Aziz - OJ is right.
&lt;blockquote&gt;&lt;p&gt;
* Add this number to another.
public Number add(Number num)
&lt;/p&gt;&lt;/blockquote&gt;

This is clearly redundant. If you are writing comments in style that Bashar&#039;s &lt;em&gt;&quot;// Z is the sum of X &amp; Y&quot;&lt;/em&gt; professor is looking for, it should be a red flag.

Maybe it&#039;s just more difficult to write meaningful comments for such a generic example. It&#039;s easy to understand that &lt;em&gt;class Number&lt;/em&gt; represents a &quot;number&quot;, without explanation. Though I still don&#039;t get why we have to represent it in the first place. Where is it used? Why is it implemented this certain way? &lt;strong&gt;Are there any special caveats or edge cases that should be pointed out?&lt;/strong&gt; I think the latter is an especially useful type of a comment.</description>
		<content:encoded><![CDATA[<p>Aziz &#8211; OJ is right.</p>
<blockquote><p>
* Add this number to another.<br />
public Number add(Number num)
</p>
</blockquote>
<p>This is clearly redundant. If you are writing comments in style that Bashar&#8217;s <em>&#8220;// Z is the sum of X &#038; Y&#8221;</em> professor is looking for, it should be a red flag.</p>
<p>Maybe it&#8217;s just more difficult to write meaningful comments for such a generic example. It&#8217;s easy to understand that <em>class Number</em> represents a &#8220;number&#8221;, without explanation. Though I still don&#8217;t get why we have to represent it in the first place. Where is it used? Why is it implemented this certain way? <strong>Are there any special caveats or edge cases that should be pointed out?</strong> I think the latter is an especially useful type of a comment.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
