
I’ve just realized that while I’ve written a bunch of posts referring to snapshots and using snapshots, I’ve never explained what they are and how they can fit into a software engineer’s workflow. Hence the “missing piece of the puzzle” clip art above.
Q: What are snapshots?
A: A snapshot is a binary store included within an Understand database. A database can hold be any number of snapshots. Each contains three things:
- a complete Understand database containing analysis (parse) information
- all source, including any include files, needed to rebuild that analysis
- certain cached information used to speed up working with them (metrics and file information)
Q: What are snapshots used for?
A: They are used throughout Understand 2.0 to provide details and metrics about what has changed in source code between two points of time. The “Change”, “Metrics”, and “Estimate” menus all use snapshots intensively.
“Change” will tell you what has changed at the semantic level. For instance, what classes or types changed, versus just what files/lines changed.
“Metrics” can tell you the number of semantic changes – classes removed, changed, added, so forth.
Q: How is a “diff” better when using snapshots than Understand 2.0’s text differencing capabilities?
A:
- Easy. Using a snapshot means you don’t have to keep different versions of source lying around. Snapshots are easy to make. Just click a button and you’ve got one.
- Compares using snapshots use semantic differencing. That means, for instance, that no matter how much a function changes or moves around in a file you can easily isolate just changes inside the function, class or other logical / semantic unit in code. Differences shown are specific to the entities you are concerned about.
- Find Changes by type of entity changed. You can just look at class or type changes, or functions. You can find changes in classes with high complexity. You can find classes that had the most changes. So on.
- Find changes in dependency trees. Semantic differencing also permits exploring changes in dependency trees. For instance you can ask “Change” to find changes in code that is depended on by, or depends on, a region of code. This helps you know what changes have affected a piece you are working on, or what pieces are affected by what you changed. The classic question is “this function is broke, what changed that affected it”? Semantic differencing answers that question directly.
Q: What kind of snapshots are there?
A: All snapshots contain the same kind of information. But we divide them up into kinds more on how they are made and what you can do with them in Understand 2.0.
There are three kinds:
- Automatic – these are made with the project scheduler (Project->Configure->Schedule). At the same time each day you can tell Understand 2.0 to update, parse and make a snapshot. These are labeled by the name of the day (e.g. Monday, Tuesday, Wednesday, …)
- Scratch – there is only one “scratch” snapshot. You can make it from the current database in a single button click or keystroke. Use it for snapshots you want to have but not long term. For instance, to save a key point, prior to moving ahead.
- Named – these snapshots have a name / date that you set. For instance “B452” or “Before I started messing with the interface”. There can be any number of these.
Q: Hey… I could use this stuff… but how do I make a snapshot?
A: Oh let me count the ways…
- Via button on the Parse Log…

- Via the Change->Make A Snapshot Menu

- Via the Project Scheduler… (Configure from Change->Scheduled Activities dialog)

- Via the command line tool “und”
und -db foo.udb -snapshot “Src-13–Jul-2008”
Q: It does seem easy to make one from source I have in an Understand project now, but what about source versions from before I heard about this?
A: We call these “Historical Snapshots”. Basically, you need to get the old source and make a snapshot out of it. We provide two ways to do this:
- Do it from TrackBack. If you have been using Trackback, getting old source is easy. Just choose “Change->Make a Snapshot->From any point in time” and specify TrackBack and a time:

- Copy or checkout the desired source to an alternate location. Then choose “Make a Snapshot->Named from an Alternate Location”.

For a detailed look at making a snapshot this way see “Tip: Making a Snapshot from an alternate source directory”.
Q: So how do you use snapshots?
A: Well,lets ignore me using them soley for testing of the snapshot function. How do I use them in my “real” day to day work?
I usually need to see what happened since the last build and since yesterday. I sometimes need to see what happened since a special time (usually same day).
I have have automatic snapshot building turned on. I do this with the automatic scheduler. Hence I always have snapshots of the last 7 days readily available.
I also make snapshots of recent builds. I keep the last 3 or 4. I do this manually at the time the build is frozen (I’m involved in the freeze decision). If I forget, I make them with TrackBack.
If somebody tells me they are about to check in something I want to examine. I’ll make a scratch snapshot, update, parse and then quickly compare/see what changed and what the changes were.
I’m a bit more organized than most (my wife may disagree). Many of our engineers use only the Scratch snapshot facility. They “snap a scratch” and they can easily see what has changed since it. When happy with what they are working on, they make another and move along.
Nifty!

Leave a comment