Getting a feel for a project

When I’m looking at a project for maintenance or refactoring, I always quickly browse around the code and do some spot checks. I will often run phploc and phpmd and look at the reports. But even before I do that, I tend to do a simple test on a file that I may be working on. I zoom out - way out.

The Zoom Test

Shrink your IDE font size, and look at the file. Examine it for two things, color change, and indententation. Let’s look at the Slim 3 Router:

Slim 3 Router

With this view, we can see the overall structure of the file. In this case, we can see that we’ve got some nesting in this method, and we can use that as a starting point in our hunt for complexity.

The color changes let us know about distribution of variables and keywords, and the overall indentation gives us a feel for the complexity in the file.

When we zoom back in we’ll find nested foreach statements.

Slim 3 nesting


This alone isn’t worth using as a way to target code for refactoring. But, it is a data point when deciding what to do with a file. I think this simple test can be used to give you a feel for a file, and with some other data provided by phpmd and a code coverage analysis, it can certainly help you decide where the bugs might be hiding, and a path through your code might exist that you haven’t completely addressed.