I’m going to cover some relative basics today. At least, they’re basics when it comes to differentiating between static and dynamic code analysis. If you’re new to the software development world, you may have no idea what I’m talking about. Of course, you might be a software development veteran and still not have a great idea.
So I’ll start from basic principles and not assume you’re familiar with the distinction. But don’t worry if you already know a bit. I’ll do my best to keep things lively for all reading.
Static and Dynamic Code Analysis: an Allegory
So as not to bore anyone, bear with me as I plant my tongue in cheek a bit and offer an “allegory” that neither personifies intangible ideas nor has any real literary value. Really, I’m just trying to make the subject of static and dynamic code analysis the slightest bit fun on its face.
So pull your fingers off the keyboard and let’s head down to the kitchen. We’re going to do some cooking. And in order to that, we’re going to need a recipe for, say, chili.
We all know how recipes work in the general life sense. But let’s break the cooking activity into two basic components. First, you have the part where you read and synthesize the recipe, prepping your materials and understanding how things will work. And then you have the execution portion of the activity, wherein you do the actual cooking — and then, if all goes well, the eating.
Static and Dynamic Recipe Analysis
Having conceived of preparing the recipe in two lights, think in a bit more detail about each activity. What defines them?
First, the recipe synthesis. Sure, you read through it to get an overview from a procedural perspective, rehearsing what you might do. But you also make inferences about the eventual results. If you’ve never actually had chili as a dish, you might contemplate the ingredients and what they’d taste like together. Beef, tomato sauce, beans, spicy additives…an idea of the flavor forms in your head.
You can also recognize the potential for trouble. The recipe calls for cilantro, but you have a dinner guest allergic to cilantro. Yikes! Reading through the recipe, you anticipate that following it verbatim will create a disastrous result, so you tweak it a little. You omit the cilantro and double check against other allergies and dining preferences.
But then you have the actual execution portion of preparing a recipe. However imaginative you might be, picturing the flavor makes a poor substitute for experiencing it. As you prepare the food, you sample it for yourself so that you can make adjustments as you go. You observe the meat to make sure it really does brown after a few minutes on high heat, and then you check on the onions to make sure they caramelize. You observe, inspect, and adapt based on what’s happening around you.
Then you celebrate success by throwing cheese on the result and eating until you’re uncomfortably full.