If you’re a software developer, particularly of the newly minted variety, the concept of static analysis might not seem approachable. It sounds academic. It sounds architect-y. It sounds complicated. I’ve seen this reaction from a lot of people in my career and I think that’s too bad.
If you delve into its complex depths, static analysis can be any and all of these things, but with the developers I mentor and coach, I like to introduce it as a game that makes you better at what you do. You can use static analysis to give yourself feedback about your code that is both fast and anonymous, allowing you to improve via trial and error, rather than by soliciting feedback from people much more tenured than you and sometimes wincing as they lay into you a little. And, perhaps best of all, you can calibrate the quality of your code with the broader development world, rather than just pleasing the guy who has hung around your company long enough to default his way into the “tech lead” role.
Take a look at some of the feedback that NDepend offers about your code. “That method is too big” isn’t particularly intimidating, is it? I mean, you might wonder at what you could do to compact a method, but it’s not some kind of esoteric rule written in gibberish. You run NDepend on your code and you can see that there is some number of methods that the broader development community considers to be “too big.”
From there, you can start looking at ways to write smaller methods and to refactor some of your current ones to sneak in under the warning number. This is the essence of gamification — you change the way you write code to get rid of the warnings. You get better. And it’s gratifying.
As you do this, another interesting thing starts to happen. You start noticing that other developers continue to write large methods and when you run NDepend on their code, they light up the console with errors, whereas you do not with your code. And so, you can have conversations with them that start with, “you know, this static analysis tool I’ve been using wants us to have smaller methods, and I’ve been working a lot on that, if you ever want a hand.”
You gain a reputation as being knowledgeable. Before you know it, you can cite widely accepted static analysis rules and the design goals they imply. You know these rules, and, via gamification, you have experience molding code to comply with them. Even in cases where you might wind up overruled by the local team lead or architect, it’s no longer a simple matter of that person saying, “because I said so,” and just ending the conversation. They have to engage with you and present cogent counter-arguments to your points. You’re participating in important discussions in ways that you never have before.
If it sounds like I’m speaking from experience, I am. Throughout my career, I’ve been relentless about figuring out ways to improve my craft, always trying to be a better programmer. Early on, I was unsatisfied with a lot of arguments among developers around me that I knew boiled down to nothing more than personal preference, so I went out in search of empirical methods and broader knowledge, and that search brought me to static analysis. I read about data and science behind particular choices in approaching software, and I schooled myself to adopt the approaches that had brought the best results.
Somewhere along that journey, I discovered NDepend and its effect on my approach to writing code was profound. My methods shrank and became less complicated. My architectural and design skills improved as I made it a point to avoid dependency cycles and needless coupling. I boosted unit test coverage and learned well established language practices. It was not long before people routinely asked me for design advice and code reviews. And from there, it wasn’t long before I occupied actual lead and architect roles.
So, if you want to improve your craft and nudge your career along, don’t pass on static analysis, and don’t pass on NDepend. NDepend is not just a tool for architects; it’s a tool for creating architects from the ranks of developers. You’ll up your game, improve your craft, and even have some fun doing it.