<?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: Eliminating Comments: the Road to Clarity</title>
	<atom:link href="http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eliminating-comments-the-road-to-clarity</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: BDKR</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-64454</link>
		<dc:creator>BDKR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 15:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-64454</guid>
		<description>What about the fact that there is some code that functions exactly as wished but doesn&#039;t really lend itself to self documentation? 

And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</description>
		<content:encoded><![CDATA[<p>What about the fact that there is some code that functions exactly as wished but doesn&#8217;t really lend itself to self documentation? </p>
<p>And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63841</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 19 May 2011 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63841</guid>
		<description> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.

I can reverse engineer your code but I can&#039;t reverse engineer your thoughts.

 If you are too lazy to update your comments when you update your code thats one thing. Just don&#039;t encourage others to do it.</description>
		<content:encoded><![CDATA[<p> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.</p>
<p>I can reverse engineer your code but I can&#8217;t reverse engineer your thoughts.</p>
<p> If you are too lazy to update your comments when you update your code thats one thing. Just don&#8217;t encourage others to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63831</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 May 2011 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63831</guid>
		<description> 
If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</description>
		<content:encoded><![CDATA[<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: florin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57909</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 16:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57909</guid>
		<description>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.
The comment should state, at least code comments, why something is done not what it is done.</description>
		<content:encoded><![CDATA[<p>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.<br />
The comment should state, at least code comments, why something is done not what it is done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jgauffin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57659</link>
		<dc:creator>jgauffin</dc:creator>
		<pubDate>Wed, 09 Jun 2010 11:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57659</guid>
		<description>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#039;t :)

I rather see documentation as a tool to write better code. And now I&#039;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.

I try to explain my point of view here:
http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</description>
		<content:encoded><![CDATA[<p>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#8217;t <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I rather see documentation as a tool to write better code. And now I&#8217;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.</p>
<p>I try to explain my point of view here:<br />
<a href="http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/" rel="nofollow">http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57221</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Mon, 17 May 2010 20:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57221</guid>
		<description>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#039;s name, which means your test and description/documentation always stay in sync. 

This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#039;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</description>
		<content:encoded><![CDATA[<p>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#8217;s name, which means your test and description/documentation always stay in sync. </p>
<p>This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#8217;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freddy rios</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57214</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Mon, 17 May 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57214</guid>
		<description>@Branko, you said:

&quot;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&quot;

Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#039;t easily/quickly understand what it is, it almost surely isn&#039;t good code. You say having the high-level comments all over the place serves as a &#039;shortcut&#039;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#039;t mean the situation wasn&#039;t created by a different problem, ignoring that perpetuates the issue.</description>
		<content:encoded><![CDATA[<p>@Branko, you said:</p>
<p>&#8220;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&#8221;</p>
<p>Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#8217;t easily/quickly understand what it is, it almost surely isn&#8217;t good code. You say having the high-level comments all over the place serves as a &#8216;shortcut&#8217;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#8217;t mean the situation wasn&#8217;t created by a different problem, ignoring that perpetuates the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Branko Dimitrijevic</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57115</link>
		<dc:creator>Branko Dimitrijevic</dc:creator>
		<pubDate>Thu, 13 May 2010 21:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57115</guid>
		<description>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc... and these are just &quot;physical&quot; levels - there may be many domain-specific &quot;logical&quot; paradigms with no direct analog in the programming language/technology.

While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.

The rules of thumb for good comments are:

  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.
  2. The comment is usually written BEFORE code.



Here are some examples:

  - Commenting the API is absolute must - the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.
  - Everything is &quot;API&quot;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#039;m not currently working on. Having high-level comments all over the place serves as a &quot;shortcut&quot; for understanding the code I now no longer need to read.
  - Commenting intention - as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.
  - Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &quot;shape&quot; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.
  - Commenting dependencies - a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &quot;environmental forces&quot; change.
  - Commenting on a choice of algorithm or data structure - there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &quot;incorrect&quot; - they all produce correct end result - by there are time/space/scalability tradeoffs to consider and the &quot;correct&quot; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.
  - Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &quot;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&quot;; at the end I settled for simple (but imprecise) &quot;CleanupSession()&quot; with appropriate comment.



Let me disagree with some of the specific points you make:

  - &quot;They do not change with the code.&quot; - Nor the other way around. I often find myself editing the comment simply to &quot;debug&quot; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.
  - &quot;A wrong comment is worse than horribly complex non-commented code.&quot; - True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &quot;comment consistency&quot; is useful technique for &quot;paradigm debugging&quot; in your head.
  - &quot;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&quot; - Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.
 - &quot;Comments don’t show up in stack traces.&quot; - No, they are one click away.
 - &quot;Reading comments is optional.&quot; - Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</description>
		<content:encoded><![CDATA[<p>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc&#8230; and these are just &#8220;physical&#8221; levels &#8211; there may be many domain-specific &#8220;logical&#8221; paradigms with no direct analog in the programming language/technology.</p>
<p>While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.</p>
<p>The rules of thumb for good comments are:</p>
<p>  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.<br />
  2. The comment is usually written BEFORE code.</p>
<p>Here are some examples:</p>
<p>  &#8211; Commenting the API is absolute must &#8211; the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.<br />
  &#8211; Everything is &#8220;API&#8221;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#8217;m not currently working on. Having high-level comments all over the place serves as a &#8220;shortcut&#8221; for understanding the code I now no longer need to read.<br />
  &#8211; Commenting intention &#8211; as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.<br />
  &#8211; Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &#8220;shape&#8221; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.<br />
  &#8211; Commenting dependencies &#8211; a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &#8220;environmental forces&#8221; change.<br />
  &#8211; Commenting on a choice of algorithm or data structure &#8211; there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &#8220;incorrect&#8221; &#8211; they all produce correct end result &#8211; by there are time/space/scalability tradeoffs to consider and the &#8220;correct&#8221; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.<br />
  &#8211; Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &#8220;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&#8221;; at the end I settled for simple (but imprecise) &#8220;CleanupSession()&#8221; with appropriate comment.</p>
<p>Let me disagree with some of the specific points you make:</p>
<p>  &#8211; &#8220;They do not change with the code.&#8221; &#8211; Nor the other way around. I often find myself editing the comment simply to &#8220;debug&#8221; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.<br />
  &#8211; &#8220;A wrong comment is worse than horribly complex non-commented code.&#8221; &#8211; True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &#8220;comment consistency&#8221; is useful technique for &#8220;paradigm debugging&#8221; in your head.<br />
  &#8211; &#8220;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&#8221; &#8211; Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.<br />
 &#8211; &#8220;Comments don’t show up in stack traces.&#8221; &#8211; No, they are one click away.<br />
 &#8211; &#8220;Reading comments is optional.&#8221; &#8211; Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57046</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57046</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 

If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: </p>
<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
	<atom:link href="http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eliminating-comments-the-road-to-clarity</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>Comments on: Eliminating Comments: the Road to Clarity</title>
	<atom:link href="http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eliminating-comments-the-road-to-clarity</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: BDKR</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-64454</link>
		<dc:creator>BDKR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 15:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-64454</guid>
		<description>What about the fact that there is some code that functions exactly as wished but doesn&#039;t really lend itself to self documentation? 

And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</description>
		<content:encoded><![CDATA[<p>What about the fact that there is some code that functions exactly as wished but doesn&#8217;t really lend itself to self documentation? </p>
<p>And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63841</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 19 May 2011 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63841</guid>
		<description> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.

I can reverse engineer your code but I can&#039;t reverse engineer your thoughts.

 If you are too lazy to update your comments when you update your code thats one thing. Just don&#039;t encourage others to do it.</description>
		<content:encoded><![CDATA[<p> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.</p>
<p>I can reverse engineer your code but I can&#8217;t reverse engineer your thoughts.</p>
<p> If you are too lazy to update your comments when you update your code thats one thing. Just don&#8217;t encourage others to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63831</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 May 2011 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63831</guid>
		<description> 
If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</description>
		<content:encoded><![CDATA[<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: florin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57909</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 16:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57909</guid>
		<description>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.
The comment should state, at least code comments, why something is done not what it is done.</description>
		<content:encoded><![CDATA[<p>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.<br />
The comment should state, at least code comments, why something is done not what it is done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jgauffin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57659</link>
		<dc:creator>jgauffin</dc:creator>
		<pubDate>Wed, 09 Jun 2010 11:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57659</guid>
		<description>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#039;t :)

I rather see documentation as a tool to write better code. And now I&#039;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.

I try to explain my point of view here:
http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</description>
		<content:encoded><![CDATA[<p>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#8217;t <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I rather see documentation as a tool to write better code. And now I&#8217;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.</p>
<p>I try to explain my point of view here:<br />
<a href="http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/" rel="nofollow">http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57221</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Mon, 17 May 2010 20:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57221</guid>
		<description>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#039;s name, which means your test and description/documentation always stay in sync. 

This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#039;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</description>
		<content:encoded><![CDATA[<p>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#8217;s name, which means your test and description/documentation always stay in sync. </p>
<p>This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#8217;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freddy rios</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57214</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Mon, 17 May 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57214</guid>
		<description>@Branko, you said:

&quot;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&quot;

Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#039;t easily/quickly understand what it is, it almost surely isn&#039;t good code. You say having the high-level comments all over the place serves as a &#039;shortcut&#039;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#039;t mean the situation wasn&#039;t created by a different problem, ignoring that perpetuates the issue.</description>
		<content:encoded><![CDATA[<p>@Branko, you said:</p>
<p>&#8220;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&#8221;</p>
<p>Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#8217;t easily/quickly understand what it is, it almost surely isn&#8217;t good code. You say having the high-level comments all over the place serves as a &#8216;shortcut&#8217;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#8217;t mean the situation wasn&#8217;t created by a different problem, ignoring that perpetuates the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Branko Dimitrijevic</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57115</link>
		<dc:creator>Branko Dimitrijevic</dc:creator>
		<pubDate>Thu, 13 May 2010 21:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57115</guid>
		<description>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc... and these are just &quot;physical&quot; levels - there may be many domain-specific &quot;logical&quot; paradigms with no direct analog in the programming language/technology.

While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.

The rules of thumb for good comments are:

  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.
  2. The comment is usually written BEFORE code.



Here are some examples:

  - Commenting the API is absolute must - the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.
  - Everything is &quot;API&quot;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#039;m not currently working on. Having high-level comments all over the place serves as a &quot;shortcut&quot; for understanding the code I now no longer need to read.
  - Commenting intention - as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.
  - Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &quot;shape&quot; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.
  - Commenting dependencies - a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &quot;environmental forces&quot; change.
  - Commenting on a choice of algorithm or data structure - there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &quot;incorrect&quot; - they all produce correct end result - by there are time/space/scalability tradeoffs to consider and the &quot;correct&quot; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.
  - Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &quot;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&quot;; at the end I settled for simple (but imprecise) &quot;CleanupSession()&quot; with appropriate comment.



Let me disagree with some of the specific points you make:

  - &quot;They do not change with the code.&quot; - Nor the other way around. I often find myself editing the comment simply to &quot;debug&quot; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.
  - &quot;A wrong comment is worse than horribly complex non-commented code.&quot; - True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &quot;comment consistency&quot; is useful technique for &quot;paradigm debugging&quot; in your head.
  - &quot;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&quot; - Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.
 - &quot;Comments don’t show up in stack traces.&quot; - No, they are one click away.
 - &quot;Reading comments is optional.&quot; - Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</description>
		<content:encoded><![CDATA[<p>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc&#8230; and these are just &#8220;physical&#8221; levels &#8211; there may be many domain-specific &#8220;logical&#8221; paradigms with no direct analog in the programming language/technology.</p>
<p>While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.</p>
<p>The rules of thumb for good comments are:</p>
<p>  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.<br />
  2. The comment is usually written BEFORE code.</p>
<p>Here are some examples:</p>
<p>  &#8211; Commenting the API is absolute must &#8211; the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.<br />
  &#8211; Everything is &#8220;API&#8221;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#8217;m not currently working on. Having high-level comments all over the place serves as a &#8220;shortcut&#8221; for understanding the code I now no longer need to read.<br />
  &#8211; Commenting intention &#8211; as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.<br />
  &#8211; Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &#8220;shape&#8221; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.<br />
  &#8211; Commenting dependencies &#8211; a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &#8220;environmental forces&#8221; change.<br />
  &#8211; Commenting on a choice of algorithm or data structure &#8211; there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &#8220;incorrect&#8221; &#8211; they all produce correct end result &#8211; by there are time/space/scalability tradeoffs to consider and the &#8220;correct&#8221; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.<br />
  &#8211; Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &#8220;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&#8221;; at the end I settled for simple (but imprecise) &#8220;CleanupSession()&#8221; with appropriate comment.</p>
<p>Let me disagree with some of the specific points you make:</p>
<p>  &#8211; &#8220;They do not change with the code.&#8221; &#8211; Nor the other way around. I often find myself editing the comment simply to &#8220;debug&#8221; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.<br />
  &#8211; &#8220;A wrong comment is worse than horribly complex non-commented code.&#8221; &#8211; True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &#8220;comment consistency&#8221; is useful technique for &#8220;paradigm debugging&#8221; in your head.<br />
  &#8211; &#8220;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&#8221; &#8211; Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.<br />
 &#8211; &#8220;Comments don’t show up in stack traces.&#8221; &#8211; No, they are one click away.<br />
 &#8211; &#8220;Reading comments is optional.&#8221; &#8211; Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57046</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57046</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 

If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: </p>
<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-64454</link>
		<dc:creator>BDKR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 15:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-64454</guid>
		<description>What about the fact that there is some code that functions exactly as wished but doesn&#039;t really lend itself to self documentation? 

And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</description>
		<content:encoded><![CDATA[<p>What about the fact that there is some code that functions exactly as wished but doesn&#8217;t really lend itself to self documentation? </p>
<p>And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comments on: Eliminating Comments: the Road to Clarity</title>
	<atom:link href="http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eliminating-comments-the-road-to-clarity</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: BDKR</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-64454</link>
		<dc:creator>BDKR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 15:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-64454</guid>
		<description>What about the fact that there is some code that functions exactly as wished but doesn&#039;t really lend itself to self documentation? 

And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</description>
		<content:encoded><![CDATA[<p>What about the fact that there is some code that functions exactly as wished but doesn&#8217;t really lend itself to self documentation? </p>
<p>And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63841</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 19 May 2011 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63841</guid>
		<description> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.

I can reverse engineer your code but I can&#039;t reverse engineer your thoughts.

 If you are too lazy to update your comments when you update your code thats one thing. Just don&#039;t encourage others to do it.</description>
		<content:encoded><![CDATA[<p> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.</p>
<p>I can reverse engineer your code but I can&#8217;t reverse engineer your thoughts.</p>
<p> If you are too lazy to update your comments when you update your code thats one thing. Just don&#8217;t encourage others to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63831</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 May 2011 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63831</guid>
		<description> 
If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</description>
		<content:encoded><![CDATA[<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: florin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57909</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 16:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57909</guid>
		<description>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.
The comment should state, at least code comments, why something is done not what it is done.</description>
		<content:encoded><![CDATA[<p>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.<br />
The comment should state, at least code comments, why something is done not what it is done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jgauffin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57659</link>
		<dc:creator>jgauffin</dc:creator>
		<pubDate>Wed, 09 Jun 2010 11:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57659</guid>
		<description>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#039;t :)

I rather see documentation as a tool to write better code. And now I&#039;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.

I try to explain my point of view here:
http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</description>
		<content:encoded><![CDATA[<p>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#8217;t <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I rather see documentation as a tool to write better code. And now I&#8217;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.</p>
<p>I try to explain my point of view here:<br />
<a href="http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/" rel="nofollow">http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57221</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Mon, 17 May 2010 20:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57221</guid>
		<description>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#039;s name, which means your test and description/documentation always stay in sync. 

This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#039;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</description>
		<content:encoded><![CDATA[<p>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#8217;s name, which means your test and description/documentation always stay in sync. </p>
<p>This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#8217;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freddy rios</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57214</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Mon, 17 May 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57214</guid>
		<description>@Branko, you said:

&quot;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&quot;

Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#039;t easily/quickly understand what it is, it almost surely isn&#039;t good code. You say having the high-level comments all over the place serves as a &#039;shortcut&#039;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#039;t mean the situation wasn&#039;t created by a different problem, ignoring that perpetuates the issue.</description>
		<content:encoded><![CDATA[<p>@Branko, you said:</p>
<p>&#8220;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&#8221;</p>
<p>Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#8217;t easily/quickly understand what it is, it almost surely isn&#8217;t good code. You say having the high-level comments all over the place serves as a &#8216;shortcut&#8217;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#8217;t mean the situation wasn&#8217;t created by a different problem, ignoring that perpetuates the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Branko Dimitrijevic</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57115</link>
		<dc:creator>Branko Dimitrijevic</dc:creator>
		<pubDate>Thu, 13 May 2010 21:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57115</guid>
		<description>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc... and these are just &quot;physical&quot; levels - there may be many domain-specific &quot;logical&quot; paradigms with no direct analog in the programming language/technology.

While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.

The rules of thumb for good comments are:

  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.
  2. The comment is usually written BEFORE code.



Here are some examples:

  - Commenting the API is absolute must - the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.
  - Everything is &quot;API&quot;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#039;m not currently working on. Having high-level comments all over the place serves as a &quot;shortcut&quot; for understanding the code I now no longer need to read.
  - Commenting intention - as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.
  - Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &quot;shape&quot; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.
  - Commenting dependencies - a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &quot;environmental forces&quot; change.
  - Commenting on a choice of algorithm or data structure - there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &quot;incorrect&quot; - they all produce correct end result - by there are time/space/scalability tradeoffs to consider and the &quot;correct&quot; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.
  - Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &quot;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&quot;; at the end I settled for simple (but imprecise) &quot;CleanupSession()&quot; with appropriate comment.



Let me disagree with some of the specific points you make:

  - &quot;They do not change with the code.&quot; - Nor the other way around. I often find myself editing the comment simply to &quot;debug&quot; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.
  - &quot;A wrong comment is worse than horribly complex non-commented code.&quot; - True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &quot;comment consistency&quot; is useful technique for &quot;paradigm debugging&quot; in your head.
  - &quot;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&quot; - Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.
 - &quot;Comments don’t show up in stack traces.&quot; - No, they are one click away.
 - &quot;Reading comments is optional.&quot; - Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</description>
		<content:encoded><![CDATA[<p>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc&#8230; and these are just &#8220;physical&#8221; levels &#8211; there may be many domain-specific &#8220;logical&#8221; paradigms with no direct analog in the programming language/technology.</p>
<p>While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.</p>
<p>The rules of thumb for good comments are:</p>
<p>  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.<br />
  2. The comment is usually written BEFORE code.</p>
<p>Here are some examples:</p>
<p>  &#8211; Commenting the API is absolute must &#8211; the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.<br />
  &#8211; Everything is &#8220;API&#8221;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#8217;m not currently working on. Having high-level comments all over the place serves as a &#8220;shortcut&#8221; for understanding the code I now no longer need to read.<br />
  &#8211; Commenting intention &#8211; as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.<br />
  &#8211; Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &#8220;shape&#8221; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.<br />
  &#8211; Commenting dependencies &#8211; a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &#8220;environmental forces&#8221; change.<br />
  &#8211; Commenting on a choice of algorithm or data structure &#8211; there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &#8220;incorrect&#8221; &#8211; they all produce correct end result &#8211; by there are time/space/scalability tradeoffs to consider and the &#8220;correct&#8221; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.<br />
  &#8211; Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &#8220;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&#8221;; at the end I settled for simple (but imprecise) &#8220;CleanupSession()&#8221; with appropriate comment.</p>
<p>Let me disagree with some of the specific points you make:</p>
<p>  &#8211; &#8220;They do not change with the code.&#8221; &#8211; Nor the other way around. I often find myself editing the comment simply to &#8220;debug&#8221; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.<br />
  &#8211; &#8220;A wrong comment is worse than horribly complex non-commented code.&#8221; &#8211; True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &#8220;comment consistency&#8221; is useful technique for &#8220;paradigm debugging&#8221; in your head.<br />
  &#8211; &#8220;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&#8221; &#8211; Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.<br />
 &#8211; &#8220;Comments don’t show up in stack traces.&#8221; &#8211; No, they are one click away.<br />
 &#8211; &#8220;Reading comments is optional.&#8221; &#8211; Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57046</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57046</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 

If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: </p>
<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63841</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 19 May 2011 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63841</guid>
		<description> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.

I can reverse engineer your code but I can&#039;t reverse engineer your thoughts.

 If you are too lazy to update your comments when you update your code thats one thing. Just don&#039;t encourage others to do it.</description>
		<content:encoded><![CDATA[<p> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.</p>
<p>I can reverse engineer your code but I can&#8217;t reverse engineer your thoughts.</p>
<p> If you are too lazy to update your comments when you update your code thats one thing. Just don&#8217;t encourage others to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comments on: Eliminating Comments: the Road to Clarity</title>
	<atom:link href="http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eliminating-comments-the-road-to-clarity</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: BDKR</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-64454</link>
		<dc:creator>BDKR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 15:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-64454</guid>
		<description>What about the fact that there is some code that functions exactly as wished but doesn&#039;t really lend itself to self documentation? 

And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</description>
		<content:encoded><![CDATA[<p>What about the fact that there is some code that functions exactly as wished but doesn&#8217;t really lend itself to self documentation? </p>
<p>And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63841</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 19 May 2011 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63841</guid>
		<description> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.

I can reverse engineer your code but I can&#039;t reverse engineer your thoughts.

 If you are too lazy to update your comments when you update your code thats one thing. Just don&#039;t encourage others to do it.</description>
		<content:encoded><![CDATA[<p> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.</p>
<p>I can reverse engineer your code but I can&#8217;t reverse engineer your thoughts.</p>
<p> If you are too lazy to update your comments when you update your code thats one thing. Just don&#8217;t encourage others to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63831</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 May 2011 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63831</guid>
		<description> 
If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</description>
		<content:encoded><![CDATA[<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: florin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57909</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 16:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57909</guid>
		<description>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.
The comment should state, at least code comments, why something is done not what it is done.</description>
		<content:encoded><![CDATA[<p>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.<br />
The comment should state, at least code comments, why something is done not what it is done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jgauffin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57659</link>
		<dc:creator>jgauffin</dc:creator>
		<pubDate>Wed, 09 Jun 2010 11:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57659</guid>
		<description>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#039;t :)

I rather see documentation as a tool to write better code. And now I&#039;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.

I try to explain my point of view here:
http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</description>
		<content:encoded><![CDATA[<p>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#8217;t <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I rather see documentation as a tool to write better code. And now I&#8217;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.</p>
<p>I try to explain my point of view here:<br />
<a href="http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/" rel="nofollow">http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57221</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Mon, 17 May 2010 20:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57221</guid>
		<description>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#039;s name, which means your test and description/documentation always stay in sync. 

This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#039;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</description>
		<content:encoded><![CDATA[<p>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#8217;s name, which means your test and description/documentation always stay in sync. </p>
<p>This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#8217;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freddy rios</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57214</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Mon, 17 May 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57214</guid>
		<description>@Branko, you said:

&quot;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&quot;

Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#039;t easily/quickly understand what it is, it almost surely isn&#039;t good code. You say having the high-level comments all over the place serves as a &#039;shortcut&#039;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#039;t mean the situation wasn&#039;t created by a different problem, ignoring that perpetuates the issue.</description>
		<content:encoded><![CDATA[<p>@Branko, you said:</p>
<p>&#8220;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&#8221;</p>
<p>Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#8217;t easily/quickly understand what it is, it almost surely isn&#8217;t good code. You say having the high-level comments all over the place serves as a &#8216;shortcut&#8217;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#8217;t mean the situation wasn&#8217;t created by a different problem, ignoring that perpetuates the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Branko Dimitrijevic</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57115</link>
		<dc:creator>Branko Dimitrijevic</dc:creator>
		<pubDate>Thu, 13 May 2010 21:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57115</guid>
		<description>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc... and these are just &quot;physical&quot; levels - there may be many domain-specific &quot;logical&quot; paradigms with no direct analog in the programming language/technology.

While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.

The rules of thumb for good comments are:

  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.
  2. The comment is usually written BEFORE code.



Here are some examples:

  - Commenting the API is absolute must - the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.
  - Everything is &quot;API&quot;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#039;m not currently working on. Having high-level comments all over the place serves as a &quot;shortcut&quot; for understanding the code I now no longer need to read.
  - Commenting intention - as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.
  - Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &quot;shape&quot; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.
  - Commenting dependencies - a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &quot;environmental forces&quot; change.
  - Commenting on a choice of algorithm or data structure - there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &quot;incorrect&quot; - they all produce correct end result - by there are time/space/scalability tradeoffs to consider and the &quot;correct&quot; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.
  - Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &quot;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&quot;; at the end I settled for simple (but imprecise) &quot;CleanupSession()&quot; with appropriate comment.



Let me disagree with some of the specific points you make:

  - &quot;They do not change with the code.&quot; - Nor the other way around. I often find myself editing the comment simply to &quot;debug&quot; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.
  - &quot;A wrong comment is worse than horribly complex non-commented code.&quot; - True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &quot;comment consistency&quot; is useful technique for &quot;paradigm debugging&quot; in your head.
  - &quot;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&quot; - Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.
 - &quot;Comments don’t show up in stack traces.&quot; - No, they are one click away.
 - &quot;Reading comments is optional.&quot; - Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</description>
		<content:encoded><![CDATA[<p>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc&#8230; and these are just &#8220;physical&#8221; levels &#8211; there may be many domain-specific &#8220;logical&#8221; paradigms with no direct analog in the programming language/technology.</p>
<p>While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.</p>
<p>The rules of thumb for good comments are:</p>
<p>  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.<br />
  2. The comment is usually written BEFORE code.</p>
<p>Here are some examples:</p>
<p>  &#8211; Commenting the API is absolute must &#8211; the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.<br />
  &#8211; Everything is &#8220;API&#8221;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#8217;m not currently working on. Having high-level comments all over the place serves as a &#8220;shortcut&#8221; for understanding the code I now no longer need to read.<br />
  &#8211; Commenting intention &#8211; as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.<br />
  &#8211; Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &#8220;shape&#8221; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.<br />
  &#8211; Commenting dependencies &#8211; a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &#8220;environmental forces&#8221; change.<br />
  &#8211; Commenting on a choice of algorithm or data structure &#8211; there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &#8220;incorrect&#8221; &#8211; they all produce correct end result &#8211; by there are time/space/scalability tradeoffs to consider and the &#8220;correct&#8221; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.<br />
  &#8211; Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &#8220;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&#8221;; at the end I settled for simple (but imprecise) &#8220;CleanupSession()&#8221; with appropriate comment.</p>
<p>Let me disagree with some of the specific points you make:</p>
<p>  &#8211; &#8220;They do not change with the code.&#8221; &#8211; Nor the other way around. I often find myself editing the comment simply to &#8220;debug&#8221; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.<br />
  &#8211; &#8220;A wrong comment is worse than horribly complex non-commented code.&#8221; &#8211; True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &#8220;comment consistency&#8221; is useful technique for &#8220;paradigm debugging&#8221; in your head.<br />
  &#8211; &#8220;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&#8221; &#8211; Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.<br />
 &#8211; &#8220;Comments don’t show up in stack traces.&#8221; &#8211; No, they are one click away.<br />
 &#8211; &#8220;Reading comments is optional.&#8221; &#8211; Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57046</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57046</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 

If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: </p>
<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63831</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 May 2011 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63831</guid>
		<description> 
If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</description>
		<content:encoded><![CDATA[<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comments on: Eliminating Comments: the Road to Clarity</title>
	<atom:link href="http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eliminating-comments-the-road-to-clarity</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: BDKR</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-64454</link>
		<dc:creator>BDKR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 15:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-64454</guid>
		<description>What about the fact that there is some code that functions exactly as wished but doesn&#039;t really lend itself to self documentation? 

And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</description>
		<content:encoded><![CDATA[<p>What about the fact that there is some code that functions exactly as wished but doesn&#8217;t really lend itself to self documentation? </p>
<p>And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63841</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 19 May 2011 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63841</guid>
		<description> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.

I can reverse engineer your code but I can&#039;t reverse engineer your thoughts.

 If you are too lazy to update your comments when you update your code thats one thing. Just don&#039;t encourage others to do it.</description>
		<content:encoded><![CDATA[<p> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.</p>
<p>I can reverse engineer your code but I can&#8217;t reverse engineer your thoughts.</p>
<p> If you are too lazy to update your comments when you update your code thats one thing. Just don&#8217;t encourage others to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63831</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 May 2011 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63831</guid>
		<description> 
If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</description>
		<content:encoded><![CDATA[<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: florin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57909</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 16:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57909</guid>
		<description>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.
The comment should state, at least code comments, why something is done not what it is done.</description>
		<content:encoded><![CDATA[<p>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.<br />
The comment should state, at least code comments, why something is done not what it is done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jgauffin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57659</link>
		<dc:creator>jgauffin</dc:creator>
		<pubDate>Wed, 09 Jun 2010 11:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57659</guid>
		<description>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#039;t :)

I rather see documentation as a tool to write better code. And now I&#039;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.

I try to explain my point of view here:
http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</description>
		<content:encoded><![CDATA[<p>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#8217;t <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I rather see documentation as a tool to write better code. And now I&#8217;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.</p>
<p>I try to explain my point of view here:<br />
<a href="http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/" rel="nofollow">http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57221</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Mon, 17 May 2010 20:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57221</guid>
		<description>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#039;s name, which means your test and description/documentation always stay in sync. 

This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#039;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</description>
		<content:encoded><![CDATA[<p>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#8217;s name, which means your test and description/documentation always stay in sync. </p>
<p>This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#8217;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freddy rios</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57214</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Mon, 17 May 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57214</guid>
		<description>@Branko, you said:

&quot;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&quot;

Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#039;t easily/quickly understand what it is, it almost surely isn&#039;t good code. You say having the high-level comments all over the place serves as a &#039;shortcut&#039;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#039;t mean the situation wasn&#039;t created by a different problem, ignoring that perpetuates the issue.</description>
		<content:encoded><![CDATA[<p>@Branko, you said:</p>
<p>&#8220;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&#8221;</p>
<p>Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#8217;t easily/quickly understand what it is, it almost surely isn&#8217;t good code. You say having the high-level comments all over the place serves as a &#8216;shortcut&#8217;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#8217;t mean the situation wasn&#8217;t created by a different problem, ignoring that perpetuates the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Branko Dimitrijevic</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57115</link>
		<dc:creator>Branko Dimitrijevic</dc:creator>
		<pubDate>Thu, 13 May 2010 21:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57115</guid>
		<description>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc... and these are just &quot;physical&quot; levels - there may be many domain-specific &quot;logical&quot; paradigms with no direct analog in the programming language/technology.

While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.

The rules of thumb for good comments are:

  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.
  2. The comment is usually written BEFORE code.



Here are some examples:

  - Commenting the API is absolute must - the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.
  - Everything is &quot;API&quot;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#039;m not currently working on. Having high-level comments all over the place serves as a &quot;shortcut&quot; for understanding the code I now no longer need to read.
  - Commenting intention - as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.
  - Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &quot;shape&quot; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.
  - Commenting dependencies - a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &quot;environmental forces&quot; change.
  - Commenting on a choice of algorithm or data structure - there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &quot;incorrect&quot; - they all produce correct end result - by there are time/space/scalability tradeoffs to consider and the &quot;correct&quot; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.
  - Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &quot;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&quot;; at the end I settled for simple (but imprecise) &quot;CleanupSession()&quot; with appropriate comment.



Let me disagree with some of the specific points you make:

  - &quot;They do not change with the code.&quot; - Nor the other way around. I often find myself editing the comment simply to &quot;debug&quot; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.
  - &quot;A wrong comment is worse than horribly complex non-commented code.&quot; - True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &quot;comment consistency&quot; is useful technique for &quot;paradigm debugging&quot; in your head.
  - &quot;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&quot; - Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.
 - &quot;Comments don’t show up in stack traces.&quot; - No, they are one click away.
 - &quot;Reading comments is optional.&quot; - Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</description>
		<content:encoded><![CDATA[<p>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc&#8230; and these are just &#8220;physical&#8221; levels &#8211; there may be many domain-specific &#8220;logical&#8221; paradigms with no direct analog in the programming language/technology.</p>
<p>While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.</p>
<p>The rules of thumb for good comments are:</p>
<p>  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.<br />
  2. The comment is usually written BEFORE code.</p>
<p>Here are some examples:</p>
<p>  &#8211; Commenting the API is absolute must &#8211; the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.<br />
  &#8211; Everything is &#8220;API&#8221;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#8217;m not currently working on. Having high-level comments all over the place serves as a &#8220;shortcut&#8221; for understanding the code I now no longer need to read.<br />
  &#8211; Commenting intention &#8211; as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.<br />
  &#8211; Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &#8220;shape&#8221; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.<br />
  &#8211; Commenting dependencies &#8211; a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &#8220;environmental forces&#8221; change.<br />
  &#8211; Commenting on a choice of algorithm or data structure &#8211; there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &#8220;incorrect&#8221; &#8211; they all produce correct end result &#8211; by there are time/space/scalability tradeoffs to consider and the &#8220;correct&#8221; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.<br />
  &#8211; Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &#8220;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&#8221;; at the end I settled for simple (but imprecise) &#8220;CleanupSession()&#8221; with appropriate comment.</p>
<p>Let me disagree with some of the specific points you make:</p>
<p>  &#8211; &#8220;They do not change with the code.&#8221; &#8211; Nor the other way around. I often find myself editing the comment simply to &#8220;debug&#8221; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.<br />
  &#8211; &#8220;A wrong comment is worse than horribly complex non-commented code.&#8221; &#8211; True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &#8220;comment consistency&#8221; is useful technique for &#8220;paradigm debugging&#8221; in your head.<br />
  &#8211; &#8220;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&#8221; &#8211; Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.<br />
 &#8211; &#8220;Comments don’t show up in stack traces.&#8221; &#8211; No, they are one click away.<br />
 &#8211; &#8220;Reading comments is optional.&#8221; &#8211; Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57046</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57046</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 

If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: </p>
<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57909</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 16:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57909</guid>
		<description>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.
The comment should state, at least code comments, why something is done not what it is done.</description>
		<content:encoded><![CDATA[<p>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.<br />
The comment should state, at least code comments, why something is done not what it is done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comments on: Eliminating Comments: the Road to Clarity</title>
	<atom:link href="http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eliminating-comments-the-road-to-clarity</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: BDKR</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-64454</link>
		<dc:creator>BDKR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 15:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-64454</guid>
		<description>What about the fact that there is some code that functions exactly as wished but doesn&#039;t really lend itself to self documentation? 

And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</description>
		<content:encoded><![CDATA[<p>What about the fact that there is some code that functions exactly as wished but doesn&#8217;t really lend itself to self documentation? </p>
<p>And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63841</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 19 May 2011 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63841</guid>
		<description> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.

I can reverse engineer your code but I can&#039;t reverse engineer your thoughts.

 If you are too lazy to update your comments when you update your code thats one thing. Just don&#039;t encourage others to do it.</description>
		<content:encoded><![CDATA[<p> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.</p>
<p>I can reverse engineer your code but I can&#8217;t reverse engineer your thoughts.</p>
<p> If you are too lazy to update your comments when you update your code thats one thing. Just don&#8217;t encourage others to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63831</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 May 2011 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63831</guid>
		<description> 
If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</description>
		<content:encoded><![CDATA[<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: florin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57909</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 16:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57909</guid>
		<description>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.
The comment should state, at least code comments, why something is done not what it is done.</description>
		<content:encoded><![CDATA[<p>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.<br />
The comment should state, at least code comments, why something is done not what it is done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jgauffin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57659</link>
		<dc:creator>jgauffin</dc:creator>
		<pubDate>Wed, 09 Jun 2010 11:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57659</guid>
		<description>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#039;t :)

I rather see documentation as a tool to write better code. And now I&#039;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.

I try to explain my point of view here:
http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</description>
		<content:encoded><![CDATA[<p>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#8217;t <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I rather see documentation as a tool to write better code. And now I&#8217;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.</p>
<p>I try to explain my point of view here:<br />
<a href="http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/" rel="nofollow">http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57221</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Mon, 17 May 2010 20:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57221</guid>
		<description>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#039;s name, which means your test and description/documentation always stay in sync. 

This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#039;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</description>
		<content:encoded><![CDATA[<p>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#8217;s name, which means your test and description/documentation always stay in sync. </p>
<p>This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#8217;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freddy rios</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57214</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Mon, 17 May 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57214</guid>
		<description>@Branko, you said:

&quot;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&quot;

Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#039;t easily/quickly understand what it is, it almost surely isn&#039;t good code. You say having the high-level comments all over the place serves as a &#039;shortcut&#039;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#039;t mean the situation wasn&#039;t created by a different problem, ignoring that perpetuates the issue.</description>
		<content:encoded><![CDATA[<p>@Branko, you said:</p>
<p>&#8220;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&#8221;</p>
<p>Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#8217;t easily/quickly understand what it is, it almost surely isn&#8217;t good code. You say having the high-level comments all over the place serves as a &#8216;shortcut&#8217;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#8217;t mean the situation wasn&#8217;t created by a different problem, ignoring that perpetuates the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Branko Dimitrijevic</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57115</link>
		<dc:creator>Branko Dimitrijevic</dc:creator>
		<pubDate>Thu, 13 May 2010 21:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57115</guid>
		<description>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc... and these are just &quot;physical&quot; levels - there may be many domain-specific &quot;logical&quot; paradigms with no direct analog in the programming language/technology.

While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.

The rules of thumb for good comments are:

  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.
  2. The comment is usually written BEFORE code.



Here are some examples:

  - Commenting the API is absolute must - the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.
  - Everything is &quot;API&quot;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#039;m not currently working on. Having high-level comments all over the place serves as a &quot;shortcut&quot; for understanding the code I now no longer need to read.
  - Commenting intention - as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.
  - Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &quot;shape&quot; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.
  - Commenting dependencies - a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &quot;environmental forces&quot; change.
  - Commenting on a choice of algorithm or data structure - there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &quot;incorrect&quot; - they all produce correct end result - by there are time/space/scalability tradeoffs to consider and the &quot;correct&quot; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.
  - Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &quot;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&quot;; at the end I settled for simple (but imprecise) &quot;CleanupSession()&quot; with appropriate comment.



Let me disagree with some of the specific points you make:

  - &quot;They do not change with the code.&quot; - Nor the other way around. I often find myself editing the comment simply to &quot;debug&quot; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.
  - &quot;A wrong comment is worse than horribly complex non-commented code.&quot; - True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &quot;comment consistency&quot; is useful technique for &quot;paradigm debugging&quot; in your head.
  - &quot;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&quot; - Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.
 - &quot;Comments don’t show up in stack traces.&quot; - No, they are one click away.
 - &quot;Reading comments is optional.&quot; - Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</description>
		<content:encoded><![CDATA[<p>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc&#8230; and these are just &#8220;physical&#8221; levels &#8211; there may be many domain-specific &#8220;logical&#8221; paradigms with no direct analog in the programming language/technology.</p>
<p>While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.</p>
<p>The rules of thumb for good comments are:</p>
<p>  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.<br />
  2. The comment is usually written BEFORE code.</p>
<p>Here are some examples:</p>
<p>  &#8211; Commenting the API is absolute must &#8211; the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.<br />
  &#8211; Everything is &#8220;API&#8221;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#8217;m not currently working on. Having high-level comments all over the place serves as a &#8220;shortcut&#8221; for understanding the code I now no longer need to read.<br />
  &#8211; Commenting intention &#8211; as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.<br />
  &#8211; Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &#8220;shape&#8221; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.<br />
  &#8211; Commenting dependencies &#8211; a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &#8220;environmental forces&#8221; change.<br />
  &#8211; Commenting on a choice of algorithm or data structure &#8211; there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &#8220;incorrect&#8221; &#8211; they all produce correct end result &#8211; by there are time/space/scalability tradeoffs to consider and the &#8220;correct&#8221; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.<br />
  &#8211; Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &#8220;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&#8221;; at the end I settled for simple (but imprecise) &#8220;CleanupSession()&#8221; with appropriate comment.</p>
<p>Let me disagree with some of the specific points you make:</p>
<p>  &#8211; &#8220;They do not change with the code.&#8221; &#8211; Nor the other way around. I often find myself editing the comment simply to &#8220;debug&#8221; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.<br />
  &#8211; &#8220;A wrong comment is worse than horribly complex non-commented code.&#8221; &#8211; True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &#8220;comment consistency&#8221; is useful technique for &#8220;paradigm debugging&#8221; in your head.<br />
  &#8211; &#8220;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&#8221; &#8211; Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.<br />
 &#8211; &#8220;Comments don’t show up in stack traces.&#8221; &#8211; No, they are one click away.<br />
 &#8211; &#8220;Reading comments is optional.&#8221; &#8211; Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57046</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57046</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 

If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: </p>
<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57659</link>
		<dc:creator>jgauffin</dc:creator>
		<pubDate>Wed, 09 Jun 2010 11:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57659</guid>
		<description>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#039;t :)

I rather see documentation as a tool to write better code. And now I&#039;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.

I try to explain my point of view here:
http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</description>
		<content:encoded><![CDATA[<p>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#8217;t <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I rather see documentation as a tool to write better code. And now I&#8217;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.</p>
<p>I try to explain my point of view here:<br />
<a href="http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/" rel="nofollow">http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comments on: Eliminating Comments: the Road to Clarity</title>
	<atom:link href="http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eliminating-comments-the-road-to-clarity</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: BDKR</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-64454</link>
		<dc:creator>BDKR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 15:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-64454</guid>
		<description>What about the fact that there is some code that functions exactly as wished but doesn&#039;t really lend itself to self documentation? 

And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</description>
		<content:encoded><![CDATA[<p>What about the fact that there is some code that functions exactly as wished but doesn&#8217;t really lend itself to self documentation? </p>
<p>And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63841</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 19 May 2011 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63841</guid>
		<description> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.

I can reverse engineer your code but I can&#039;t reverse engineer your thoughts.

 If you are too lazy to update your comments when you update your code thats one thing. Just don&#039;t encourage others to do it.</description>
		<content:encoded><![CDATA[<p> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.</p>
<p>I can reverse engineer your code but I can&#8217;t reverse engineer your thoughts.</p>
<p> If you are too lazy to update your comments when you update your code thats one thing. Just don&#8217;t encourage others to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63831</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 May 2011 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63831</guid>
		<description> 
If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</description>
		<content:encoded><![CDATA[<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: florin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57909</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 16:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57909</guid>
		<description>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.
The comment should state, at least code comments, why something is done not what it is done.</description>
		<content:encoded><![CDATA[<p>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.<br />
The comment should state, at least code comments, why something is done not what it is done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jgauffin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57659</link>
		<dc:creator>jgauffin</dc:creator>
		<pubDate>Wed, 09 Jun 2010 11:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57659</guid>
		<description>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#039;t :)

I rather see documentation as a tool to write better code. And now I&#039;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.

I try to explain my point of view here:
http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</description>
		<content:encoded><![CDATA[<p>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#8217;t <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I rather see documentation as a tool to write better code. And now I&#8217;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.</p>
<p>I try to explain my point of view here:<br />
<a href="http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/" rel="nofollow">http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57221</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Mon, 17 May 2010 20:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57221</guid>
		<description>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#039;s name, which means your test and description/documentation always stay in sync. 

This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#039;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</description>
		<content:encoded><![CDATA[<p>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#8217;s name, which means your test and description/documentation always stay in sync. </p>
<p>This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#8217;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freddy rios</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57214</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Mon, 17 May 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57214</guid>
		<description>@Branko, you said:

&quot;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&quot;

Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#039;t easily/quickly understand what it is, it almost surely isn&#039;t good code. You say having the high-level comments all over the place serves as a &#039;shortcut&#039;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#039;t mean the situation wasn&#039;t created by a different problem, ignoring that perpetuates the issue.</description>
		<content:encoded><![CDATA[<p>@Branko, you said:</p>
<p>&#8220;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&#8221;</p>
<p>Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#8217;t easily/quickly understand what it is, it almost surely isn&#8217;t good code. You say having the high-level comments all over the place serves as a &#8216;shortcut&#8217;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#8217;t mean the situation wasn&#8217;t created by a different problem, ignoring that perpetuates the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Branko Dimitrijevic</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57115</link>
		<dc:creator>Branko Dimitrijevic</dc:creator>
		<pubDate>Thu, 13 May 2010 21:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57115</guid>
		<description>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc... and these are just &quot;physical&quot; levels - there may be many domain-specific &quot;logical&quot; paradigms with no direct analog in the programming language/technology.

While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.

The rules of thumb for good comments are:

  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.
  2. The comment is usually written BEFORE code.



Here are some examples:

  - Commenting the API is absolute must - the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.
  - Everything is &quot;API&quot;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#039;m not currently working on. Having high-level comments all over the place serves as a &quot;shortcut&quot; for understanding the code I now no longer need to read.
  - Commenting intention - as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.
  - Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &quot;shape&quot; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.
  - Commenting dependencies - a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &quot;environmental forces&quot; change.
  - Commenting on a choice of algorithm or data structure - there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &quot;incorrect&quot; - they all produce correct end result - by there are time/space/scalability tradeoffs to consider and the &quot;correct&quot; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.
  - Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &quot;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&quot;; at the end I settled for simple (but imprecise) &quot;CleanupSession()&quot; with appropriate comment.



Let me disagree with some of the specific points you make:

  - &quot;They do not change with the code.&quot; - Nor the other way around. I often find myself editing the comment simply to &quot;debug&quot; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.
  - &quot;A wrong comment is worse than horribly complex non-commented code.&quot; - True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &quot;comment consistency&quot; is useful technique for &quot;paradigm debugging&quot; in your head.
  - &quot;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&quot; - Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.
 - &quot;Comments don’t show up in stack traces.&quot; - No, they are one click away.
 - &quot;Reading comments is optional.&quot; - Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</description>
		<content:encoded><![CDATA[<p>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc&#8230; and these are just &#8220;physical&#8221; levels &#8211; there may be many domain-specific &#8220;logical&#8221; paradigms with no direct analog in the programming language/technology.</p>
<p>While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.</p>
<p>The rules of thumb for good comments are:</p>
<p>  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.<br />
  2. The comment is usually written BEFORE code.</p>
<p>Here are some examples:</p>
<p>  &#8211; Commenting the API is absolute must &#8211; the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.<br />
  &#8211; Everything is &#8220;API&#8221;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#8217;m not currently working on. Having high-level comments all over the place serves as a &#8220;shortcut&#8221; for understanding the code I now no longer need to read.<br />
  &#8211; Commenting intention &#8211; as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.<br />
  &#8211; Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &#8220;shape&#8221; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.<br />
  &#8211; Commenting dependencies &#8211; a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &#8220;environmental forces&#8221; change.<br />
  &#8211; Commenting on a choice of algorithm or data structure &#8211; there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &#8220;incorrect&#8221; &#8211; they all produce correct end result &#8211; by there are time/space/scalability tradeoffs to consider and the &#8220;correct&#8221; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.<br />
  &#8211; Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &#8220;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&#8221;; at the end I settled for simple (but imprecise) &#8220;CleanupSession()&#8221; with appropriate comment.</p>
<p>Let me disagree with some of the specific points you make:</p>
<p>  &#8211; &#8220;They do not change with the code.&#8221; &#8211; Nor the other way around. I often find myself editing the comment simply to &#8220;debug&#8221; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.<br />
  &#8211; &#8220;A wrong comment is worse than horribly complex non-commented code.&#8221; &#8211; True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &#8220;comment consistency&#8221; is useful technique for &#8220;paradigm debugging&#8221; in your head.<br />
  &#8211; &#8220;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&#8221; &#8211; Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.<br />
 &#8211; &#8220;Comments don’t show up in stack traces.&#8221; &#8211; No, they are one click away.<br />
 &#8211; &#8220;Reading comments is optional.&#8221; &#8211; Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57046</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57046</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 

If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: </p>
<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57221</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Mon, 17 May 2010 20:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57221</guid>
		<description>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#039;s name, which means your test and description/documentation always stay in sync. 

This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#039;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</description>
		<content:encoded><![CDATA[<p>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#8217;s name, which means your test and description/documentation always stay in sync. </p>
<p>This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#8217;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comments on: Eliminating Comments: the Road to Clarity</title>
	<atom:link href="http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eliminating-comments-the-road-to-clarity</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: BDKR</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-64454</link>
		<dc:creator>BDKR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 15:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-64454</guid>
		<description>What about the fact that there is some code that functions exactly as wished but doesn&#039;t really lend itself to self documentation? 

And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</description>
		<content:encoded><![CDATA[<p>What about the fact that there is some code that functions exactly as wished but doesn&#8217;t really lend itself to self documentation? </p>
<p>And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63841</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 19 May 2011 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63841</guid>
		<description> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.

I can reverse engineer your code but I can&#039;t reverse engineer your thoughts.

 If you are too lazy to update your comments when you update your code thats one thing. Just don&#039;t encourage others to do it.</description>
		<content:encoded><![CDATA[<p> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.</p>
<p>I can reverse engineer your code but I can&#8217;t reverse engineer your thoughts.</p>
<p> If you are too lazy to update your comments when you update your code thats one thing. Just don&#8217;t encourage others to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63831</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 May 2011 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63831</guid>
		<description> 
If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</description>
		<content:encoded><![CDATA[<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: florin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57909</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 16:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57909</guid>
		<description>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.
The comment should state, at least code comments, why something is done not what it is done.</description>
		<content:encoded><![CDATA[<p>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.<br />
The comment should state, at least code comments, why something is done not what it is done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jgauffin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57659</link>
		<dc:creator>jgauffin</dc:creator>
		<pubDate>Wed, 09 Jun 2010 11:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57659</guid>
		<description>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#039;t :)

I rather see documentation as a tool to write better code. And now I&#039;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.

I try to explain my point of view here:
http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</description>
		<content:encoded><![CDATA[<p>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#8217;t <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I rather see documentation as a tool to write better code. And now I&#8217;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.</p>
<p>I try to explain my point of view here:<br />
<a href="http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/" rel="nofollow">http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57221</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Mon, 17 May 2010 20:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57221</guid>
		<description>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#039;s name, which means your test and description/documentation always stay in sync. 

This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#039;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</description>
		<content:encoded><![CDATA[<p>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#8217;s name, which means your test and description/documentation always stay in sync. </p>
<p>This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#8217;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freddy rios</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57214</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Mon, 17 May 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57214</guid>
		<description>@Branko, you said:

&quot;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&quot;

Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#039;t easily/quickly understand what it is, it almost surely isn&#039;t good code. You say having the high-level comments all over the place serves as a &#039;shortcut&#039;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#039;t mean the situation wasn&#039;t created by a different problem, ignoring that perpetuates the issue.</description>
		<content:encoded><![CDATA[<p>@Branko, you said:</p>
<p>&#8220;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&#8221;</p>
<p>Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#8217;t easily/quickly understand what it is, it almost surely isn&#8217;t good code. You say having the high-level comments all over the place serves as a &#8216;shortcut&#8217;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#8217;t mean the situation wasn&#8217;t created by a different problem, ignoring that perpetuates the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Branko Dimitrijevic</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57115</link>
		<dc:creator>Branko Dimitrijevic</dc:creator>
		<pubDate>Thu, 13 May 2010 21:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57115</guid>
		<description>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc... and these are just &quot;physical&quot; levels - there may be many domain-specific &quot;logical&quot; paradigms with no direct analog in the programming language/technology.

While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.

The rules of thumb for good comments are:

  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.
  2. The comment is usually written BEFORE code.



Here are some examples:

  - Commenting the API is absolute must - the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.
  - Everything is &quot;API&quot;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#039;m not currently working on. Having high-level comments all over the place serves as a &quot;shortcut&quot; for understanding the code I now no longer need to read.
  - Commenting intention - as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.
  - Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &quot;shape&quot; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.
  - Commenting dependencies - a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &quot;environmental forces&quot; change.
  - Commenting on a choice of algorithm or data structure - there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &quot;incorrect&quot; - they all produce correct end result - by there are time/space/scalability tradeoffs to consider and the &quot;correct&quot; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.
  - Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &quot;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&quot;; at the end I settled for simple (but imprecise) &quot;CleanupSession()&quot; with appropriate comment.



Let me disagree with some of the specific points you make:

  - &quot;They do not change with the code.&quot; - Nor the other way around. I often find myself editing the comment simply to &quot;debug&quot; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.
  - &quot;A wrong comment is worse than horribly complex non-commented code.&quot; - True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &quot;comment consistency&quot; is useful technique for &quot;paradigm debugging&quot; in your head.
  - &quot;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&quot; - Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.
 - &quot;Comments don’t show up in stack traces.&quot; - No, they are one click away.
 - &quot;Reading comments is optional.&quot; - Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</description>
		<content:encoded><![CDATA[<p>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc&#8230; and these are just &#8220;physical&#8221; levels &#8211; there may be many domain-specific &#8220;logical&#8221; paradigms with no direct analog in the programming language/technology.</p>
<p>While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.</p>
<p>The rules of thumb for good comments are:</p>
<p>  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.<br />
  2. The comment is usually written BEFORE code.</p>
<p>Here are some examples:</p>
<p>  &#8211; Commenting the API is absolute must &#8211; the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.<br />
  &#8211; Everything is &#8220;API&#8221;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#8217;m not currently working on. Having high-level comments all over the place serves as a &#8220;shortcut&#8221; for understanding the code I now no longer need to read.<br />
  &#8211; Commenting intention &#8211; as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.<br />
  &#8211; Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &#8220;shape&#8221; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.<br />
  &#8211; Commenting dependencies &#8211; a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &#8220;environmental forces&#8221; change.<br />
  &#8211; Commenting on a choice of algorithm or data structure &#8211; there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &#8220;incorrect&#8221; &#8211; they all produce correct end result &#8211; by there are time/space/scalability tradeoffs to consider and the &#8220;correct&#8221; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.<br />
  &#8211; Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &#8220;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&#8221;; at the end I settled for simple (but imprecise) &#8220;CleanupSession()&#8221; with appropriate comment.</p>
<p>Let me disagree with some of the specific points you make:</p>
<p>  &#8211; &#8220;They do not change with the code.&#8221; &#8211; Nor the other way around. I often find myself editing the comment simply to &#8220;debug&#8221; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.<br />
  &#8211; &#8220;A wrong comment is worse than horribly complex non-commented code.&#8221; &#8211; True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &#8220;comment consistency&#8221; is useful technique for &#8220;paradigm debugging&#8221; in your head.<br />
  &#8211; &#8220;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&#8221; &#8211; Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.<br />
 &#8211; &#8220;Comments don’t show up in stack traces.&#8221; &#8211; No, they are one click away.<br />
 &#8211; &#8220;Reading comments is optional.&#8221; &#8211; Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57046</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57046</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 

If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: </p>
<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57214</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Mon, 17 May 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57214</guid>
		<description>@Branko, you said:

&quot;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&quot;

Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#039;t easily/quickly understand what it is, it almost surely isn&#039;t good code. You say having the high-level comments all over the place serves as a &#039;shortcut&#039;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#039;t mean the situation wasn&#039;t created by a different problem, ignoring that perpetuates the issue.</description>
		<content:encoded><![CDATA[<p>@Branko, you said:</p>
<p>&#8220;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&#8221;</p>
<p>Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#8217;t easily/quickly understand what it is, it almost surely isn&#8217;t good code. You say having the high-level comments all over the place serves as a &#8216;shortcut&#8217;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#8217;t mean the situation wasn&#8217;t created by a different problem, ignoring that perpetuates the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comments on: Eliminating Comments: the Road to Clarity</title>
	<atom:link href="http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eliminating-comments-the-road-to-clarity</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: BDKR</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-64454</link>
		<dc:creator>BDKR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 15:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-64454</guid>
		<description>What about the fact that there is some code that functions exactly as wished but doesn&#039;t really lend itself to self documentation? 

And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</description>
		<content:encoded><![CDATA[<p>What about the fact that there is some code that functions exactly as wished but doesn&#8217;t really lend itself to self documentation? </p>
<p>And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63841</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 19 May 2011 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63841</guid>
		<description> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.

I can reverse engineer your code but I can&#039;t reverse engineer your thoughts.

 If you are too lazy to update your comments when you update your code thats one thing. Just don&#039;t encourage others to do it.</description>
		<content:encoded><![CDATA[<p> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.</p>
<p>I can reverse engineer your code but I can&#8217;t reverse engineer your thoughts.</p>
<p> If you are too lazy to update your comments when you update your code thats one thing. Just don&#8217;t encourage others to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63831</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 May 2011 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63831</guid>
		<description> 
If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</description>
		<content:encoded><![CDATA[<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: florin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57909</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 16:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57909</guid>
		<description>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.
The comment should state, at least code comments, why something is done not what it is done.</description>
		<content:encoded><![CDATA[<p>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.<br />
The comment should state, at least code comments, why something is done not what it is done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jgauffin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57659</link>
		<dc:creator>jgauffin</dc:creator>
		<pubDate>Wed, 09 Jun 2010 11:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57659</guid>
		<description>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#039;t :)

I rather see documentation as a tool to write better code. And now I&#039;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.

I try to explain my point of view here:
http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</description>
		<content:encoded><![CDATA[<p>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#8217;t <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I rather see documentation as a tool to write better code. And now I&#8217;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.</p>
<p>I try to explain my point of view here:<br />
<a href="http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/" rel="nofollow">http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57221</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Mon, 17 May 2010 20:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57221</guid>
		<description>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#039;s name, which means your test and description/documentation always stay in sync. 

This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#039;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</description>
		<content:encoded><![CDATA[<p>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#8217;s name, which means your test and description/documentation always stay in sync. </p>
<p>This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#8217;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freddy rios</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57214</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Mon, 17 May 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57214</guid>
		<description>@Branko, you said:

&quot;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&quot;

Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#039;t easily/quickly understand what it is, it almost surely isn&#039;t good code. You say having the high-level comments all over the place serves as a &#039;shortcut&#039;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#039;t mean the situation wasn&#039;t created by a different problem, ignoring that perpetuates the issue.</description>
		<content:encoded><![CDATA[<p>@Branko, you said:</p>
<p>&#8220;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&#8221;</p>
<p>Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#8217;t easily/quickly understand what it is, it almost surely isn&#8217;t good code. You say having the high-level comments all over the place serves as a &#8216;shortcut&#8217;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#8217;t mean the situation wasn&#8217;t created by a different problem, ignoring that perpetuates the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Branko Dimitrijevic</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57115</link>
		<dc:creator>Branko Dimitrijevic</dc:creator>
		<pubDate>Thu, 13 May 2010 21:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57115</guid>
		<description>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc... and these are just &quot;physical&quot; levels - there may be many domain-specific &quot;logical&quot; paradigms with no direct analog in the programming language/technology.

While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.

The rules of thumb for good comments are:

  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.
  2. The comment is usually written BEFORE code.



Here are some examples:

  - Commenting the API is absolute must - the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.
  - Everything is &quot;API&quot;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#039;m not currently working on. Having high-level comments all over the place serves as a &quot;shortcut&quot; for understanding the code I now no longer need to read.
  - Commenting intention - as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.
  - Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &quot;shape&quot; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.
  - Commenting dependencies - a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &quot;environmental forces&quot; change.
  - Commenting on a choice of algorithm or data structure - there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &quot;incorrect&quot; - they all produce correct end result - by there are time/space/scalability tradeoffs to consider and the &quot;correct&quot; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.
  - Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &quot;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&quot;; at the end I settled for simple (but imprecise) &quot;CleanupSession()&quot; with appropriate comment.



Let me disagree with some of the specific points you make:

  - &quot;They do not change with the code.&quot; - Nor the other way around. I often find myself editing the comment simply to &quot;debug&quot; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.
  - &quot;A wrong comment is worse than horribly complex non-commented code.&quot; - True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &quot;comment consistency&quot; is useful technique for &quot;paradigm debugging&quot; in your head.
  - &quot;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&quot; - Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.
 - &quot;Comments don’t show up in stack traces.&quot; - No, they are one click away.
 - &quot;Reading comments is optional.&quot; - Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</description>
		<content:encoded><![CDATA[<p>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc&#8230; and these are just &#8220;physical&#8221; levels &#8211; there may be many domain-specific &#8220;logical&#8221; paradigms with no direct analog in the programming language/technology.</p>
<p>While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.</p>
<p>The rules of thumb for good comments are:</p>
<p>  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.<br />
  2. The comment is usually written BEFORE code.</p>
<p>Here are some examples:</p>
<p>  &#8211; Commenting the API is absolute must &#8211; the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.<br />
  &#8211; Everything is &#8220;API&#8221;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#8217;m not currently working on. Having high-level comments all over the place serves as a &#8220;shortcut&#8221; for understanding the code I now no longer need to read.<br />
  &#8211; Commenting intention &#8211; as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.<br />
  &#8211; Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &#8220;shape&#8221; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.<br />
  &#8211; Commenting dependencies &#8211; a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &#8220;environmental forces&#8221; change.<br />
  &#8211; Commenting on a choice of algorithm or data structure &#8211; there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &#8220;incorrect&#8221; &#8211; they all produce correct end result &#8211; by there are time/space/scalability tradeoffs to consider and the &#8220;correct&#8221; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.<br />
  &#8211; Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &#8220;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&#8221;; at the end I settled for simple (but imprecise) &#8220;CleanupSession()&#8221; with appropriate comment.</p>
<p>Let me disagree with some of the specific points you make:</p>
<p>  &#8211; &#8220;They do not change with the code.&#8221; &#8211; Nor the other way around. I often find myself editing the comment simply to &#8220;debug&#8221; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.<br />
  &#8211; &#8220;A wrong comment is worse than horribly complex non-commented code.&#8221; &#8211; True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &#8220;comment consistency&#8221; is useful technique for &#8220;paradigm debugging&#8221; in your head.<br />
  &#8211; &#8220;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&#8221; &#8211; Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.<br />
 &#8211; &#8220;Comments don’t show up in stack traces.&#8221; &#8211; No, they are one click away.<br />
 &#8211; &#8220;Reading comments is optional.&#8221; &#8211; Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57046</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57046</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 

If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: </p>
<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57115</link>
		<dc:creator>Branko Dimitrijevic</dc:creator>
		<pubDate>Thu, 13 May 2010 21:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57115</guid>
		<description>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc... and these are just &quot;physical&quot; levels - there may be many domain-specific &quot;logical&quot; paradigms with no direct analog in the programming language/technology.

While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.

The rules of thumb for good comments are:

  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.
  2. The comment is usually written BEFORE code.



Here are some examples:

  - Commenting the API is absolute must - the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.
  - Everything is &quot;API&quot;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#039;m not currently working on. Having high-level comments all over the place serves as a &quot;shortcut&quot; for understanding the code I now no longer need to read.
  - Commenting intention - as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.
  - Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &quot;shape&quot; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.
  - Commenting dependencies - a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &quot;environmental forces&quot; change.
  - Commenting on a choice of algorithm or data structure - there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &quot;incorrect&quot; - they all produce correct end result - by there are time/space/scalability tradeoffs to consider and the &quot;correct&quot; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.
  - Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &quot;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&quot;; at the end I settled for simple (but imprecise) &quot;CleanupSession()&quot; with appropriate comment.



Let me disagree with some of the specific points you make:

  - &quot;They do not change with the code.&quot; - Nor the other way around. I often find myself editing the comment simply to &quot;debug&quot; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.
  - &quot;A wrong comment is worse than horribly complex non-commented code.&quot; - True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &quot;comment consistency&quot; is useful technique for &quot;paradigm debugging&quot; in your head.
  - &quot;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&quot; - Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.
 - &quot;Comments don’t show up in stack traces.&quot; - No, they are one click away.
 - &quot;Reading comments is optional.&quot; - Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</description>
		<content:encoded><![CDATA[<p>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc&#8230; and these are just &#8220;physical&#8221; levels &#8211; there may be many domain-specific &#8220;logical&#8221; paradigms with no direct analog in the programming language/technology.</p>
<p>While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.</p>
<p>The rules of thumb for good comments are:</p>
<p>  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.<br />
  2. The comment is usually written BEFORE code.</p>
<p>Here are some examples:</p>
<p>  &#8211; Commenting the API is absolute must &#8211; the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.<br />
  &#8211; Everything is &#8220;API&#8221;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#8217;m not currently working on. Having high-level comments all over the place serves as a &#8220;shortcut&#8221; for understanding the code I now no longer need to read.<br />
  &#8211; Commenting intention &#8211; as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.<br />
  &#8211; Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &#8220;shape&#8221; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.<br />
  &#8211; Commenting dependencies &#8211; a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &#8220;environmental forces&#8221; change.<br />
  &#8211; Commenting on a choice of algorithm or data structure &#8211; there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &#8220;incorrect&#8221; &#8211; they all produce correct end result &#8211; by there are time/space/scalability tradeoffs to consider and the &#8220;correct&#8221; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.<br />
  &#8211; Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &#8220;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&#8221;; at the end I settled for simple (but imprecise) &#8220;CleanupSession()&#8221; with appropriate comment.</p>
<p>Let me disagree with some of the specific points you make:</p>
<p>  &#8211; &#8220;They do not change with the code.&#8221; &#8211; Nor the other way around. I often find myself editing the comment simply to &#8220;debug&#8221; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.<br />
  &#8211; &#8220;A wrong comment is worse than horribly complex non-commented code.&#8221; &#8211; True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &#8220;comment consistency&#8221; is useful technique for &#8220;paradigm debugging&#8221; in your head.<br />
  &#8211; &#8220;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&#8221; &#8211; Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.<br />
 &#8211; &#8220;Comments don’t show up in stack traces.&#8221; &#8211; No, they are one click away.<br />
 &#8211; &#8220;Reading comments is optional.&#8221; &#8211; Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comments on: Eliminating Comments: the Road to Clarity</title>
	<atom:link href="http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eliminating-comments-the-road-to-clarity</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: BDKR</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-64454</link>
		<dc:creator>BDKR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 15:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-64454</guid>
		<description>What about the fact that there is some code that functions exactly as wished but doesn&#039;t really lend itself to self documentation? 

And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</description>
		<content:encoded><![CDATA[<p>What about the fact that there is some code that functions exactly as wished but doesn&#8217;t really lend itself to self documentation? </p>
<p>And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63841</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 19 May 2011 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63841</guid>
		<description> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.

I can reverse engineer your code but I can&#039;t reverse engineer your thoughts.

 If you are too lazy to update your comments when you update your code thats one thing. Just don&#039;t encourage others to do it.</description>
		<content:encoded><![CDATA[<p> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.</p>
<p>I can reverse engineer your code but I can&#8217;t reverse engineer your thoughts.</p>
<p> If you are too lazy to update your comments when you update your code thats one thing. Just don&#8217;t encourage others to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63831</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 May 2011 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63831</guid>
		<description> 
If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</description>
		<content:encoded><![CDATA[<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: florin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57909</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 16:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57909</guid>
		<description>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.
The comment should state, at least code comments, why something is done not what it is done.</description>
		<content:encoded><![CDATA[<p>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.<br />
The comment should state, at least code comments, why something is done not what it is done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jgauffin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57659</link>
		<dc:creator>jgauffin</dc:creator>
		<pubDate>Wed, 09 Jun 2010 11:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57659</guid>
		<description>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#039;t :)

I rather see documentation as a tool to write better code. And now I&#039;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.

I try to explain my point of view here:
http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</description>
		<content:encoded><![CDATA[<p>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#8217;t <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I rather see documentation as a tool to write better code. And now I&#8217;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.</p>
<p>I try to explain my point of view here:<br />
<a href="http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/" rel="nofollow">http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57221</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Mon, 17 May 2010 20:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57221</guid>
		<description>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#039;s name, which means your test and description/documentation always stay in sync. 

This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#039;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</description>
		<content:encoded><![CDATA[<p>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#8217;s name, which means your test and description/documentation always stay in sync. </p>
<p>This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#8217;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freddy rios</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57214</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Mon, 17 May 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57214</guid>
		<description>@Branko, you said:

&quot;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&quot;

Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#039;t easily/quickly understand what it is, it almost surely isn&#039;t good code. You say having the high-level comments all over the place serves as a &#039;shortcut&#039;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#039;t mean the situation wasn&#039;t created by a different problem, ignoring that perpetuates the issue.</description>
		<content:encoded><![CDATA[<p>@Branko, you said:</p>
<p>&#8220;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&#8221;</p>
<p>Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#8217;t easily/quickly understand what it is, it almost surely isn&#8217;t good code. You say having the high-level comments all over the place serves as a &#8216;shortcut&#8217;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#8217;t mean the situation wasn&#8217;t created by a different problem, ignoring that perpetuates the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Branko Dimitrijevic</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57115</link>
		<dc:creator>Branko Dimitrijevic</dc:creator>
		<pubDate>Thu, 13 May 2010 21:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57115</guid>
		<description>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc... and these are just &quot;physical&quot; levels - there may be many domain-specific &quot;logical&quot; paradigms with no direct analog in the programming language/technology.

While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.

The rules of thumb for good comments are:

  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.
  2. The comment is usually written BEFORE code.



Here are some examples:

  - Commenting the API is absolute must - the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.
  - Everything is &quot;API&quot;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#039;m not currently working on. Having high-level comments all over the place serves as a &quot;shortcut&quot; for understanding the code I now no longer need to read.
  - Commenting intention - as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.
  - Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &quot;shape&quot; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.
  - Commenting dependencies - a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &quot;environmental forces&quot; change.
  - Commenting on a choice of algorithm or data structure - there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &quot;incorrect&quot; - they all produce correct end result - by there are time/space/scalability tradeoffs to consider and the &quot;correct&quot; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.
  - Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &quot;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&quot;; at the end I settled for simple (but imprecise) &quot;CleanupSession()&quot; with appropriate comment.



Let me disagree with some of the specific points you make:

  - &quot;They do not change with the code.&quot; - Nor the other way around. I often find myself editing the comment simply to &quot;debug&quot; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.
  - &quot;A wrong comment is worse than horribly complex non-commented code.&quot; - True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &quot;comment consistency&quot; is useful technique for &quot;paradigm debugging&quot; in your head.
  - &quot;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&quot; - Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.
 - &quot;Comments don’t show up in stack traces.&quot; - No, they are one click away.
 - &quot;Reading comments is optional.&quot; - Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</description>
		<content:encoded><![CDATA[<p>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc&#8230; and these are just &#8220;physical&#8221; levels &#8211; there may be many domain-specific &#8220;logical&#8221; paradigms with no direct analog in the programming language/technology.</p>
<p>While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.</p>
<p>The rules of thumb for good comments are:</p>
<p>  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.<br />
  2. The comment is usually written BEFORE code.</p>
<p>Here are some examples:</p>
<p>  &#8211; Commenting the API is absolute must &#8211; the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.<br />
  &#8211; Everything is &#8220;API&#8221;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#8217;m not currently working on. Having high-level comments all over the place serves as a &#8220;shortcut&#8221; for understanding the code I now no longer need to read.<br />
  &#8211; Commenting intention &#8211; as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.<br />
  &#8211; Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &#8220;shape&#8221; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.<br />
  &#8211; Commenting dependencies &#8211; a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &#8220;environmental forces&#8221; change.<br />
  &#8211; Commenting on a choice of algorithm or data structure &#8211; there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &#8220;incorrect&#8221; &#8211; they all produce correct end result &#8211; by there are time/space/scalability tradeoffs to consider and the &#8220;correct&#8221; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.<br />
  &#8211; Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &#8220;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&#8221;; at the end I settled for simple (but imprecise) &#8220;CleanupSession()&#8221; with appropriate comment.</p>
<p>Let me disagree with some of the specific points you make:</p>
<p>  &#8211; &#8220;They do not change with the code.&#8221; &#8211; Nor the other way around. I often find myself editing the comment simply to &#8220;debug&#8221; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.<br />
  &#8211; &#8220;A wrong comment is worse than horribly complex non-commented code.&#8221; &#8211; True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &#8220;comment consistency&#8221; is useful technique for &#8220;paradigm debugging&#8221; in your head.<br />
  &#8211; &#8220;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&#8221; &#8211; Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.<br />
 &#8211; &#8220;Comments don’t show up in stack traces.&#8221; &#8211; No, they are one click away.<br />
 &#8211; &#8220;Reading comments is optional.&#8221; &#8211; Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57046</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57046</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 

If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: </p>
<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57046</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57046</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 

If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: </p>
<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comments on: Eliminating Comments: the Road to Clarity</title>
	<atom:link href="http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=eliminating-comments-the-road-to-clarity</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 09:13:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: BDKR</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-64454</link>
		<dc:creator>BDKR</dc:creator>
		<pubDate>Tue, 29 Nov 2011 15:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-64454</guid>
		<description>What about the fact that there is some code that functions exactly as wished but doesn&#039;t really lend itself to self documentation? 

And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</description>
		<content:encoded><![CDATA[<p>What about the fact that there is some code that functions exactly as wished but doesn&#8217;t really lend itself to self documentation? </p>
<p>And in my experience, the vigorous application of this logic begins to feel like the dark side of hungarian notation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63841</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Thu, 19 May 2011 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63841</guid>
		<description> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.

I can reverse engineer your code but I can&#039;t reverse engineer your thoughts.

 If you are too lazy to update your comments when you update your code thats one thing. Just don&#039;t encourage others to do it.</description>
		<content:encoded><![CDATA[<p> Um, no. Comment your code please. I small comment giving me insight to what you were thinking is worth a whole lot.</p>
<p>I can reverse engineer your code but I can&#8217;t reverse engineer your thoughts.</p>
<p> If you are too lazy to update your comments when you update your code thats one thing. Just don&#8217;t encourage others to do it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-63831</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 11 May 2011 07:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-63831</guid>
		<description> 
If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</description>
		<content:encoded><![CDATA[<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: florin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57909</link>
		<dc:creator>florin</dc:creator>
		<pubDate>Wed, 30 Jun 2010 16:30:55 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57909</guid>
		<description>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.
The comment should state, at least code comments, why something is done not what it is done.</description>
		<content:encoded><![CDATA[<p>Comments are not bad at all, they are just wrongly used. Because they are consider of lower importance with regards to code.<br />
The comment should state, at least code comments, why something is done not what it is done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jgauffin</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57659</link>
		<dc:creator>jgauffin</dc:creator>
		<pubDate>Wed, 09 Jun 2010 11:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57659</guid>
		<description>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#039;t :)

I rather see documentation as a tool to write better code. And now I&#039;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.

I try to explain my point of view here:
http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</description>
		<content:encoded><![CDATA[<p>imho, your blog post takes for granted that everyone writes well structured and self-explainable code. In my experience, people don&#8217;t <img src='http://elegantcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I rather see documentation as a tool to write better code. And now I&#8217;m not talking about writing comments inside methods, but commenting projects, classes/interfaces and properties/methods: XML style comments.</p>
<p>I try to explain my point of view here:<br />
<a href="http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/" rel="nofollow">http://blog.gauffin.com/2010/06/my-name-is-more-docu-more/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Renso</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-6/#comment-57221</link>
		<dc:creator>Renso</dc:creator>
		<pubDate>Mon, 17 May 2010 20:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57221</guid>
		<description>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#039;s name, which means your test and description/documentation always stay in sync. 

This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#039;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</description>
		<content:encoded><![CDATA[<p>Your code should not contain comments. Your TDD/BDD style unit tests should tell the story. If the unit test name is descriptive it would be easy to understand what the code is doing without even looking inside the unit test itself. if your unit tests are grouped correctly, just reading the method names of the tests should provide an overview of what the code section is doing. best of all, if your code changes, your tests should fail (TDD approach) and you need to fix them, including changing the test&#8217;s name, which means your test and description/documentation always stay in sync. </p>
<p>This of course is in the perfect world of TDD, I do find myself commenting code when I need to fix something quickly and don&#8217;t have time to write or update a unit test, not ideal. I started off writing comments in pseudo code style comments as a way to organize my thoughts, you should use your Unit Test Class to do this in TDD style and not in the code. The only reasonable explanation for commenting a piece of code is when it needs work; i.e. better design, and to reflect that in the comment so that another developer knows when they see it that it needs better design, keeping in mind unit tests already exists for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: freddy rios</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57214</link>
		<dc:creator>freddy rios</dc:creator>
		<pubDate>Mon, 17 May 2010 15:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57214</guid>
		<description>@Branko, you said:

&quot;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&quot;

Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#039;t easily/quickly understand what it is, it almost surely isn&#039;t good code. You say having the high-level comments all over the place serves as a &#039;shortcut&#039;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#039;t mean the situation wasn&#039;t created by a different problem, ignoring that perpetuates the issue.</description>
		<content:encoded><![CDATA[<p>@Branko, you said:</p>
<p>&#8220;Everything is “API”, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I’m not currently working on. Having high-level comments all over the place serves as a “shortcut” for understanding the code I now no longer need to read.&#8221;</p>
<p>Its ok not knowing and/or remembering the details of complex software. But if you open any given code file in such software, and you can&#8217;t easily/quickly understand what it is, it almost surely isn&#8217;t good code. You say having the high-level comments all over the place serves as a &#8216;shortcut&#8217;, but its usually there for the inability to use a better design. ps. I know sometimes we just have to deal with such code, but that doesn&#8217;t mean the situation wasn&#8217;t created by a different problem, ignoring that perpetuates the issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Branko Dimitrijevic</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57115</link>
		<dc:creator>Branko Dimitrijevic</dc:creator>
		<pubDate>Thu, 13 May 2010 21:59:54 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57115</guid>
		<description>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc... and these are just &quot;physical&quot; levels - there may be many domain-specific &quot;logical&quot; paradigms with no direct analog in the programming language/technology.

While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.

The rules of thumb for good comments are:

  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.
  2. The comment is usually written BEFORE code.



Here are some examples:

  - Commenting the API is absolute must - the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.
  - Everything is &quot;API&quot;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#039;m not currently working on. Having high-level comments all over the place serves as a &quot;shortcut&quot; for understanding the code I now no longer need to read.
  - Commenting intention - as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.
  - Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &quot;shape&quot; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.
  - Commenting dependencies - a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &quot;environmental forces&quot; change.
  - Commenting on a choice of algorithm or data structure - there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &quot;incorrect&quot; - they all produce correct end result - by there are time/space/scalability tradeoffs to consider and the &quot;correct&quot; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.
  - Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &quot;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&quot;; at the end I settled for simple (but imprecise) &quot;CleanupSession()&quot; with appropriate comment.



Let me disagree with some of the specific points you make:

  - &quot;They do not change with the code.&quot; - Nor the other way around. I often find myself editing the comment simply to &quot;debug&quot; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.
  - &quot;A wrong comment is worse than horribly complex non-commented code.&quot; - True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &quot;comment consistency&quot; is useful technique for &quot;paradigm debugging&quot; in your head.
  - &quot;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&quot; - Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.
 - &quot;Comments don’t show up in stack traces.&quot; - No, they are one click away.
 - &quot;Reading comments is optional.&quot; - Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</description>
		<content:encoded><![CDATA[<p>The non-trivial software product will have many levels of abstraction. At the lowest level there are the actual code statements, over that there are methods, then classes/interfaces, components/packages/assemblies/DLLs, layers, clients/servers/tiers etc&#8230; and these are just &#8220;physical&#8221; levels &#8211; there may be many domain-specific &#8220;logical&#8221; paradigms with no direct analog in the programming language/technology.</p>
<p>While I agree that commenting at the level of statements is usually superfluous (i.e. the code can usually express itself AT THAT PARTICULAR LEVEL OF ABSTRACTION), properly documenting all the other levels has great value for long-term maintainability of the product, which is where some forms of comments have their rightful place.</p>
<p>The rules of thumb for good comments are:</p>
<p>  1. The comment should be AT HIGHER LEVEL OF ABSTRACTION than can be expressed directly in code.<br />
  2. The comment is usually written BEFORE code.</p>
<p>Here are some examples:</p>
<p>  &#8211; Commenting the API is absolute must &#8211; the client will usually not have the access to the source code and not all of the pre/post-requisites for making a particular API call can be expressed through the language / communication technology chosen to implement the API. Typically, the best the API implementation code can do is throw an exception / error code, but by that time the high-level context for understanding the root cause of the problem may be lost.<br />
  &#8211; Everything is &#8220;API&#8221;, even if used by the same person/team. The software I usually work on is usually too complex to keep ALL the nitty-gritty details in my head. There is a great value in being able to FORGET the code that I&#8217;m not currently working on. Having high-level comments all over the place serves as a &#8220;shortcut&#8221; for understanding the code I now no longer need to read.<br />
  &#8211; Commenting intention &#8211; as code evolves, having a proper documentation on what is ESSENTIAL, versus what is INCIDENTAL lets me stick with essentials and break less clients as code evolves. In fact, well written comment will change LESS OFTEN than the implementation code.<br />
  &#8211; Commenting higher-level structures. Often, my data structure is a complex graph or tree of nodes, and needs to have a specific &#8220;shape&#8221; or certain things need to happen in certain sequence to have a proper behaviour. While assertions/contracts help, higher-level documentation is usually a must.<br />
  &#8211; Commenting dependencies &#8211; a product can depend on many pieces of code or even entire applications not written by me or my team. We are often forced to do certain things in a certain way simply by not existing in a vacuum. With proper documentation, it is easier to understand what changes need to be made in our code when the &#8220;environmental forces&#8221; change.<br />
  &#8211; Commenting on a choice of algorithm or data structure &#8211; there is often a situation when there are multiple choices of algorithms and/or data structures that can be used to solve a particular problem. Neither choice is &#8220;incorrect&#8221; &#8211; they all produce correct end result &#8211; by there are time/space/scalability tradeoffs to consider and the &#8220;correct&#8221; solution is the one that fits with the expected USAGE PATTERN best. Commenting what is the expected usage pattern and what are the performance tradeoffs chosen as a consequence can help tremendously in understanding performance bottlenecks when usage pattern changes.<br />
  &#8211; Comments can simply be LONGER than programming language names. Just the other day, I was tempted to make a method: &#8220;RemoveHandlesOfNotImplicitlyUnloadedModelsFromSession()&#8221;; at the end I settled for simple (but imprecise) &#8220;CleanupSession()&#8221; with appropriate comment.</p>
<p>Let me disagree with some of the specific points you make:</p>
<p>  &#8211; &#8220;They do not change with the code.&#8221; &#8211; Nor the other way around. I often find myself editing the comment simply to &#8220;debug&#8221; my thinking and change the code only AFTER the comment looks right. If you code first and comment later, then I can see your point.<br />
  &#8211; &#8220;A wrong comment is worse than horribly complex non-commented code.&#8221; &#8211; True, but a comment rarely exists in vacuum. If the rest of you product is documented properly, the bad comment will be obviously inconsistent with the rest of the documentation and easy to spot. Actually, achieving &#8220;comment consistency&#8221; is useful technique for &#8220;paradigm debugging&#8221; in your head.<br />
  &#8211; &#8220;A comment almost always expresses an absolute thing, where a well named variable or method can express an abstract concept.&#8221; &#8211; Actually, my experience is the opposite. Good comments are always at the higher level of abstraction than the code.<br />
 &#8211; &#8220;Comments don’t show up in stack traces.&#8221; &#8211; No, they are one click away.<br />
 &#8211; &#8220;Reading comments is optional.&#8221; &#8211; Well, the basic OOP principle of encapsulation tells us that reading implementation code is optional as well. Without comments, what you are left with is reading names/signatures of classes/methods/parameters and that alone is often simply not expressive enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57046</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:33:39 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57046</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 

If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say -Comments are bad- in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: </p>
<p>If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/comment-page-5/#comment-57045</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Wed, 12 May 2010 15:31:14 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2010/04/18/eliminating-comments-the-road-to-clarity/#comment-57045</guid>
		<description>Love this article - I have long promoted this. I even went so far as to say &quot;Comments are bad&quot; in a session only to have to get into a huge debate on it.

Method names also need to be descriptive - it&#039;s all about the name.

Comments do have their place - but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said: 
&quot;If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.&quot;

That&#039;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</description>
		<content:encoded><![CDATA[<p>Love this article &#8211; I have long promoted this. I even went so far as to say &#8220;Comments are bad&#8221; in a session only to have to get into a huge debate on it.</p>
<p>Method names also need to be descriptive &#8211; it&#8217;s all about the name.</p>
<p>Comments do have their place &#8211; but most comments can be left inside Source control systems and spec documents. That said, I like what Shazbot said:<br />
&#8220;If you really need comments then they should be put within the comment blocks that show on the intelisense within your VS IDE.&#8221;</p>
<p>That&#8217;s why I added a rule into my refactoring tool to say any code where the comments are 1/3 the size of the code, needs to be refactored immediately.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

