Title: A Review of NDepend

Patrick Smacchia kindly provided me with a professional license for v2.12 so I could explore and share my thoughts. As it was a gift, I made sure to spend some time diving into its features. After exploring it thoroughly, I must say I like it. NDepend isn’t the ultimate tool you must use, but, like others such as Resharper or Reflector, it gives you a valuable perspective on your codebase.

NDepend is a bit like Resharper in that it highlights potential issues in your code. The difference is that Resharper helps during coding, while NDepend focuses on giving a comprehensive review of the overall code quality.

The Core of NDepend: CQL

The heart of NDepend is its Code Query Language (CQL). Initially, I thought CQL might just be a flashy feature to help market the tool, but it turns out to be genuinely useful. CQL is essentially SQL for code, allowing you to query your codebase in a structured way. The autocomplete support in the CQL textbox also makes writing these queries quite easy.

Don’t Make It a Judgment Tool

The biggest risk with NDepend is giving it to people who may not fully understand software development (e.g., code quality reviewers who aren’t developers). Used unwisely, it could be a source of frustration. Not every piece of code that triggers a warning should necessarily be changed.

Take this example from the StreamRipper app:

private static Boolean ParseArgs(String[] args, Parameters parameters) {
    try {
        for (int i = 0; i < args.Length; i++) {
            switch (args[i]) {
                case "--url":
                case "-u":
                    parameters.Urls.Add(args[++i]);
                    break;
                case "--user-agent":
                case "-a":
                    parameters.UserAgent = args[++i];
                    break;
                case "--reconnect-attempts":
                case "-r":
                    parameters.MaxReconnectionTries = int.Parse(args[++i]);
                    break;
            }
        }
        return true;
    }
    catch (Exception) {
        Console.Error.WriteLine("Arguments error!");
        return false;
    }
}

This method generates a cyclomatic complexity warning, as it would in Resharper. Personally, I think it’s fine to accept a fair number of these warnings. Unlike Resharper, where you can solve most issues by accepting its suggestions, NDepend often surfaces deeper concerns that require more nuanced judgment.

What NDepend Does Well

NDepend gives you a broad overview of your codebase: main projects, classes, methods, and an overall sense of quality. The visual representation, though not the prettiest, effectively simplifies complex structures.

When you have a doubt, just double-click on a method, and it opens directly in Visual Studio. You also get a dependency graph view:

At first glance, it may not seem that useful, but with Visual NDepend, moving your mouse over a project displays both parent and child assemblies:

Project Evolution

Another neat feature is how NDepend saves past analysis results, allowing you to track the evolution of your project over time. You can see which methods were modified, added, or deleted between analyses. This feature works for individual assemblies as well, providing insights into changes made between versions. Combined with tools like Reflector, this allows a detailed view of what has been fixed or improved.

For a good example, check out .

Final Thoughts

NDepend provides a quick, simplified view of a project’s organization and size. It’s an excellent tool for .Net projects, especially for large codebases. However, be careful not to get too hung up on trying to meet all its CQL checks—they can be restrictive. If needed, consider adjusting threshold values. And most importantly, be cautious before making any big judgment calls based on NDepend alone—it can be tempting, but context matters.