<?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: The Commented Version Of The Readable Code Challenge</title> <atom:link href="http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/feed/" rel="self" type="application/rss+xml" /><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/</link> <description>inquisitive: adjective. given to inquiry, research, or asking questions; eager for knowledge; intellectually curious</description> <lastBuildDate>Sun, 20 May 2012 21:55:00 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: timvw</title><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/comment-page-1/#comment-55617</link> <dc:creator>timvw</dc:creator> <pubDate>Tue, 24 Aug 2010 11:52:18 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=983#comment-55617</guid> <description>I stand corrected.I think this prooves that having a set of decent tests is gold.
Comments explaining the potential issues are silver.</description> <content:encoded><![CDATA[<p>I stand corrected.</p><p>I think this prooves that having a set of decent tests is gold.<br
/> Comments explaining the potential issues are silver.</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/comment-page-1/#comment-54864</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Thu, 19 Aug 2010 16:05:56 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=983#comment-54864</guid> <description>@Timvit&#039;s not an issue with lazy evaluation of an enumerablewith your suggested approach, you could still run into threading issues during the executing of the list.ToArray() callunless you lock around all writes, as well as around the creation of the array</description> <content:encoded><![CDATA[<p>@Timv</p><p>it&#8217;s not an issue with lazy evaluation of an enumerable</p><p>with your suggested approach, you could still run into threading issues during the executing of the list.ToArray() call</p><p>unless you lock around all writes, as well as around the creation of the array</p> ]]></content:encoded> </item> <item><title>By: timvw</title><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/comment-page-1/#comment-54776</link> <dc:creator>timvw</dc:creator> <pubDate>Thu, 19 Aug 2010 07:11:52 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=983#comment-54776</guid> <description>- Admitted, currently the intent is only clear when you have the comments around...- If you rewrite the code as below, i think the comments (and the newing up of the clienlist) are not needed anymore,
because the issue with &#039;lazy evaluation&#039; of an enumeration should be more or less obvious:// ignore changes to the underlying source while enumerating
foreach (var  client in clients.AsImmutable())
{
client.SendNotificationAsynchronously(notification);
}public static IEnumerable AsImmutable(this List list)
{
return list.ToArray();
}</description> <content:encoded><![CDATA[<p>- Admitted, currently the intent is only clear when you have the comments around&#8230;</p><p>- If you rewrite the code as below, i think the comments (and the newing up of the clienlist) are not needed anymore,<br
/> because the issue with &#8216;lazy evaluation&#8217; of an enumeration should be more or less obvious:</p><p>// ignore changes to the underlying source while enumerating<br
/> foreach (var  client in clients.AsImmutable())<br
/> {<br
/> client.SendNotificationAsynchronously(notification);<br
/> }</p><p>public static IEnumerable AsImmutable(this List list)<br
/> {<br
/> return list.ToArray();<br
/> }</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/comment-page-1/#comment-9113</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Tue, 24 Feb 2009 05:57:38 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=983#comment-9113</guid> <description>@Jeremywell, as far as this piece of code is concerned, the &#039;series&#039; is pretty much over... i think i&#039;ve already milked it for all it&#039;s worth ;)</description> <content:encoded><![CDATA[<p>@Jeremy</p><p>well, as far as this piece of code is concerned, the &#8216;series&#8217; is pretty much over&#8230; i think i&#8217;ve already milked it for all it&#8217;s worth <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Jeremy Gray</title><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/comment-page-1/#comment-9103</link> <dc:creator>Jeremy Gray</dc:creator> <pubDate>Mon, 23 Feb 2009 22:15:32 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=983#comment-9103</guid> <description>@Davy - Believe me, it happens. :DI suppose my background (and working environment) is a bit more ruthless than average when it comes to factoring code for understandability that avoids getting comment-happy. In many ways, I suppose I&#039;m more inclined to being ruthless in that manner to help counterbalance the comment-happiness that is prevalent in a lot of codebases. Codebases where comments are used to shore up crap code that itself could easily be made much clearer and avoid the risks of comments where possible (e.g. getting out of sync with the code, what have you.)To be clear: complicated code should be commented. But only once as many as possible of those comments have been refactored into the structure of the code itself (in the names of members, etc.) :)Keep up the great series of posts! I&#039;m really enjoying them so far.</description> <content:encoded><![CDATA[<p>@Davy &#8211; Believe me, it happens. <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p><p>I suppose my background (and working environment) is a bit more ruthless than average when it comes to factoring code for understandability that avoids getting comment-happy. In many ways, I suppose I&#8217;m more inclined to being ruthless in that manner to help counterbalance the comment-happiness that is prevalent in a lot of codebases. Codebases where comments are used to shore up crap code that itself could easily be made much clearer and avoid the risks of comments where possible (e.g. getting out of sync with the code, what have you.)</p><p>To be clear: complicated code should be commented. But only once as many as possible of those comments have been refactored into the structure of the code itself (in the names of members, etc.) <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>Keep up the great series of posts! I&#8217;m really enjoying them so far.</p> ]]></content:encoded> </item> <item><title>By: Laila</title><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/comment-page-1/#comment-9060</link> <dc:creator>Laila</dc:creator> <pubDate>Sun, 22 Feb 2009 21:57:45 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=983#comment-9060</guid> <description>If you decide to leave in comments, I&#039;d really try to shorten them up, and that&#039;s very feasible in this example :) And why not put them as xml-remarks to the class or to variables as xml-summary?</description> <content:encoded><![CDATA[<p>If you decide to leave in comments, I&#8217;d really try to shorten them up, and that&#8217;s very feasible in this example <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> And why not put them as xml-remarks to the class or to variables as xml-summary?</p> ]]></content:encoded> </item> <item><title>By: Davy Brion</title><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/comment-page-1/#comment-9047</link> <dc:creator>Davy Brion</dc:creator> <pubDate>Sun, 22 Feb 2009 09:40:13 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=983#comment-9047</guid> <description>@Filipi&#039;ve followed your suggestion... renamed the monitor and gotten rid of the comments in the AddClientToRegisteredClients and RemoveClientFromRegisteredClients methods.  So now, i only have the comment block on top of the clients list field and the comments in the Broadcast method.  Kinda like the result, thx :)As for why i used copy-on-write instead of copy-on-read... i have no idea, this was just the first solution i thought of using. Haven&#039;t tried the copy-on-read yet, but it actually might make it more explicit as to what is going on.  You&#039;d have to put locking in all 3 &#039;tricky&#039; places (addition, removal, pre-looping) so to the reader, it might be more clear as to what is going on without requiring comments.@JeremyFor you, this code might have been entirely clear from the beginning, but i&#039;m pretty sure that that wasn&#039;t the case for most people who read it.  When i posted the original code, a lot of people were asking me for hints in the comments, at the office, on IM, email, etc...  So i think the commenting on the &#039;why&#039; does make sense in this example. Oh and i&#039;d hate to see code that you _don&#039;t_ find clear :P</description> <content:encoded><![CDATA[<p>@Filip</p><p>i&#8217;ve followed your suggestion&#8230; renamed the monitor and gotten rid of the comments in the AddClientToRegisteredClients and RemoveClientFromRegisteredClients methods.  So now, i only have the comment block on top of the clients list field and the comments in the Broadcast method.  Kinda like the result, thx <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>As for why i used copy-on-write instead of copy-on-read&#8230; i have no idea, this was just the first solution i thought of using. Haven&#8217;t tried the copy-on-read yet, but it actually might make it more explicit as to what is going on.  You&#8217;d have to put locking in all 3 &#8216;tricky&#8217; places (addition, removal, pre-looping) so to the reader, it might be more clear as to what is going on without requiring comments.</p><p>@Jeremy</p><p>For you, this code might have been entirely clear from the beginning, but i&#8217;m pretty sure that that wasn&#8217;t the case for most people who read it.  When i posted the original code, a lot of people were asking me for hints in the comments, at the office, on IM, email, etc&#8230;  So i think the commenting on the &#8216;why&#8217; does make sense in this example. Oh and i&#8217;d hate to see code that you _don&#8217;t_ find clear <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>By: Filip Duyck</title><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/comment-page-1/#comment-9042</link> <dc:creator>Filip Duyck</dc:creator> <pubDate>Sat, 21 Feb 2009 23:51:16 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=983#comment-9042</guid> <description>@TomC:
You would copy the list before iterating it. No concurrency problems if you lock during the copying, and no problems with changes to the list while iterating it, because changes are done to the original rather than to your copy.</description> <content:encoded><![CDATA[<p>@TomC:<br
/> You would copy the list before iterating it. No concurrency problems if you lock during the copying, and no problems with changes to the list while iterating it, because changes are done to the original rather than to your copy.</p> ]]></content:encoded> </item> <item><title>By: Jeremy Gray</title><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/comment-page-1/#comment-9033</link> <dc:creator>Jeremy Gray</dc:creator> <pubDate>Sat, 21 Feb 2009 19:52:40 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=983#comment-9033</guid> <description>When I read the code in your original post it was 100% clear what the code was up to and why. Unless your goal is to try to explain threading issues to a less-experienced developer via comments (which I would argue is a pretty bad way to teach someone ;) ) then the amount of comments you have here are just creating noise that make it harder to pay attention to the actual code. I wouldn&#039;t be surprised if this would result in a maintainer simply skimming the comments without stopping to gain an understanding of the code, which would help no one.My personal recommendation would be to save commenting like this for those rare-but-inevitable occasions where code has to do something very specific for a reason that is very obscure and strongly tied to something entirely outside the control of the developer, with your example not counting as such a situation given that it is a general solution to a common problem, not, for example, a seemingly-incorrect-but-in-reality-utterly-unavoidable work-around at a integration point with a problematice external system. In other words, you should never have to comment on who, what, when, or where, and should only comment on why when why _only_ makes sense in this _single_ situation and no other.</description> <content:encoded><![CDATA[<p>When I read the code in your original post it was 100% clear what the code was up to and why. Unless your goal is to try to explain threading issues to a less-experienced developer via comments (which I would argue is a pretty bad way to teach someone <img
src='http://d18sni7re4ly7f.cloudfront.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) then the amount of comments you have here are just creating noise that make it harder to pay attention to the actual code. I wouldn&#8217;t be surprised if this would result in a maintainer simply skimming the comments without stopping to gain an understanding of the code, which would help no one.</p><p>My personal recommendation would be to save commenting like this for those rare-but-inevitable occasions where code has to do something very specific for a reason that is very obscure and strongly tied to something entirely outside the control of the developer, with your example not counting as such a situation given that it is a general solution to a common problem, not, for example, a seemingly-incorrect-but-in-reality-utterly-unavoidable work-around at a integration point with a problematice external system. In other words, you should never have to comment on who, what, when, or where, and should only comment on why when why _only_ makes sense in this _single_ situation and no other.</p> ]]></content:encoded> </item> <item><title>By: Ayende Rahien</title><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/comment-page-1/#comment-9031</link> <dc:creator>Ayende Rahien</dc:creator> <pubDate>Sat, 21 Feb 2009 19:20:59 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=983#comment-9031</guid> <description>I would say that you have a lot more comments there than you need.</description> <content:encoded><![CDATA[<p>I would say that you have a lot more comments there than you need.</p> ]]></content:encoded> </item> <item><title>By: TomC</title><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/comment-page-1/#comment-9030</link> <dc:creator>TomC</dc:creator> <pubDate>Sat, 21 Feb 2009 19:18:20 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=983#comment-9030</guid> <description>@Filip Duyck:
How would a copy-on-read work? Doesn&#039;t a copy imply a read, so wouldn&#039;t it give you the concurrency problem described in the comments?I do agree on the fact that some parts of the comments are already obvious from the code itself.
They even remind me of Davy&#039;s post &lt;a href=&quot;http://davybrion.com/blog/2008/06/are-women-better-developers-than-men&quot; title=&quot;Are women better developers than men?&quot; rel=&quot;nofollow&quot;&gt;Are women better developers than men?&lt;/a&gt;, more specifically the part about the female &#039;roadmap-comments&#039; within code...</description> <content:encoded><![CDATA[<p>@Filip Duyck:<br
/> How would a copy-on-read work? Doesn&#8217;t a copy imply a read, so wouldn&#8217;t it give you the concurrency problem described in the comments?</p><p>I do agree on the fact that some parts of the comments are already obvious from the code itself.<br
/> They even remind me of Davy&#8217;s post <a
href="http://davybrion.com/blog/2008/06/are-women-better-developers-than-men" title="Are women better developers than men?" rel="nofollow">Are women better developers than men?</a>, more specifically the part about the female &#8216;roadmap-comments&#8217; within code&#8230;</p> ]]></content:encoded> </item> <item><title>By: Filip Duyck</title><link>http://davybrion.com/blog/2009/02/the-commented-version-of-the-readable-code-challeng/comment-page-1/#comment-9029</link> <dc:creator>Filip Duyck</dc:creator> <pubDate>Sat, 21 Feb 2009 18:18:13 +0000</pubDate> <guid
isPermaLink="false">http://davybrion.com/blog/?p=983#comment-9029</guid> <description>I get the feeling that most of your comments serve to explain the principle of a copy-on-write but they do a good job of explaining why you need this kind of pattern here. Others seem to make up for the poor naming of your &#039;monitor&#039; variable. If you rename it to &#039;clientsWriteLock&#039;, it will be obvious from the name and &#039;Find Usages&#039; result what is going on.The comments &quot;we create a new List instance based on the previous list plus the new client and then we assign the new list to the clients reference that the rest of this class uses&quot; and &quot;we create a new List instance based on the previous list minus the client that needs to be removed and then we assign the new list to the clients reference&quot; pretty much just states what is obvious from the code itself.One thing that deserves a comment but was left out is why you opted for a copy-on-write instead of a copy-on-read when broadcasting -- I assume it is for performance reasons?</description> <content:encoded><![CDATA[<p>I get the feeling that most of your comments serve to explain the principle of a copy-on-write but they do a good job of explaining why you need this kind of pattern here. Others seem to make up for the poor naming of your &#8216;monitor&#8217; variable. If you rename it to &#8216;clientsWriteLock&#8217;, it will be obvious from the name and &#8216;Find Usages&#8217; result what is going on.</p><p>The comments &#8220;we create a new List instance based on the previous list plus the new client and then we assign the new list to the clients reference that the rest of this class uses&#8221; and &#8220;we create a new List instance based on the previous list minus the client that needs to be removed and then we assign the new list to the clients reference&#8221; pretty much just states what is obvious from the code itself.</p><p>One thing that deserves a comment but was left out is why you opted for a copy-on-write instead of a copy-on-read when broadcasting &#8212; I assume it is for performance reasons?</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/16 queries in 0.011 seconds using disk: basic
Object Caching 532/533 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: d18sni7re4ly7f.cloudfront.net

Served from: davybrion.com @ 2012-05-22 11:00:07 -->
