<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>LifeCycle Solutions, LLC - Weblog - Utilities</title>
    <link>http://blog.lifecycle-solutions.com/</link>
    <description>Technical Writing</description>
    <language>en-us</language>
    <copyright>LifeCycle Solutions, LLC</copyright>
    <lastBuildDate>Thu, 26 Feb 2009 23:27:30 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.2.8279.16125</generator>
    <managingEditor>info@lifecycle-solutions.com</managingEditor>
    <webMaster>info@lifecycle-solutions.com</webMaster>
    <item>
      <trackback:ping>http://blog.lifecycle-solutions.com/Trackback.aspx?guid=881a0cb7-695e-4842-9637-b40c8051106a</trackback:ping>
      <pingback:server>http://blog.lifecycle-solutions.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.lifecycle-solutions.com/PermaLink,guid,881a0cb7-695e-4842-9637-b40c8051106a.aspx</pingback:target>
      <dc:creator>Daniel Root</dc:creator>
      <wfw:comment>http://blog.lifecycle-solutions.com/CommentView,guid,881a0cb7-695e-4842-9637-b40c8051106a.aspx</wfw:comment>
      <wfw:commentRss>http://blog.lifecycle-solutions.com/SyndicationService.asmx/GetEntryCommentsRss?guid=881a0cb7-695e-4842-9637-b40c8051106a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've recently started playing with NDepend again.  This tool is a sort of data
mining utility for your code.  Feed it your assemblies and it can tell you almost
anything about them.  Using a custom query language with a SQL-like syntax, you
can dig into all sorts of metrics and useful information. Out of the box, it ships
with tons of useful queries for common code problems.  
</p>
        <p>
I ran some of our code through it and got dinged on some of the code complexity queries:
</p>
        <p>
 <a href="http://blog.lifecycle-solutions.com/content/binary/WindowsLiveWriter/DeepZoomYourCodeQualityWithNDepend_C61E/image_2.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="187" alt="image" src="http://blog.lifecycle-solutions.com/content/binary/WindowsLiveWriter/DeepZoomYourCodeQualityWithNDepend_C61E/image_thumb.png" width="430" border="0" /></a></p>
        <p>
In this case, I had several huge methods that needed to be broken up and optimized. 
Thanks to NDepend's prodding, I spent some time refactoring using ReSharper, and whittled
those down to 0s:
</p>
        <p>
          <a href="http://blog.lifecycle-solutions.com/content/binary/WindowsLiveWriter/DeepZoomYourCodeQualityWithNDepend_C61E/image_4.png">
          </a>
          <a href="http://blog.lifecycle-solutions.com/content/binary/WindowsLiveWriter/DeepZoomYourCodeQualityWithNDepend_C61E/image_8.png">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="142" alt="image" src="http://blog.lifecycle-solutions.com/content/binary/WindowsLiveWriter/DeepZoomYourCodeQualityWithNDepend_C61E/image_thumb_3.png" width="405" border="0" />
          </a>
        </p>
        <p>
That's helpful, but not nearly everything that NDepend can do.  For example,
the code I'm testing with is involved in some multithreading, so with a little digging
through the docs, I came up with this query to show all methods that change state
(besides property and event setters), but don't use any locks:
</p>
        <p>
WARN IF Count &lt; 0 IN SELECT METHODS WHERE 
<br />
!IsDirectlyUsing "System.Threading.Monitor" AND ( ChangesObjectState OR
ChangesTypeState ) AND 
<br />
!IsConstructor AND !IsClassConstructor AND !IsPropertySetter AND !IsEventAdder AND
!IsEventRemover
</p>
        <p>
This doesn't guarantee thread-safe code, but it definitely helps drill down to potential
problem areas.
</p>
        <p>
Another area I can see us using this in is to provide metrics for our customers. 
Generally they are not concerned with things like Cyclomatic Complexity, but some
simple numbers may be useful.  We use FinalBuilder, so it's possible we could
run NDepend's console utility to roll the numbers into some XML and publish to their
customer wiki.  For example, here's a quick query to spit out the total number
of tests for a project:
</p>
        <p>
SELECT METHODS FROM ASSEMBLIES "TestAssemblyName" WHERE HasAttribute "NUnit.Framework.TestAttribute"
</p>
        <p>
Once we get a customer set up with these metrics, we'll post more about how to automate
that.  Until then, go <a href="http://www.ndepend.com">check out NDepend</a>!
</p>
        <p>
        </p>
        <img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=881a0cb7-695e-4842-9637-b40c8051106a" />
      </body>
      <title>DeepZoom Your Code Quality With NDepend</title>
      <guid isPermaLink="false">http://blog.lifecycle-solutions.com/PermaLink,guid,881a0cb7-695e-4842-9637-b40c8051106a.aspx</guid>
      <link>http://blog.lifecycle-solutions.com/2009/02/26/DeepZoomYourCodeQualityWithNDepend.aspx</link>
      <pubDate>Thu, 26 Feb 2009 23:27:30 GMT</pubDate>
      <description>&lt;p&gt;
I've recently started playing with NDepend again.&amp;#160; This tool is a sort of data
mining utility for your code.&amp;#160; Feed it your assemblies and it can tell you almost
anything about them.&amp;#160; Using a custom query language with a SQL-like syntax, you
can dig into all sorts of metrics and useful information. Out of the box, it ships
with tons of useful queries for common code problems.&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
I ran some of our code through it and got dinged on some of the code complexity queries:
&lt;/p&gt;
&lt;p&gt;
&amp;#160;&lt;a href="http://blog.lifecycle-solutions.com/content/binary/WindowsLiveWriter/DeepZoomYourCodeQualityWithNDepend_C61E/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="187" alt="image" src="http://blog.lifecycle-solutions.com/content/binary/WindowsLiveWriter/DeepZoomYourCodeQualityWithNDepend_C61E/image_thumb.png" width="430" border="0" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
In this case, I had several huge methods that needed to be broken up and optimized.&amp;#160;
Thanks to NDepend's prodding, I spent some time refactoring using ReSharper, and whittled
those down to 0s:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blog.lifecycle-solutions.com/content/binary/WindowsLiveWriter/DeepZoomYourCodeQualityWithNDepend_C61E/image_4.png"&gt;&lt;/a&gt;&lt;a href="http://blog.lifecycle-solutions.com/content/binary/WindowsLiveWriter/DeepZoomYourCodeQualityWithNDepend_C61E/image_8.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="142" alt="image" src="http://blog.lifecycle-solutions.com/content/binary/WindowsLiveWriter/DeepZoomYourCodeQualityWithNDepend_C61E/image_thumb_3.png" width="405" border="0" /&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
That's helpful, but not nearly everything that NDepend can do.&amp;#160; For example,
the code I'm testing with is involved in some multithreading, so with a little digging
through the docs, I came up with this query to show all methods that change state
(besides property and event setters), but don't use any locks:
&lt;/p&gt;
&lt;p&gt;
WARN IF Count &amp;lt; 0 IN SELECT METHODS WHERE 
&lt;br /&gt;
!IsDirectlyUsing &amp;quot;System.Threading.Monitor&amp;quot; AND ( ChangesObjectState OR
ChangesTypeState ) AND 
&lt;br /&gt;
!IsConstructor AND !IsClassConstructor AND !IsPropertySetter AND !IsEventAdder AND
!IsEventRemover
&lt;/p&gt;
&lt;p&gt;
This doesn't guarantee thread-safe code, but it definitely helps drill down to potential
problem areas.
&lt;/p&gt;
&lt;p&gt;
Another area I can see us using this in is to provide metrics for our customers.&amp;#160;
Generally they are not concerned with things like Cyclomatic Complexity, but some
simple numbers may be useful.&amp;#160; We use FinalBuilder, so it's possible we could
run NDepend's console utility to roll the numbers into some XML and publish to their
customer wiki.&amp;#160; For example, here's a quick query to spit out the total number
of tests for a project:
&lt;/p&gt;
&lt;p&gt;
SELECT METHODS FROM ASSEMBLIES &amp;quot;TestAssemblyName&amp;quot; WHERE HasAttribute &amp;quot;NUnit.Framework.TestAttribute&amp;quot;
&lt;/p&gt;
&lt;p&gt;
Once we get a customer set up with these metrics, we'll post more about how to automate
that.&amp;#160; Until then, go &lt;a href="http://www.ndepend.com"&gt;check out NDepend&lt;/a&gt;!
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&gt;&gt;&lt;img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=881a0cb7-695e-4842-9637-b40c8051106a" /&gt;</description>
      <comments>http://blog.lifecycle-solutions.com/CommentView,guid,881a0cb7-695e-4842-9637-b40c8051106a.aspx</comments>
      <category>C#</category>
      <category>Utilities</category>
      <category>Visual Studio</category>
    </item>
  </channel>
</rss>