<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Matt Manela's Blog : Random Thoughts</title><link>http://blogs.msdn.com/matt/archive/tags/Random+Thoughts/default.aspx</link><description>Tags: Random Thoughts</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Self Documenting Code</title><link>http://blogs.msdn.com/matt/archive/2007/10/09/self-documenting-code.aspx</link><pubDate>Wed, 10 Oct 2007 03:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5387019</guid><dc:creator>MattManela</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/matt/comments/5387019.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=5387019</wfw:commentRss><description>&lt;p&gt;&lt;font size="2"&gt;I have come across many developers who believe that comments are not necessary to make code readable.&amp;nbsp; They argue that code should document itself.&amp;nbsp; By this they mean that the code you write should be clear and have good enough naming conventions such that you don't need to add extra comments to make it understandable.&amp;nbsp; They say that if you feel you need to write a comment then you should rewrite the code to be more clear.&lt;/font&gt;&lt;/p&gt; &lt;p mce_keep="true"&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;I agree that any code you write should be as clear and well named as possible.&amp;nbsp; Comments do NOT make bad code readable. However, I do not agree that clean well written code is sufficient documentation in itself.&amp;nbsp; I am not talking about simple comments like:&lt;/font&gt;&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;font size="2"&gt;&lt;span class="rem"&gt;/*this calls a function which calculates &lt;br&gt;the nth fibinocci number */&lt;/span&gt;
&lt;span class="kwrd"&gt;int&lt;/span&gt; fibNum = calculateFibinocciNumber(5);
&lt;/font&gt;&lt;/pre&gt;
&lt;p&gt;&lt;font size="2"&gt;or even funnier is:&amp;nbsp; ... And I have done this in the past :)&lt;/font&gt;&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;font size="2"&gt;&lt;span class="rem"&gt;//the owners first name&lt;/span&gt;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; ownersFirstName;&lt;/font&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p mce_keep="true"&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Those comments are useless since they are just repeating what the code clearly states. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Where you really need descriptive comments are situations such as&amp;nbsp; complex algorithms that the best code in the world still wouldn't make clear how it works.&amp;nbsp; Or when a function is using many different objects.&amp;nbsp; While you could understand what this block does after hours of tracing through all the other functions and classes of the objects it uses, it would be much more convenient to have a simple paragraph give you an overview of what it does and how it uses other those objects.&lt;/font&gt;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Another argument against the use of comments I hear is that they don't get updated when the code does.&amp;nbsp;&amp;nbsp; This is a problem but this is the burden of the programmer to always update the comments.&amp;nbsp; Keeping your code clean and your comments in synch with your code is part of a programmers job.&lt;/font&gt;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;I believe any developer who is thrown in to a large code base will agree with me on this. &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;So my fellow developers PLEASE both write clean code AND write relevant descriptive comments.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5387019" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/matt/archive/tags/Programming/default.aspx">Programming</category><category domain="http://blogs.msdn.com/matt/archive/tags/Random+Thoughts/default.aspx">Random Thoughts</category></item><item><title>Things I have learnt about Seattle...</title><link>http://blogs.msdn.com/matt/archive/2007/08/21/things-i-have-learnt-about-seattle.aspx</link><pubDate>Wed, 22 Aug 2007 08:20:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4504965</guid><dc:creator>MattManela</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/matt/comments/4504965.aspx</comments><wfw:commentRss>http://blogs.msdn.com/matt/commentrss.aspx?PostID=4504965</wfw:commentRss><description>&lt;p&gt;At the beginning of August I moved out to Seattle from New York&amp;nbsp;and since then I have learned some things about this city:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;strong&gt;People in Seattle dislike Starbucks but are inexorably drawn to constantly go there.&lt;/strong&gt;&amp;nbsp; Everyone complains how Starbucks sold out and how there is better coffee at other local Seattle coffee shops but they all still go to Starbucks religiously.&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Traffic in Seattle is worse than all of New York city EXCEPT for Manhattan.&lt;/strong&gt;&amp;nbsp; Traffic here is pretty bad (520? 405?)&amp;nbsp;and beats in my opinion the four other boroughs of&amp;nbsp;New York&amp;nbsp;in severity but nothing compares to the parking lot that is Manhattan.&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Homeless in Seattle&amp;nbsp;get up very early and stay out very late.&lt;/strong&gt;&amp;nbsp; Anyone who travels in Seattle will notice the flocks of homeless people.&amp;nbsp; I feel bad for them but I must appreciate the long hours they work.&amp;nbsp; I have seen the same person at 6:30am and at 9pm in one day.&lt;/li&gt; &lt;li&gt;&lt;strong&gt;The Seattle bus drivers are the nicest people in the world.&lt;/strong&gt;&amp;nbsp; Maybe I am biased coming from New York where most of the bus drivers would ignore you if you did talk to them but the bus drivers in Seattle are extremely nice.&amp;nbsp; They will help you with anything and seem genuinely concerned that get to where you are going.&amp;nbsp; I had a bus driver ask everyone if they were sure that they didn't want to get off at a certain stop.&amp;nbsp; That shocked me.&amp;nbsp; A bus driving making sure no one forget to see if this was there stop.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;That is all for now.&amp;nbsp; I will add more as I learn them.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4504965" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/matt/archive/tags/Personal/default.aspx">Personal</category><category domain="http://blogs.msdn.com/matt/archive/tags/Random+Thoughts/default.aspx">Random Thoughts</category></item></channel></rss>