Coder to Developer: Tools and Strategies for Delivering Your Software

 < Day Day Up > 


There are many ways to tell whether a software project is in trouble, but here’s a three-question pop quiz on the subject:

  1. Can you, right now, produce a fresh copy of the application and all of the surrounding artifacts (such as documentation or data files), starting from source code?

  2. Can you reproduce the application and all of the surrounding artifacts as they were on this day last week?

  3. Can you go get a cup of coffee while all this is happening automatically?

If the answer to any of these questions is “no,” then your build process could use some work.

The Big Picture

Just building your application is easy: Decide whether you want a debug or a release build, and then select Build Solution or Rebuild Solution from the Build menu in Visual Studio .NET (VS .NET).

Tip

The Build menu item rebuilds only the components that have changed since the last build; the Rebuild menu item cleans out all of the intermediate files and rebuilds everything from scratch. In theory, you should always be able to use Build after the first time. In practice, life tends not to be so simple. When you’ve made major code changes, or when strange errors start cropping up, or when VS .NET fails trying to rebuild the project, switch back to Build for your next run. I tend to do a full build the first time I build a project each day as well.

But the simple approach is not sufficient for a project of any reasonable size. That’s because manually building just the code when you think about it doesn’t account for all of the other tasks that are involved in turning out the final package. If you’re working with other developers, for example, you need to remember to get the latest pieces from your source code control system before building. You might also have unit tests to run through, documentation to update, and so on.

The problem with attempting to put all the pieces together by hand is that people tend to forget things. When you’re trying to pull together a product, forgetting things can vary from being a nuisance (forgetting to run the unit tests before you check in code that breaks someone else’s work) to becoming a full-fledged disaster (shipping an old version of the help file to customers with the released product). That’s why you should be using an automated build tool for any project.

I’ll look at a number of build tools in this chapter, but they’re all designed to bring two main benefits to developers:

But there’s more to using a build tool than just producing reliable builds easily. Once you have your build process under control, you can proceed to implement a daily build routine. Actually, it doesn’t so much matter whether your daily builds are done daily, twice a day, or once every two days. What’s important is that you have a regular schedule for building your software from scratch.

It seems obvious when you think about it, but in order to actually ship a product, you’re going to need a perfect build, where everything works just the way it’s supposed to: no errors in compilation, no failing tests, no missing files. The best way to get to the point of being able to produce such a perfect build is to produce a perfect build (or as close as you can get) every day. The ritual of building serves as a bit of clockwork for the project, a way to ensure that you’re constantly moving forward. It also affords you a quick check on the quality of your work: If the daily build fails to finish, something is seriously wrong.

Teams that build high-quality software take the daily build routine seriously indeed. On major Microsoft products, for example, “breaking the build” is such a serious issue that any developer who’s responsible is liable to be the one who has to stay late to fix things. While you may not want to make yourself stay late when you’re a team of one, implementing daily builds will still help you keep in mind that the goal is to ship software, not just to write code.

RULE

If the daily build fails, fix it before you do anything else.

Tasks for Daily Builds

When you’re ready to choose a build tool and set up a build process, the first step is to figure out just what it is that you want to automate. Different projects will have different needs, but in general, the more you can do automatically the better. Here’s a selection of tasks I’ve done as part of daily builds on various projects:

Not all build tools can handle all of these tasks, of course. When you’re evaluating build tools, one thing to consider is how much of your process a particular tool can handle.


 < Day Day Up > 

Категории