Whether you are on a big team or a small team, complexity is one of the most common problems among developers. Even projects with just one developer can easily get out of hand when it comes to architecture. Thankfully there are easy measures you can take to prevent your project from falling into a pit of complexity.

Background

Now obviously the best approach is proper planning. Taking time to think through requirements, potential issues, and how to set everything up can save you tons of time later down the road. Unfortunately even the best plans can still get muddy when you add more developers, increase scope, or move up deadlines. I think some of the worst mistakes aren't the concious "hacks" or intentional tech debt, but rather the bad decisions we don't even know about. Thankfully that's where tools can save the day!

Static analysis tools read through your codebase and find potentially problematic areas of code. The most common problems are usually around unhandled exceptions, memory leaks, complex code blocks, and more. If you can integrate these tools into your daily workflow, or even better your DevOps pipeline, you will find the quality of your codebase will improve.

My clients have often asked about which static analysis tools to use, but rarely want to take the time to try out the options. One such tool that I've seen come up time and time again is NDepend. Of the tools I've read about, NDepend seems to be the most developer focused tool with a great set of features for maintaining complex projects. So over the next few months I will be making NDepend a daily driver to get to know it a little better.

I would like to send a sincere thanks to Patrick from the NDepend team for giving me a pro license to play around with. As always I only share my genuine thoughts and opinions about anything I review, good and bad. But something tells me this is gonna be pretty good, especially since they just added full support for .NET 5 and Blazor!

Top Features

Let's take a look the features I'm most excited to get my hands on:

Code Rules

This is really the core functionality of "Static Code Analysis", find the problems/bad practices in your projects. I'm super interested to see what NDepend can find in my current projects and what it might find in some popular open source projects. The best part is that code rules are written using C# Linq queries, so editing existing rules or creating custom ones looks to be very straightforward.

Screenshot of the editing a code rule in NDepend using Linq.
Rules are just Linq statements! (with very detailed intellisense)

Tech Debt Estimate

If it works as advertised, the ability for NDepend to estimate how much time it will take to fix a code smell will be a game changer for planning sessions. It also estimates how much time will be saved over the next year just by fixing it. And again, these calculations are all done in C# Linq queries, so they can be tweaked and customized to your liking.

Screenshot of NDepend's tech debt estimates inside of Visual Studio.
Annual Intrest is the number of days it will cost you if you don't fix it.

DevOps Integration

All of the features sound great, but there is nothing more satisfying than automating all of these checks and tracking them over time. It looks like NDepend can integrate with quite a few DevOps platforms, but I will be focusing on Azure DevOps since that't what we use for almost all of our projects. And no PM can resist more dashboard widgets and quality gates!

Screenshot of the NDepend dashboard inside Azure DevOps.
Dashboard widgets for all of the metrics/trends!

Performance

Based on the "real world proof", NDepend is lightening fast and uses minimal memory. Even on a laptop with an i9, 500GB SSD, and 64GB RAM I have trouble running some tools (I'm looking at your Resharper) at full throttle. If NDepend can analyze my entire codebase with virtually zero impact on Visual Studio then I will be very happy camper!

Wrap Up

I've been wanting to test NDepend for months now and I can't wait to see how it scores my projects. I'm optimistic that it will be a valuable tool, but I also hope it can teach me better ways to write code. Because at the end of the day writing better code, pausing to plan, and working together is a guarenteed combo for building better software.


Have you used NDepend, or any other static analyzer? Send me a tweet and let me know about it!!