<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JAPF &#187; stylecop</title>
	<atom:link href="http://www.japf.fr/tag/stylecop/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.japf.fr</link>
	<description>Jeremy Alles Presentation Foundation: WPF, .Net and modern software development</description>
	<lastBuildDate>Thu, 29 Jul 2010 07:29:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Microsoft StyleCop vs Agility</title>
		<link>http://www.japf.fr/2008/11/microsoft-stylecop-vs-agility/</link>
		<comments>http://www.japf.fr/2008/11/microsoft-stylecop-vs-agility/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 21:53:00 +0000</pubDate>
		<dc:creator>Jeremy</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[agility]]></category>
		<category><![CDATA[practises]]></category>
		<category><![CDATA[stylecop]]></category>

		<guid isPermaLink="false">http://www.japf.fr/?p=53</guid>
		<description><![CDATA[When I write code, I try to keep it as clean as possible by following rules that I define and use in all my project. Those rules can be the ordering of elements within a class, or the way I choose name for my properties and methods&#8230; Microsoft created a tool that analyzes C# source [...]]]></description>
			<content:encoded><![CDATA[<p>When I write code, I try to keep it as clean as possible by following <em>rules </em>that I define and use in all my project. Those <em>rules</em> can be the ordering of elements within a class, or the way I choose name for my properties and methods&#8230;</p>
<p>Microsoft created a tool that <span id="ctl00_ctl00_Content_TabContentPanel_Content_wikiSourceLabel">analyzes C# source code in order to enforce a set of style and consistency rules : it&#8217;s <a href="http://code.msdn.microsoft.com/sourceanalysis">StyleCop</a> (available for free to download). StyleCop defines a lot of rules, for example:</span></p>
<ul>
<li>Element must begin with an upper case letter</li>
<li>Field name must begin with a lower case letter</li>
<li>Prefix local calls with the &#8220;this&#8221; prefix</li>
</ul>
<p>It is possible to enable or disable each rules separately, and this is what most users will do. Running StyleCop on one of your project can lead to thousands of warning. You can then choose which rules you want to keep enabled.</p>
<p>I started to use StyleCop the project I&#8217;m working on at job about one week ago. After disabling some of the rules I didn&#8217;t wanted to fix yet, I found a rules that was giving me a lot of warnings:</p>
<ul>
<li>ALL elements must be documented</li>
</ul>
<p>Hmm&#8230; This means that each single method or properties in my project must have a documentation&#8230; Well, if documentation is good lets start writing documentation everywhere. I though I will take a couple of classes per day, and write the entire documentation. I started with opening one of my class, and found this method:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p53code3'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p533"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p53code3"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> OpenDocument<span style="color: #008000;">&#40;</span>IDocument document<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
<span style="color: #008080; font-style: italic;">// ...</span>
&nbsp;
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>StyleCop wasn&#8217;t happy because there wasn&#8217;t any documentation, so I wrote one:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p53code4'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p534"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p53code4"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// Open a document</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;document&quot;&gt;IDocument to open&lt;param&gt;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> OpenDocument<span style="color: #008000;">&#40;</span>IDocument document<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
<span style="color: #008080; font-style: italic;">// ...</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Then, I don&#8217;t know why but I asked myself &#8220;what the hell this documentation is going to help the user of the class ???&#8221;. Because one month earlier I went to the <a href="http://www.agiletour.com/">AgileTour</a> (a french event about Agile methods), I remembered the <em>Agile Manifesto</em>:</p>
<ul>
<li>Individuals and interactions <em>over </em>processes and tools</li>
<li>Working software <em>over </em><strong>comprehensive documentation</strong></li>
<li>Customer collaboration <em>over </em>contract negotiation</li>
<li>Responding to change <em>over </em>following a plan</li>
</ul>
<p>I was thinking a couple of minutes, and then I decided to remove the StyleCop rules about documenting EVERYTHING in my code. I think that would be a waste of time and that would preventing me to put good comments where it&#8217;s really needed such explaning an algorithm or why I choose this way over this other way to do the job.</p>
<p>I&#8217;m still using StyleCop to have a set of rules about the style of my code. But for now, that&#8217;s it ! I think it is very important to make the differenciation between documentation and comments. If documentation is needed because it will generate a document outside the application then it might be usefull. But if the documentation is written just to have it, I prefer forget about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.japf.fr/2008/11/microsoft-stylecop-vs-agility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
