TLDR: Eric Poole has used Understand for over 20 years to understand and reverse engineer legacy code for medical devices and other projects.
Eric Poole is a retired software engineering consultant who specializes in software development for medical devices. His career as a software engineer began in 1976. Four years later, he began offering independent consulting on a variety of projects. By 1990, he found a specialization in medical devices and never looked back.
For over 20 years, Eric has used Understand to refactor and reverse engineer legacy code for his clients. Because understanding legacy code can be a challenge, he uses a tool he knows he can trust.
Eric’s primary objective is to understand how code works. To achieve this objective, he uses Understand’s diverse features. Some of his favorites include the Most Complex Functions chart, graphs, Annotations, and CodeCheck. Each of these features serve Eric in a different way and help him understand how his clients’ code works together.
Reverse Engineering Code Using Understand
Legacy code can be like spaghetti–tangled and messy. Even with code that he has never seen before, Eric is able to quickly make sense of the mess with Understand. According to him, there are two primary ways in which he works with legacy code: graphic diagrams for visualization and jump-to features for easy navigation.
Eric frequently uses call, called-by, butterfly, and control flow graphs. Each of these graphs allows Eric to visualize code. Using these graphs, Eric can view the project as a whole or zoom in on a specific area he’s interested in examining.
Eric asserts that the graphs feature is helpful in allowing him to understand his clients’ code, and it’s easy to see why. Without the ability to maneuver through legacy code using graphs, it’s very difficult to see how the code works together. This is especially important for Eric in identifying exactly where errors are occurring in the code.
Eric also mentioned his appreciation for the ability to right-click on source code to jump to definitions or declarations. This simple feature allows Eric to work through code quickly by taking him to the exact lines of code he wants to examine. From there, he can see references, textual call trees, dependencies, and graphs. He can also identify how any changes to the code might affect the project.
How Understand Helps Eric Work With Legacy Code
Let’s dig a bit deeper into some of Eric’s favorite features in Understand.
When we sat down with Eric, the first thing he mentioned was how useful Understand’s dashboard charts are. When beginning a new project, this is Eric’s first stop. Project Overview charts, like the ones displayed below, are an excellent way to orient yourself to the project you’re working on, especially if you’ve never seen the source before. They provide a comprehensive overview of important information in your code, including how many lines of code the project has, how many of those lines of code are inactive, what the basic structure of the project looks like, what the most complex function is, and more. They can be reached by selecting Project -> Overview.
Most Complex Functions Charts
Eric starts with the Most Complex Functions Chart, which tells a quick story about where the most complicated pieces of code in the project are located. Functions are measured using a complexity metric, determined by the McCabe cyclomatic metric, which gives insight into how difficult the code can be to understand and refactor. A higher McCabe cyclomatic metric translates to more decision points in a function, which results in a higher complexity that is more difficult to understand and increases the risks of changing the code. Eric investigates these complex functions and uses Understand to help get them refactored to a more manageable piece of code. This most often results in programs that run faster and are easier to maintain.
Eric revisits these dashboard charts to view his progress. For someone wanting to see the bigger picture of their project, these charts are a great place to start.
Whereas overview charts provide an overall view of the project, graphs allow Eric to examine code line by line. Because Eric’s objective is to understand and improve code, he finds Understand’s graphs to be a valuable resource.
Call/Call by and Butterfly
For Eric, this is where the fun begins. Call/Call by graphs allow Eric to get up close and personal with his clients’ code. Typically, he selects individual elements of code and expands them three to four levels; he noted that anything past these levels are often difficult to follow because of its size. This method of analyzing code shows Eric circular dependencies and where code will be affected by any changes made.
When using call/called-by graphs, Eric recommends selecting “show edges out” (right-click on the node to find the option) to expand each node as needed.
Similarly, butterfly graphs are helpful in analyzing how elements of code work together. By using butterfly graphs, Eric can examine both call and called-by functions of a particular element in code.
Control Flow graphs provide a visual view of all of the paths through a function. This representation can make it easier to find potential areas to optimize, including easy-to-see loops and overly complicated paths. SciTools realizes the importance of viewing your control flow graph, so there are many options built in to Understand to customize your view. Eric prefers his Control Flow graphs to be displayed vertically, as shown here, but they can also be displayed horizontally.
Let’s face it: in projects that contain thousands of lines of code, it’s easy to get lost in the chaos. In Eric’s case, he prefers to keep track of his work using Understand’s Annotations feature. This allows the comments to be in-line in the editor so they are easy to see, but they aren’t actually in the source. Eric uses Annotations to document the changes he’s made to the code and remind him what still needs to be done. He can view the Annotations in-line in the editor, in a report view, or in the Annotations Browser. And don’t worry, when code with an attached Annotation gets deleted or moves around, Understand is smart and keeps it where it needs to be.
Eric also emphasized the importance of using Annotations to document his work to his clients. His clients need to be aware of every change he makes to the code, and the Annotation feature is an easy way to do that. Eric says that using Annotations avoids later confusion and frustration from his clients, who didn’t want the process documented in their source, just the end results. It also ensures he avoids maintaining duplicate source code.
What good is a static analysis tool that doesn’t check code? CodeCheck is one of Understand’s most significant features, and it helps Eric see how the project measures up to the expected standard, giving him an idea of how much work is ahead of him. With the jump-to-code feature from the list of violations and the in-line source view of violations with many auto-fix options, it is faster and easier to manage the work of meeting necessary standards. Eric specializes in medical devices that require verification against the MISRA set of industry standards, and Understand provides out-of-the-box support for 3 of the MISRA standards.
A Shoutout to the Support Team
Eric Poole has used Understand for over 20 years to refactor legacy code and keep it running efficiently. We’ve discussed some of Eric’s favorite tools in Understand, and in addition to these features, Eric is a big fan of our support team. When he has questions or concerns, he knows he can rely on the SciTools support team to help. Here’s what he has to say about his experience interacting with our engineers:
“Most often, whenever there would be something I wished it would do or do better, I’d send in a report to Kevin or someone else on the support team, and within a few days to a few weeks, I’d get an email back advising that the issue has been fixed and would be released in the next release. That, to me, is the best part of Understand–your amazing support and development team.”
Thank You, Eric!
SciTools thanks long-time customers like Eric for their continued support. Because of the “Erics” of the world, we work hard to create an exceptional static code analysis tool that you can rely on. If there is a feature that Understand doesn’t have, shoot our support team a message, and we’ll do our best to implement the change into a future version of the tool.