<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by jhashimoto on Medium]]></title>
        <description><![CDATA[Stories by jhashimoto on Medium]]></description>
        <link>https://medium.com/@jhashimoto0518?source=rss-ba0dad840dfa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gc6TCbdP3CuBGPGGIgUKBg.jpeg</url>
            <title>Stories by jhashimoto on Medium</title>
            <link>https://medium.com/@jhashimoto0518?source=rss-ba0dad840dfa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 14:43:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jhashimoto0518/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Visualizing Technical Debt Repayment through Refactoring with NDepend]]></title>
            <link>https://jhashimoto0518.medium.com/visualizing-technical-debt-repayment-through-refactoring-with-ndepend-d9c0ba8fe7a0?source=rss-ba0dad840dfa------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9c0ba8fe7a0</guid>
            <category><![CDATA[technical-debt]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[ndepend]]></category>
            <category><![CDATA[refactoring]]></category>
            <dc:creator><![CDATA[jhashimoto]]></dc:creator>
            <pubDate>Thu, 13 Apr 2023 23:56:25 GMT</pubDate>
            <atom:updated>2023-09-29T21:07:46.578Z</atom:updated>
            <content:encoded><![CDATA[<p>Note: This article is an English translation of my original article, which you can find here.</p><p><a href="https://qiita.com/JHashimoto/items/1cde008689c0446be780">リファクタリングによる技術的負債の返済をNDependで可視化してみた - Qiita</a></p><p>In this article, I will explore how NDepend can be used to repay technical debt through refactoring.</p><h3>Introduction</h3><p>I received a license from Patrick Smacchia, the creator of NDepend. However, my recent role has been more focused on infrastructure rather than application development, so I have not had the opportunity to use it in my work. Therefore, I decided to refactor some source code I had written in the past.</p><p>Here is the source code I tried to refactor; it is a simple desktop capture tool:</p><p><a href="https://github.com/JHashimoto0518/tiny-desktop-capture">GitHub - JHashimoto0518/tiny-desktop-capture: This is a simple screen capture.</a></p><p>The code was written 15 years ago, so it is quite rudimentary, but I thought it would be perfect for practicing refactoring.</p><p>Patrick suggested that the feature to “set an old project as a baseline and compare it with the refactored project to visualize the extent of improvement” would be a good match. In this article, I will try this feature and show how to visualize improvements through refactoring.</p><h3>What is NDepend?</h3><p>NDepend is a static analysis tool for analyzing .NET code. Its main features include code quality and architecture visualization, and code change tracking.</p><p>Here is an article where Patrick talks about NDepend:</p><p><a href="https://www.infoq.com/articles/patrick-smacchia-interview/">Talking .NET Code Analysis with Patrick Smacchia</a></p><h3>Analyzing the Source Code</h3><p>Launch VisualNDepend.exe and analyze the VS project. The association with the VS project can be saved as an NDepend project.</p><p>The analysis results are visualized in the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/0*Lu54WBbimPEmOax3" /></figure><h3>Setting the Baseline</h3><p>First, set a baseline before refactoring.</p><p>Create a copy of the original source code `v1.0` and create `v2.0`. Then, create NDepend projects for both v1.0 and v2.0, and set v1.0 as the baseline for v2.0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/0*93LOY2BdilXwp6Co" /></figure><p>From now on, I will not modify v1.0 and refactor v2.0.</p><h3>Exploring Hotspots</h3><p>NDepend has powerful features to help identify areas that should be refactored.</p><p>Focus on the `Debt` (technical debt) in the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*6YuM22Nn8E6kQrOe" /></figure><p>Selecting `Types to Fix Priority` lists classes with low breakpoint `issues`.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*02q8flIZGOxFpPgq" /></figure><p>The lower the breakpoint, the higher the investment value in improving code quality, and it serves as an indicator for determining priority.</p><p>Please refer to the official documentation for the concept of breakpoints:</p><p><a href="https://www.ndepend.com/docs/find-hot-spots#prioritize-issues-fix">Find Hot-Spots to Fix First</a></p><p>This time, I will focus on fixing MainForm+Config with the lowest breakpoint and an E rating.</p><p>Please note that the rating is based on the SQALE method.</p><p><a href="https://www.ndepend.com/docs/technical-debt#DebtRating">Compute and Manage the Technical Debt with NDepend</a></p><h3>Refactoring Hotspots</h3><p>Click `Issues` on the `MainForm+Config`, and a list of issues will be displayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*dN5i4EWM0ZRWQ1Rf" /></figure><p>Many issues stem from fields, so I will change them to properties.</p><p>v1.0</p><pre>/// &lt;summary&gt;<br>/// Configuration<br>/// &lt;/summary&gt;<br>private class Config {<br>    /// &lt;summary&gt;<br>    /// Image format<br>    /// &lt;/summary&gt;<br>    public string ImageType;<br>    /// &lt;summary&gt;<br>    /// Image magnification<br>    /// &lt;/summary&gt;<br>    public decimal Magnification;<br>}</pre><p>v2.0</p><pre>/// &lt;summary&gt;<br>/// Configuration<br>/// &lt;/summary&gt;<br>private class Config {<br>    /// &lt;summary&gt;<br>    /// Image format<br>    /// &lt;/summary&gt;<br>    public string ImageType { get; set; }<br>    /// &lt;summary&gt;<br>    /// Image magnification<br>    /// &lt;/summary&gt;<br>    public decimal Magnification { get; set; }<br>}</pre><p>After rebuilding and analyzing again, you can see how much debt has been repaid from the baseline. Other metrics, such as `Method Complexity`, are also visualized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/0*y5QSOA9TugpZmUHd" /></figure><h3>New debt created unintentionally</h3><p>It is essential to ensure that refactoring does not create new debt.</p><p><a href="https://www.ndepend.com/docs/write-clean-code">Write Clean Code From Now On</a></p><p>I will repost the dashboard from earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/0*MYnbryiy9aucpURf" /></figure><p>This shows that four new issues have emerged from the baseline. These are debts created during the refactoring process.</p><p>Clicking on `+4` will list the classes with issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/0*Bswj_xbhc4lgPGco" /></figure><p>Clicking on the `typeIssues` of the relevant class will display the issue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/0*kN6CW32S6kx0jzF7" /></figure><p>All of these issues point out that the visibility of the properties is public, even though the MainForm+Config class is not public. Therefore, I will modify them to internal.</p><p>v2.0</p><pre>private class Config {<br>    /// &lt;summary&gt;<br>    /// Image format<br>    /// &lt;/summary&gt;<br>    internal string ImageType { get; set; }<br>    /// &lt;summary&gt;<br>    /// Image magnification<br>    /// &lt;/summary&gt;<br>    internal decimal Magnification { get; set; }<br>}</pre><p>After rebuilding and analyzing again, confirm that the new issues are resolved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/0*BzhEbpjkDGQAL8Ut" /></figure><h3>Visualizing Comparison with Baseline</h3><p>As mentioned earlier, you can compare how much debt has been repaid from the baseline.</p><p>Additionally, you can compare various aspects.</p><p>For example, selecting [Diff] &gt; [Code Diff Summary] &gt; [Types where code] was changed from the menu will list the classes changed during refactoring.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/0*9PthBQ_ivvuhFP7n" /></figure><p>Selecting [Diff Source] from the context menu will display the difference between the relevant class and the baseline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*sggOO9ZbIzMMZmUL" /></figure><h3>Conclusion</h3><p>In this article, I explained how to use NDepend to improve code quality by focusing on comparing with the baseline.</p><p>After trying it out, I felt that NDepend could provide the following benefits:</p><ul><li>The quantification of losses due to debt and repayments through refactoring, which can be used to appeal to the business side. In other words, it can be used as a basis for proposing refactoring.</li><li>Improved developer motivation through visualization of code quality improvement achievement rates and the current code quality compared to target values.</li></ul><p>Furthermore, NDepend has many other features and use cases. I would like to try other features in the future.</p><p><a href="https://www.ndepend.com/docs/ndepend-use-cases">Introduction to NDepend Use Cases</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9c0ba8fe7a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>