Anyone working with large software systems knows the difficulties of retaining visibility into those systems. As software solutions grow, it becomes increasingly difficult to retain a clear picture of how the components fit together. In an age of increasingly demanding software consumers it is critical to quickly find and solve problems before they grow. Enter NDepend, a collection of tools designed for deep analysis and visualization of the software solutions you create.
NDepend provides a rich analytic tool set to help gain a deep understanding of your code and monitor the health of a project throughout its lifecycle. I’ve used NDepend in a number of projects on which I consider myself very knowledgeable. NDepend provides pleasant surprises, even within those familiar projects. It’s great to see the new insights I gain when analysing familiar solutions. I can quickly see the structure of my code in ways that were previously unavailable to me.
I recently started work at a new job where I became quickly involved with a number of large software solutions. Cvent have two decades of software, some written in .NET, others in Java, and a solution here in our Portland office written in Ruby. I’ve been a polyglot developer my whole career, but switching between so many large code-bases through the course of a working week means I need tools to help me maintain a working mental model of the structure of the various solutions I’m working with.
One of the first things I did upon returning to Cvent was to fire up the new NDepend 2017 and point it at one of the larger core code-bases I needed to learn. Many of my peers have worked at Cvent for several years. They are very familiar with the structure of the solutions they manage. It was important I ramp up quickly to extract as much as possible from conversations regarding solution structure, integrations, and refactoring.
As with most projects of any reasonable size and age, the documentation is either lacking or out of date. There are a few high level class and interaction diagrams kicking around, but with a few hundred thousand lines of code and solutions containing tens if not hundreds of projects, it can be hard to know where to start. NDepend’s heat map, overview dashboard, and dependency graphs helped me to quickly learn the lay of the land.
Integration with Visual Studio
Once an interesting relationship or piece of code is located, a double-click brings up the relevant file and method directly within Visual Studio. This is a great way to navigate between a high-level view of the system architecture directly into the details of a class or method of interest. Moving back and forth in this way between the abstract models of a large system then into the details of the most interesting modules helps build familiarity much faster than simply reviewing each module line by line.
It didn’t take long before my peer architects were asking whether they could get access to the tool. “Those navigable dependency graphs are awesome!” said one architect, looking over my shoulder as I merrily skipped around different modules, tracing paths through the architecture.
At its core, NDepend is a database that automatically indexes everything about the code you write. The solutions analysis stores and indexes information about aesthetic, technical, and architectural metrics. Dashboards and reports present the data in a variety of useful dashboards and reports. Examples include the number of lines of commented code, the number of parameters received by a method. Additionally there are more complex architectural metrics such as afferent and efferent coupling.
Dynamic queries, written using CQL (Code Query Language), drive many of NDepend’s visualizations. Tailoring these queries to your liking allows for customization of NDepend’s reports to your own coding standards and guidelines. It’s a powerful mechanism for rooting out areas of the code that might otherwise be difficult to uncover.
NDepend ships with predefined rule sets. These rules are used to analyse code and provide feedback on areas of concern. The rules are built using the CQL and can be customized by the development teams that rely upon them.
Delegating a part of the task of reviewing code quality to an automated process can help to avoid having that feedback taken personally. A team that votes and agrees upon the rules and standards they hold themselves to can codify those standards as a rule set. When the automated analysis highlights violations to those agreements there is a clear statement about what needs to be done. It also avoids the costs involved in having humans perform such mechanical tasks.
A snapshot of code quality is useful for quickly generating a list of issues that can improve quality. However, it doesn’t give a great sense of how the code is improving, or worse potentially devolving, over time. By measuring the trend of the code it is possible to estimate how long it will take to pay off a particular type of technical debt. Think scrum velocity measures but for code quality.
Trend analysis takes results from different analysis runs and allows you to visualize how the quality of your software is changing over time. NDepend trend monitoring is driven via the definition of a set of trend metrics. The technical team defines the rules for technical debt and quality gates. The team controls how the quality is measured. This increases the sense of ownership in trend analysis and monitoring. Relying upon an customized automated tool to provide this feedback saves precious developer hours for the more important task of writing the software. This also provides architects and team leads with feedback on how their engineering initiatives are affecting the overall quality of the delivered solution.
Learning Your Own Code
NDepend is a rich tool with a vast array of features for measuring and monitoring code quality and structure. As with any tool it can take time to learn about all of the capabilities and master their use. One of the best things about NDepend is how quickly even the initial analysis adds value. Whether I’m learning about a new piece of code or working on familiar software I’ve maintained for years, NDepend always shows me something new. You can never know too much about the structure and dependencies within your code.
I highly recommend NDepend to any software architect or senior developer who wants to understand their software more clearly. Understanding the structure of your code is the first step. Monitoring the quality journey it takes through every commit and pull request takes that to the next level. Professional effectiveness can depend upon having the right tools at hand. NDepend is definitely one you’ll want to have in your architectural bag of tricks.
The complete list of changes is available here: http://www.ndepend.com/ndepend-v2017
Disclosure: I do not work for NDepend or Zen Program Ltd. I received an evaluation copy of NDepend for my review.