Track Changes Until You Throw Away the Project


Version control and bug tracking systems are two of the most important infrastructure tools you have because they give you the history of your project. Although the developers might say that they can keep everything in their heads, the company needs to have some record of what's been accomplished on the project in case the entire development team wins the lottery and everyone quits the next day. Because most teams don't adequately maintain their requirements and design documents throughout the life of a project, the only real documentation becomes the audit trail in the version control and bug tracking systems.

I hope I'm preaching to the converted. Unfortunately, I keep running into teams that haven't yet started using these tools, especially bug tracking systems. As someone interested in history, I feel that you have to know where you've been to know where you're going. Putting these two types of tools to use is the only sure way to learn that lesson. By monitoring the outstanding bugs and bug fix rates in the bug tracking system, you can better predict when your product will be ready to ship. With the version control system, you'll get an idea of your "code churn," or the volume of changes, so that you can see how much additional testing needs to be done. Additionally, these tools are the only effective way to judge whether you're getting any results from changes you implement in your development cycle.

When you bring a new developer to your team, these tools can pay for themselves in a single day. When the new developer starts, have her sit down with the version control and bug tracking software and begin working her way through the changes. Good design documents are ideal, but if they aren't available, the version control and bug tracking systems at least provide a record of the code evolution and highlight any trouble areas.

I'm talking about these two tools in the same breath because they are inseparable. The bug tracking system captures all the events that might have driven changes to your master sources. The version control system captures every change. Ideally, you want to maintain the relationship between reported problems and actual changes in the master sources. By correlating the relationship, you can see your cause and effect for bug fixes. If you don't track the relationship, you're left wondering why certain changes to the code occurred. Invariably, in later versions of the product, you have to find the developer who made the change and hope he remembers the reason for the change.

Some products are integrated and automatically track the relationship of the master source change to the bug report, but if your current systems don't, you'll need to maintain the relationship manually. You can track the relationship by including the bug number in the comments that describe the fix. When you check the file back into version control, you'll need to identify the bug number you're fixing in the check-in comment for the file. Also, in the bug tracking system, you should identify the version of the file the fix for the bug was in. That way you can complete correlation between the two variables: the bug item and the source file.

Version Control Systems

The version control system isn't just for your project's master sources. Anything and everything related to the projectincluding all test plans, automated tests, the help system, and design documentsneeds to go into the version control system. Some companies even include the build tools (that is, the compiler, linker, include files, and libraries), which allow them to completely re-create the shipped version of their products. If you have any question about whether something should go in version control, ask yourself whether maintenance programmers could use the information in a couple of years. If you think they could, that information belongs in the version control system.

A version control system can easily tell you what changed, but knowing the reason for the change is the key. Whenever you check in a source file, you need to have a clear, lucid explanation of what and why you were changing the source file. We've all seen the check-in comment that says Fixed a bug somewhere in our careers. It makes you want to contemplate inflicting serious bodily harm to the developer because there's no information there. As a product manager, I will go through the check-in comments and immediately apply counseling to anyone who's not writing clear enough check-in comments. Those comments are as important as the source code.

The Importance of Including Unit Tests

Even though I just said to check in everything that could be of use, one of the biggest problems I've seen in development shop after development shop is not including the unit tests in the version control system. In case you're not familiar with the term unit test, I'll briefly describe it here: A unit test is the piece of code that drives portions of your main program code. (It's sometimes also referred to as test apps or test harness.) It's the testing code created by the developer that allows the developer to do glass box, or white box, testing to ensure that the basic operations take place. For a complete definition of unit tests, see Chapter 22, "Developer Testing," of Steve McConnell's book Code Complete, 2nd Edition (Microsoft Press, 2004).

Including the unit tests in version control accomplishes two key objectives. First, you make the job of maintenance developers infinitely easier. So many times, the maintenance developer, who could easily turn out to be you, has to reinvent the wheel when upgrading or fixing the code. Doing so is not only a huge waste of effort but is also a real morale killer. Second, you make general testing for QA teams trivial so that those teams can focus on the important testing areas, such as performance and scalability, in addition to fit and finish. One sign of a seasoned professional is that she always has her unit tests checked in.

Of course, checking in your unit tests requires you to keep them up to date with code changes. Yes, that's going to be additional work on your behalf. Nothing is worse than having a maintenance developer tracking you down and screaming at you because the unit tests no longer work. Having outdated unit tests is worse than having no unit tests in the version control system.

If you look at the source code for this book, you'll notice that all my unit tests are included as part of the code. In fact, my builds build all unit tests at the same time. I'm not about to recommend anything in this book that I don't do myself.

Some readers might be thinking that implementing the unit test discipline I advocate is going to take a lot more work. In reality, it's not going to take that much longer because most developers (I hope!) are already conducting unit tests, especially now that the testing tools are built into Microsoft Visual Studio Team Editions. The big differences I'm suggesting are keeping those tests based on a well-known framework checked in and up to date in addition to building them. The time you'll save by following the proper procedures will be huge. For example, for most of this book, I did my development on a machine with Microsoft Windows XP Professional x64 Edition installed. To turn around and do immediate testing on my computers running Microsoft Windows Server 2003 or Windows Vista, I simply had to get the code from version control and do the build scripts. Many developers do a one-off unit test, so testing on other operating systems is difficult because they have no easy way to get the unit tests over to the other machines and have them built and executed. If everyone is making unit tests part of the code, you can shave many weeks off your schedules.

Controlling Changes

Tracking changes is vital; however, having a good bug tracking system in place doesn't mean that developers should be allowed to make wholesale changes to the master sources whenever they want. Such freedom would make all the tracking pointless. The idea is to control the changes during development, restricting certain types of changes to certain stages of the project so that you can have an idea of the state of the master sources on a day-to-day basis. The best scheme I've heard of for controlling changes comes from my friend Steve Munyan, and he calls it "Green, Yellow, and Red Times." In Green Time, anyone can check in anything to the master sources. The earliest parts of the project are usually fully in Green Time because at this point, the team is working on new features.

Yellow Time is when the product is in a bug fix phase or nearing a code freeze. The only code changes allowed are for bug fixesand only bug fixes. No new features or other changes are permitted. Before a developer can check in a bug fix, a technical lead or a development manager must approve it. The developer making the bug fix must describe the bug fix he's making and what section of code it affects. In essence, this process is a mini-code review for every single bug fix. The important item to remember when conducting that code review is to utilize the version control product's differencing utility to ensure exactly which changes occurred so that extraneous changes don't sneak in. On some teams I've been on, the product was in Yellow Time from day one because the team liked the code review aspects of this stage. We did loosen the approval requirements so that any other developer could approve changes. The interesting outcome was that because of the constant code reviews, the developers caught many bugs before they checked the code into the master sources.

Red Time occurs when you're in a code freeze or near a key milestone and all code changes require the product manager's approval. When I am a product manager (the person on the team responsible for the code as a whole), I go to the extent of changing the permissions in the version control system so that the team has read-only access. I take this step mainly because I understand what the developers are almost certainly thinking: "This is just a little change; it will fix this bug, and it won't hurt anything else." The developers' intentions were good, but that one little change could mean that the entire team would have to restart the test plan from the beginning.

The product manager must strictly enforce Red Time. If the product has a reproducible crash or data corruption, the decision to make the change is essentially automatic because you just do it. In most cases, however, deciding whether to fix a particular bug is less black and white. To help me decide how critical a bug fix is, I always ask the following questions with the company's needs in mind:

  • How many people does this problem affect?

  • Is the change in a core or a peripheral part of the product?

  • If the change is made, what parts of the application will need to be retested?

The answers to these questions provide the criteria I need to allow or disallow the change. Let me put some concrete numbers behind this list and give you my general rules for the beta phases: If the bug is serious, such as a painting or drawing problem, but not a case of a crash or data corruption showstopper, and it's going to affect greater than 15 percent of our external testers, the bug must be fixed. If the bug will result in a change to a data file, I go ahead and fix it so that we don't have to change file formats later in the development process and so that beta testers can consequently get larger data sets for subsequent betas.

The Importance of Labeling

One of the most important commands that you can learn to use in your version control system is its label command. Microsoft Visual SourceSafe and SourceGear's Vault call it a label, and Visual Studio Team Foundation calls it a changeset. Different version control systems might refer to the label command in different ways, but whatever it's called, a label marks a particular set of master sources. A label allows you to retrieve a specific version of your master sources in the future. If you make a labeling mistake, you might never be able to retrieve the exact master sources used for a particular version. That could mean that you might not be able to discover why a particular version is crashing.

When deciding what to label, I've always followed these five hard-and-fast rules:

  • Label all internal milestones.

  • Label any transitions from Green, Yellow, or Red development times.

  • Label any build sent to someone outside the team.

  • Label any time you branch a development tree in the version control software.

  • Label after the daily build and smoke tests complete successfully. (Smoke tests are discussed in the "Smoke Tests" section later in this chapter.)

In all cases, I follow a scheme of <Project Name> <Milestone/Reason> <Date> so that the label names are descriptive.

The third labeling rule is one that many people forget. Your quality engineers are usually working with the milestone or daily build, so when they report a problem, they do so against a particular version of the master sources. Because developers can change code quickly, you want to make it simple for them to get back to the exact version of the files they need to reproduce the bug, and next, to ensure that it is fixed in a clear versioned build that quality engineers can identify.

Bug Tracking Systems

In addition to tracking your bugs, the bug tracking system makes an excellent vehicle for jotting down reminders and keeping a to-do list, especially when you're in the process of developing code. Some developers like to keep notes and to-do lists in notebooks, but essential information often gets lost between random hexadecimal number streams from a debugging session and the pages and pages of doodling that you used to keep yourself awake in the last management status meeting. By putting these notes into the bug tracking system and assigning them to yourself, you consolidate them in one place, making them easier to find. Additionally, although you probably like to think that you own the code you work on, you really don'tit belongs to the team and on a larger scale to the company. With your to-do list in the bug tracking system, other team members who have to work with your code can check your list to see what you have or haven't done. Another benefit of including to-do lists and notes in the bug tracking system is that fewer details fall through the cracks at the last minute as a result of your forgetting about a problem or because of another issue. I always find myself running the bug tracking system so that I can quickly jot down important notes and tasks to perform right when I think about them.

I like to reserve the lowest priority bug code in the system for notes and to-do lists. Flagging notes and to-do lists as lowest-priority bugs makes it easier to keep them separate from the real bugs, but at the same time, you can quickly raise their priority if you need to. You should also structure your bug metrics reports so that they don't include the lowest-priority bug code because it will skew your results.

Don't be afraid to peruse the bug tracking data either. All the unvarnished truths about your products are there. When you're planning an update, run through the bug tracking system, and find those modules or features that had the most bugs reported against them. Consider adding some time in your schedule to allow team members to go back and strengthen those sections.

When deploying your bug tracking system, make sure that everyone who needs it has it. At a minimum, everyone on the development team and the technical support team needs access to it. If your bug tracking system supports different levels of access, you might also want to think about allowing others, such as sales engineers (technical experts who are part of the sales organization and help the salespeople as needed when they're selling a complicated product) and marketing representatives, to have access as appropriate. For example, you might want to allow certain sales and marketing people to enter bugs and feature requests but not to view existing bugs. These two groups are generally out talking to customers more than your typical engineers are, and the customer feedback they can supply can be invaluable. Of course, this means that you're going to have to give sales and marketing folks classes on how to fill out bug reports. They're more than happy to help, but you need to give them the guidance so that they can do it properly. Having these groups log their feature requests and bug reports in the same system that everyone else uses is efficient and practical. The idea is to have one central place where all problems and feature requests reside. If you store this information in multiple locations, such as in the product manager's e-mail inbox, in engineers' paper notebooks, and in the bug tracking system, you're more likely to lose track of it.

Choosing the Right Systems for You

Numerous version control systems are available. Some might be easier to use than others or offer more features, but the real issue in choosing the best version control system comes down to your specific requirements. Obviously, if you're in a shop that has high-end requirements, such as multiple platform support, you're going to need to look at one of the commercial systems, such as Perforce, or possibly an open source solution, such as CVS or Subversion. If you're a small team targeting just Windows development, however, you can consider some of the Windows-only products, such as Team Foundation System or SourceGear's SourceVault. Make sure that you spend some time doing some hard evaluation of the system you're thinking about implementing, especially in trying to predict what you'll need in the future. You're going to be living with your version control system for a while, so make sure it will grow with you. And keep in mind that just as important as choosing the right version control system is using a version control system in the first place; any system is better than no system.

As for bug tracking systems, I've seen many people try to limp along with a homegrown system. Although doing a project with a homemade system is possible, I strongly recommend investing in a commercial product or utilizing an open source solution. The information in the bug tracking system is too vital to put into an application that you don't have the time to support and that can't grow to meet your needs six months or a year into the project. Additionally, developers avoid wasting time on internal tools and work instead on revenue-producing products. If you work at a company where the managers won't consider a commercial system, there are some excellent open source bug tracking systems. I've seen numerous companies have great luck with Bugzilla (http://www.bugzilla.org/).

The same criteria apply for choosing a bug tracking system as for choosing a version control system. Once, as a product manager, I decided on a bug tracking system without spending enough time looking at the most important part, reporting bugs. The product was easy enough to set up and use. Unfortunately, its reporting capabilities were so limited that we ended up transferring all our existing bugs to another product right after we hit our first external code milestone. I was rather embarrassed for not having evaluated the product as thoroughly as I should have.

As I mentioned earlier in the chapter, you should definitely consider a bug tracking product that offers integration with a version control product. In the Windows marketplace, most version control systems support the Microsoft Source Code Control Interface (MSSCCI). If your bug tracking system also supports MSSCCI, you can coordinate the bug fixes with particular file versions.

Some people have described code as the lifeblood of a development team. If that description is accurate, the version control and bug tracking systems are the arteries. They keep the lifeblood flowing and moving in the right direction. Don't develop without them.




Debugging Microsoft  .NET 2.0 Applications
Debugging Microsoft .NET 2.0 Applications
ISBN: 0735622027
EAN: 2147483647
Year: 2006
Pages: 99
Authors: John Robbins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net