<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.microsoft.co.il/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>Gil Fink&amp;#39;s Blog : Code Analysis</title><link>http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Code+Analysis/default.aspx</link><description>Tags: Code Analysis</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Why You have to use Coding Conventions</title><link>http://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/02/why-you-have-to-use-coding-conventions.aspx</link><pubDate>Sat, 02 May 2009 17:34:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:280494</guid><dc:creator>Gil Fink</dc:creator><slash:comments>1</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/gilf/commentapi.aspx?PostID=280494</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/02/why-you-have-to-use-coding-conventions.aspx#comments</comments><description>&lt;h1&gt;&lt;strong&gt;Why You have to use Coding Conventions&lt;/strong&gt;&lt;/h1&gt;
&lt;p&gt;Tomorrow I’m going to &lt;a href="http://blogs.microsoft.co.il/blogs/gilf/CodingStandards_63254E2A.jpg"&gt;&lt;img style="BORDER-BOTTOM:0px;BORDER-LEFT:0px;DISPLAY:inline;MARGIN-LEFT:0px;BORDER-TOP:0px;MARGIN-RIGHT:0px;BORDER-RIGHT:0px;" title="Coding Standards" border="0" alt="Coding Standards" align="right" src="http://blogs.microsoft.co.il/blogs/gilf/CodingStandards_thumb_58F6446E.jpg" width="300" height="230" /&gt;&lt;/a&gt; &lt;br /&gt;a client in order to help &lt;br /&gt;in constructing a &lt;strong&gt;coding &lt;br /&gt;conventions&lt;/strong&gt; document for &lt;br /&gt;their project. One question &lt;br /&gt;that I sometimes hear is why &lt;br /&gt;to use&lt;strong&gt; coding conventions&lt;/strong&gt; in &lt;br /&gt;projects? This post will try &lt;br /&gt;to answer the question.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;What are Coding Conventions?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Taken from Wikipedia – &lt;br /&gt;“&lt;b&gt;Coding conventions&lt;/b&gt; are &lt;br /&gt;a set of guidelines for a &lt;br /&gt;specific programming &lt;br /&gt;language that recommend &lt;br /&gt;programming style, practices and methods for each aspect of a piece &lt;br /&gt;program written in this language. These conventions usually cover &lt;br /&gt;file organization, indentation, comments, declarations, statements, &lt;br /&gt;white space, naming conventions, programming practices and etc.” &lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Why to use Coding Conventions?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;The main reasons to use &lt;strong&gt;coding conventions&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;u&gt;Comprehensible code&lt;/u&gt; – &lt;strong&gt;Coding conventions&lt;/strong&gt; enforce coding &lt;br /&gt;standards on the development teams and therefore makes &lt;br /&gt;the code comprehensible to read and understand.&lt;/li&gt;
&lt;li&gt;&lt;u&gt;Avoiding pitfalls&lt;/u&gt; – the &lt;strong&gt;coding conventions&lt;/strong&gt; dictate &lt;br /&gt;programming practices that can help to reduce pitfalls that &lt;br /&gt;someone else fell into in the past.&lt;/li&gt;
&lt;li&gt;&lt;u&gt;Help to spread knowledge easily&lt;/u&gt; – &lt;strong&gt;coding conventions&lt;/strong&gt; help to &lt;br /&gt;spread the ideas you write in your code more easily to other &lt;br /&gt;developers in the team.&lt;/li&gt;&lt;/ul&gt;
&lt;h3&gt;&lt;strong&gt;How to Enforce Coding Conventions?&lt;/strong&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;u&gt;Code Review Process&lt;/u&gt; – during &lt;strong&gt;code review&lt;/strong&gt; you can enforce &lt;br /&gt;the conventions of your company on the developers. &lt;/li&gt;
&lt;li&gt;&lt;u&gt;Code Conventions Tools&lt;/u&gt; – there are a lot of tools that can &lt;br /&gt;help you to integrate the &lt;strong&gt;coding conventions&lt;/strong&gt; into the &lt;br /&gt;development process. For example, you can use Microsoft &lt;a title="FxCop Site" href="http://code.msdn.microsoft.com/codeanalysis/Release/ProjectReleases.aspx?ReleaseId=553"&gt;FxCop&lt;/a&gt; &lt;br /&gt;to check conventions by creating rules for those conventions or &lt;br /&gt;You can use &lt;a title="Code Style Enforcer" href="http://joel.fjorden.se/static.php?page=CodeStyleEnforcer"&gt;Code Style Enforcer&lt;/a&gt; to checks the code against &lt;br /&gt;a configurable code standard and best practices. &lt;br /&gt;There are more tools out there that can help you to enforce &lt;br /&gt;&lt;strong&gt;coding conventions&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;u&gt;Coding Conventions Documents&lt;/u&gt; – you should create your &lt;br /&gt;company’s &lt;strong&gt;coding conventions&lt;/strong&gt; document which every developer &lt;br /&gt;should know. There is a great document that was written by &lt;br /&gt;&lt;strong&gt;Juval Lowy&lt;/strong&gt; that you can download from &lt;a title="IDesign Site" href="http://idesign.net/"&gt;here&lt;/a&gt; which is very&amp;nbsp; &lt;br /&gt;recommend to use. That document can be your building block &lt;br /&gt;for creating your own &lt;strong&gt;coding conventions&lt;/strong&gt; in your company.&lt;/li&gt;&lt;/ul&gt;
&lt;h3&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Lets sum up, I think that&lt;strong&gt; coding conventions&lt;/strong&gt; are essential &lt;br /&gt;tool for a quality and successful projects. In the post I wrote &lt;br /&gt;about &lt;strong&gt;coding conventions&lt;/strong&gt; and why you should use them. &lt;br /&gt;I also wrote how you can enforce &lt;strong&gt;coding conventions&lt;/strong&gt;.&amp;nbsp;&amp;nbsp; &lt;br /&gt;What do you think about &lt;strong&gt;coding conventions&lt;/strong&gt;? I’m very interested &lt;br /&gt;to know.&lt;/p&gt;
&lt;div style="TEXT-ALIGN:left;PADDING-BOTTOM:4px;MARGIN:0px;PADDING-LEFT:4px;PADDING-RIGHT:4px;PADDING-TOP:4px;" class="wlWriterHeaderFooter"&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/02/why-you-have-to-use-coding-conventions.aspx"&gt;&lt;img border="0" alt="DotNetKicks Image" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://blogs.microsoft.co.il/blogs/gilf/archive/2009/05/02/why-you-have-to-use-coding-conventions.aspx&amp;amp;bgcolor=0080C0&amp;amp;fgcolor=FFFFFF&amp;amp;border=000000&amp;amp;cbgcolor=D4E1ED&amp;amp;cfgcolor=000000" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=280494" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Miscellaneous/default.aspx">Miscellaneous</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Opinion/default.aspx">Opinion</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/OFFTOPIC/default.aspx">OFFTOPIC</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Code+Analysis/default.aspx">Code Analysis</category></item><item><title>Deep Code Analysis With NDepend</title><link>http://blogs.microsoft.co.il/blogs/gilf/archive/2008/11/07/deep-code-analysis-with-ndepend.aspx</link><pubDate>Fri, 07 Nov 2008 12:37:00 GMT</pubDate><guid isPermaLink="false">b5c4f5bc-c09b-4439-a595-91a98c1847df:162599</guid><dc:creator>Gil Fink</dc:creator><slash:comments>6</slash:comments><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.microsoft.co.il/blogs/gilf/commentapi.aspx?PostID=162599</wfw:comment><comments>http://blogs.microsoft.co.il/blogs/gilf/archive/2008/11/07/deep-code-analysis-with-ndepend.aspx#comments</comments><description>&lt;h1&gt;&lt;strong&gt;Deep Code Analysis With NDepend&lt;/strong&gt;&lt;/h1&gt;
&lt;p&gt;A few weeks ago,&lt;a href="http://blogs.microsoft.co.il/blogs/gilf/NDepend%20logo_3ADAFC8B.png"&gt;&lt;img title="NDepend" style="BORDER-TOP-WIDTH:0px;DISPLAY:inline;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;MARGIN-LEFT:0px;MARGIN-RIGHT:0px;BORDER-RIGHT-WIDTH:0px;" height="72" alt="NDepend" src="http://blogs.microsoft.co.il/blogs/gilf/NDepend%20logo_thumb_039DF66D.png" width="306" align="right" border="0" /&gt;&lt;/a&gt; &lt;br /&gt;I was contacted by &lt;br /&gt;&lt;a title="Patrick Smacchia&amp;#39;s Blog" href="http://codebetter.com/blogs/patricksmacchia/"&gt;Patrick Smacchia&lt;/a&gt;, &lt;br /&gt;a C# MVP, that I&amp;nbsp; &lt;br /&gt;read his articles on &lt;br /&gt;one of my favorite &lt;br /&gt;blog sites – &lt;a title="CodeBetter site" href="http://codebetter.com/"&gt;CodeBetter&lt;/a&gt;. &lt;br /&gt;&lt;a title="Patrick Smacchia&amp;#39;s Blog" href="http://codebetter.com/blogs/patricksmacchia/"&gt;Patrick&lt;/a&gt; asked me if I want to evaluate &lt;a title="NDepend site" href="http://www.ndepend.com/Default.aspx"&gt;NDepend&lt;/a&gt; professional edition. &lt;br /&gt;Without thinking twice, I agreed and this post is&amp;nbsp;a review of the product. &lt;br /&gt;I want to thank &lt;a title="Patrick Smacchia&amp;#39;s Blog" href="http://codebetter.com/blogs/patricksmacchia/"&gt;Patrick&lt;/a&gt; for the opportunity to evaluate a professional product &lt;br /&gt;which I wanted to test for a while (I downloaded the evaluation edition a few &lt;br /&gt;weeks before &lt;a title="Patrick Smacchia&amp;#39;s Blog" href="http://codebetter.com/blogs/patricksmacchia/"&gt;Patrick&lt;/a&gt; contact me and now I had the opportunity to download &lt;br /&gt;the professional edition).&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;What is NDepend?&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;&lt;u&gt;From &lt;/u&gt;&lt;a title="NDepend site" href="http://www.ndepend.com/Default.aspx"&gt;NDepend&lt;/a&gt;&lt;u&gt; site: &lt;br /&gt;&lt;/u&gt;”&lt;a title="NDepend site" href="http://www.ndepend.com/Default.aspx"&gt;NDepend&lt;/a&gt; is a tool that simplifies managing a complex .NET code base. Architects and &lt;br /&gt;developers can analyze code structure, specify design rules, plan massive refactoring, &lt;br /&gt;do effective code reviews and master evolution by comparing different versions of the &lt;br /&gt;code. &lt;br /&gt;&lt;br /&gt;The result is better &lt;b&gt;communication&lt;/b&gt;, improved &lt;b&gt;quality&lt;/b&gt;, easier &lt;b&gt;maintenance&lt;/b&gt; and &lt;br /&gt;&lt;b&gt;faster development&lt;/b&gt;.”&lt;/p&gt;
&lt;p&gt;&lt;a title="NDepend site" href="http://www.ndepend.com/Default.aspx"&gt;NDepend&lt;/a&gt; is a great tool! &lt;br /&gt;It is a static analyzer for a compiled code. It is suited for developers and architects &lt;br /&gt;that want to analyze the written code and get very helpful output data. &lt;br /&gt;The output data that &lt;a title="NDepend site" href="http://www.ndepend.com/Default.aspx"&gt;NDepend&lt;/a&gt; produces can help to improve the &lt;br /&gt;code quality and design. At first, I thought That the tool resembles the &lt;a title="FxCop on MSDN" href="http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx"&gt;FxCop&lt;/a&gt; tool &lt;br /&gt;but as I tested it further, I now understand that it allows me to drill down better and &lt;br /&gt;deeper into my code and also it supplies a visual analysis that is more intuitive for me.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;NDepend Features&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a title="NDepend site" href="http://www.ndepend.com/Default.aspx"&gt;NDepend&lt;/a&gt; has the following features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.ndepend.com/#CQL"&gt;Code Query Language (CQL)&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ndepend.com/#BuildComparison"&gt;Compare Builds&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ndepend.com/#Metrics"&gt;82 code metrics&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ndepend.com/#DependenciesView"&gt;Manage Complexity and Dependencies&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ndepend.com/#DependencyCycle"&gt;Detect Dependency Cycles&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ndepend.com/#Coverage"&gt;Harness Test Coverage Data&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ndepend.com/#Immutable"&gt;Enforce Immutability and Purity&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ndepend.com/#WarningsAndAdvices"&gt;Warnings about the health of your Build Process&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ndepend.com/#BuildProcess"&gt;Generate custom report from your Build Process&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ndepend.com/#Diagrams"&gt;Diagrams&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ndepend.com/#RealWorld"&gt;Facilities to cope with real-world environment&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;I can tell that the most awesome feature is the CQL (Code Query &lt;br /&gt;Language) which enables to write SQL like queries to get reflection details. &lt;br /&gt;In &lt;a title="FxCop on MSDN" href="http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx"&gt;FxCop&lt;/a&gt; to do the same thing enforces you to write rules or plug-ins which are less &lt;br /&gt;intuitive then the CQL.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Documentation, Documentation, Documentation&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;The most helpful thing about &lt;a title="NDepend site" href="http://www.ndepend.com/Default.aspx"&gt;NDepend&lt;/a&gt; is its documentation. Sometimes, when I &lt;br /&gt;download a tool or a product, I wish that it’ll be documented properly. Most of the &lt;br /&gt;tools aren’t documented at all or have a minor documentation. This issue is very &lt;br /&gt;annoying because you pay a lot of money for tools and you expect that it will have &lt;br /&gt;a decent documentation. The &lt;a title="NDepend site" href="http://www.ndepend.com/Default.aspx"&gt;NDepend&lt;/a&gt; site is full of documentation and screen &lt;br /&gt;casts that help to get start with the tool very fast. &lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Some Small Examples&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;When &lt;a title="NDepend site" href="http://www.ndepend.com/Default.aspx"&gt;NDepend&lt;/a&gt; load you get the following startup page: &lt;br /&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/gilf/NDepend%20Start%20Page_34561F7A.jpg" target="_blank"&gt;&lt;img title="NDepend Start Page" style="BORDER-TOP-WIDTH:0px;DISPLAY:inline;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" height="252" alt="NDepend Start Page" src="http://blogs.microsoft.co.il/blogs/gilf/NDepend%20Start%20Page_thumb_441FF742.jpg" width="420" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;As you can see, the tool can be integrated into Visual Studio (2005, 2008) &lt;br /&gt;and also into reflector (which is a must have tool for a developers). &lt;br /&gt;&lt;br /&gt;I used the New Project button from the File menu to build a new analysis project: &lt;br /&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/gilf/NDepend%20New%20Project%20View_10107951.jpg" target="_blank"&gt;&lt;img title="NDepend New Project View" style="BORDER-TOP-WIDTH:0px;DISPLAY:inline;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" height="252" alt="NDepend New Project View" src="http://blogs.microsoft.co.il/blogs/gilf/NDepend%20New%20Project%20View_thumb_540E7A5F.jpg" width="420" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;You can now Browse or Drag &amp;amp; Drop assemblies to be analyzed. &lt;br /&gt;&lt;br /&gt;After I dragged a simple assembly I got the following results: &lt;br /&gt;&lt;a href="http://blogs.microsoft.co.il/blogs/gilf/NDepend%20At%20Action_6D9B28EE.jpg" target="_blank"&gt;&lt;img title="NDepend At Action" style="BORDER-TOP-WIDTH:0px;DISPLAY:inline;BORDER-LEFT-WIDTH:0px;BORDER-BOTTOM-WIDTH:0px;BORDER-RIGHT-WIDTH:0px;" height="252" alt="NDepend At Action" src="http://blogs.microsoft.co.il/blogs/gilf/NDepend%20At%20Action_thumb_7DF34E4F.jpg" width="420" border="0" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What you can see in the screen are Dependency Graph, Dependency Matrix &lt;br /&gt;and the Metrics View which is set to the number of code lines in my example. &lt;br /&gt;In the bottom are the CQL Queries View which enables the use of CQL to &lt;br /&gt;inspect the code. This is only a minor assembly and &lt;a title="NDepend site" href="http://www.ndepend.com/Default.aspx"&gt;NDepend&lt;/a&gt; gave me a lot of details &lt;br /&gt;that I used to refactor the assembly and now the code is better written.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;&lt;a title="NDepend site" href="http://www.ndepend.com/Default.aspx"&gt;NDepend&lt;/a&gt; is a highly professional product. With its variety of features it can &lt;br /&gt;supply a very deep analysis to the code you write. I only scratched the surface of &lt;br /&gt;the product in this review. &lt;br /&gt;One last important thing, I wasn’t paid or obligated to write this review and its my thoughts &lt;br /&gt;only. I think a tool like &lt;a title="NDepend site" href="http://www.ndepend.com/Default.aspx"&gt;NDepend&lt;/a&gt; can really help you to get a deep insight and perspective &lt;br /&gt;on how you build your application and then help you to improve your code. &lt;br /&gt;&lt;/p&gt;
&lt;div class="wlWriterHeaderFooter" style="PADDING-RIGHT:4px;PADDING-LEFT:4px;PADDING-BOTTOM:4px;MARGIN:0px;PADDING-TOP:4px;TEXT-ALIGN:left;"&gt;
&lt;script type="text/javascript"&gt;&lt;/script&gt;

&lt;script src="http://widgets.dzone.com/widgets/zoneit.js"&gt;&lt;/script&gt;
&lt;/div&gt;&lt;img src="http://blogs.microsoft.co.il/aggbug.aspx?PostID=162599" width="1" height="1"&gt;</description><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Miscellaneous/default.aspx">Miscellaneous</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Opinion/default.aspx">Opinion</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/OFFTOPIC/default.aspx">OFFTOPIC</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Code+Analysis/default.aspx">Code Analysis</category><category domain="http://blogs.microsoft.co.il/blogs/gilf/archive/tags/Tools/default.aspx">Tools</category></item></channel></rss>