<<

Editors: Andy Hunt and Dave Thomas The Pragmatic Programmers [email protected] [email protected]

Ubiquitous Automation Civilization advances by extending the number of important operations we can perform without thinking. —Alfred North Whitehead

Welcome to our new column on software Many authors and pundits have compelling argu- construction. We hope that you’ll enjoy follow- ments for each of these viewpoints.1–3 This is un- ing this series as we explore the practical nuts- derstandable because all the views have merit— and-bolts issues of building today’s software. is all these things, and this Before we start, though, we need to talk about plurality is what causes so much misunderstand- the column’s title. In some ways, “construction” is ing. When should we act like engineers, and an unfortunate term, in that the most immediate when shouldn’t we? (and often used) example involves building con- Many organizations still view coding as merely struction, with the attendant idea of an initial and a mechanical activity. They take the position that inviolate architecture from which springs forth de- design and architecture are of paramount impor- sign and code. tance and that coding should be a rigorous, re- peatable, mechanistic process that can be rele- gated to inexpensive, inexperienced novices. We wish these organizations the best of luck. We’d like to think we know a better way. The SWEBOK ( Body of Knowl- edge—view an online draft at www.swebok.org), for instance, states unequivocally that coding is far from a mechanistic translation of good design into code, but instead is one of those messy, im- precise human activities that requires creativity, in- sight, and good communication skills. Good soft- ware is grown organically and evolves; it is not Of course, nothing could be further from the built slavishly and rigidly. Design and coding must truth. Software development, including its con- be flexible. We should not unduly constrain it in a struction, is utterly unlike any other human en- misguided attempt to turn coders into robots. deavor. (Software development is also exactly the However, the way we construct software same as all other human endeavors, but that’s a should not be arbitrary. It must be perfectly con- topic for another time.) Software is unique in both sistent, reliable, and repeatable, time after time. its malleability and its ephemerality; it is (to bor- And that’s the topic of this first column. row the title of a Thomas Disch book) the dreams —Andy Hunt and Dave Thomas our stuff is made of. Yet we cannot simply wish a software system into being. We must create it us- ing some semblance of engineering practice. This tension between the nonrepeatable, ill-defined, References 1. P. McBreen, Software Craftsmanship: The New Impera- chaotic creative process and the scientific, repeat- tive, Addison-Wesley, Reading, Mass., 2001. able, well-defined aspects of engineering is what 2. T. Bollinger, “The Interplay of Art and Science in Soft- causes so much heartburn in practitioners, au- ware,” Computer, vol. 30, no. 10, Oct. 1997, pp. 128, 125–126. thors, and scholars. 3. W. Humphrey, Managing the Software Process, Addi- Is software engineering? Is it art? Is it craft? son-Wesley, Reading, Mass., 1989.

0740-7459/02/$17.00 © 2002 IEEE January/February 2002 IEEE SOFTWARE 11 SOFTWAREDEPT CONSTRUCTION TITLE

f software construction is to in- that every developer on a project com- tests to try to find holes in our soft- volve engineering, the process piles his or her software the same way, ware. (There are many other, equally must be consistent and repeat- using the same tools, against the same important, reasons for using unit able. Without consistency, know- set of dependencies. sure this tests, but that’s the subject of another ing how to build, test, or ship compilation process is automated. article.) However, most developers I someone else’s software (or even This advice might seem obvious, we’ve seen skip or at best your own software two years later) is but it’s surprising how often it’s ig- do it in an ad hoc way. The standard hard, if not impossible. Without re- nored. We know teams where some technique goes something like this: peatability, how can you guarantee developers compile using the auto- the results of a build or a test run— matic dependencies calculated by 1. Write a wad of code. how do you know the 100,000 CDs their integrated development environ- 2. Get scared enough about some as- you just burned contain the same ment, others use a second IDE, and pect of it to feel the need to try it. software you think you just tested? still others use command-line build 3. Write some kind of driver that in- The simple answer is discipline: tools. The result? Hours wasted every vokes the code just written. Add a software construction must be disci- week tracking down problems that few print statements to the code plined if it is to succeed. But people aren’t really problems, as each devel- under test to verify it’s doing what don’t seem to come that way; in gen- oper tests against subtly different ex- you thought it should. eral, folks find discipline hard to take ecutables generated by his or her in- 4. Run the test, eyeball the output, and even harder to maintain. Fortu- dividual compilation system. and then delete (or comment out) nately, there’s a pragmatic solution: Nowadays, automated compila- the prints. automate everything you can, so that tions are pretty straightforward. Most 5. Go back to Step 1. the development environment itself IDEs offer a single-key “compile the provides the disciplined consistency project” command. If you’re using Let us be clear. This is not unit test- and repeatability needed to make the Java from the command line, there’s ing. This is appeasing the gods. Why process run smoothly and reliably. the Ant tool (http://jakarta.apache.org/ invest in building tests only to throw This approach leaves developers free ant/index.html). In other environ- them away after you’ve run them to work on the more creative (and ments, the “make” system, or less once? And why rely on simply scan- fun) side of software construction, common variants such as Aegis (www. ning the results when you can have which makes the programmers hap- pcug.org.au/~millerp/aegis/aegis.html), the computer check them for you? pier. At the same time, it makes the do the same job. Whatever the tool, Fortunately, easy-to-use automated accountants happier by creating a de- the ground rules are the same: provide testing frameworks are available for velopment organization that is more a single command that works out most common programming lan- efficient and less prone to costly hu- what needs to be done, does it, and re- guages. A popular choice is the set of man-induced errors and omissions. ports any errors encountered. xUnit frameworks, based on the Gamma/Beck JUnit and SUnit systems Compilation automation Testing automation (www.xprogramming.com/software. If you do nothing else, make sure During construction, we use unit htm). We’ll look at these frameworks

Career Opportunities PURDUE UNIVERSITY compilers, databases, distributed and research. Salary and benefits are highly Department of Computer Sciences parallel computing, geometric modeling competitive. Special departmental and and scientific visualization, graphics, in- university initiatives are available for ju- The Department of Computer Sciences formation security, networking and oper- nior faculty. Candidates should send a at Purdue University invites applications ating systems, programming languages, curriculum vitae, a statement of career for tenure-track positions beginning Au- scientific computing, and software engi- objectives, and names and contact infor- gust 2002. Positions are available at the neering. The department implements a mation of at least three references to: assistant professor level; senior positions strategic plan for future growth which is Chair, Faculty Search Committee will be considered for highly qualified ap- strongly supported by the higher admin- Department of Computer Sciences plicants. Applications from outstanding istration. This plan includes a new build- Purdue University candidates in all areas of computer sci- ing expected to be operational in 2004 to West Lafayette, IN 47907-1398 ence will be considered. Areas of particu- accommodate the significant growth in Applications are being accepted now lar interest include security, networking faculty size. Further information about and will be considered until the positions and distributed systems, scientific com- the department is available at are filled. Inquiries may be sent to puting, and software engineering. http://www.cs.purdue.edu. [email protected]. The Department of Computer Sciences Applicants should hold a Ph.D. in Purdue University is an Equal Opportu- offers a stimulating and nurturing acade- Computer Science, or a closely related nity/Affirmative Action mic environment. Thirty-five faculty discipline, and should be committed to employer. Women and minorities are es- members have research programs in excellence in teaching and have demon- pecially encouraged to apply. analysis of algorithms, bioinformatics, strated strong potential for excellence in

12 IEEE SOFTWARE January/February 2002 SOFTWAREDEPT CONSTRUCTION TITLE in later articles. For now, it’s enough it work when it gets there? Think have no shoes. Often, people who de- to point out that they are simple to about how much of this process you velop software use the poorest tools use, composable (so you can build can automate, allowing the quality to do the job. You can do better than suites of tests), and fully automated. assurance staff to concentrate on the that. Learn how to automate your Remember when we talked about hard stuff. environment—write macros if your making the build environment con- Never underestimate the effort re- IDE supports it; grab your favorite sistent? Well, the same applies to quired to do all this. The cycle times scripting language if it doesn’t (Ruby testing: you need repeatable test envi- of testing the process are large. Every is a good choice; see www.ruby- ronments. However, that’s not to say small problem means starting again, lang.org). Get your computer to do they should all be the same. Test in a compiling and testing and so on. as much of the repetitive and mun- wide variety of situations—some However, there’s a trick: don’t leave dane work as you can. Then you can bizarre, some commonplace. Expose build automation until the end. In- move on to the really hard stuff. See your code to the true range of target stead, make it part of the very first you next issue. environments. Do it as early as possi- project iteration. At this stage it will ble during development. And do it as be simple (if incomplete). Then ar- Andy Hunt and Dave Thomas are partners in The automatically as you can. range for it to run at least daily. This Pragmatic Programmers, LLC. They feel that software consul- Once you can compile code with a has two advantages. First, the build’s tants who can't program shouldn't be consulting, so they keep current by developing complex software systems for their button press, and test it soup-to-nuts, products give your quality assurance clients. They also offer training in modern development tech- what’s next? Integration, reviews, re- folks something to work with: anyone niques to programmers and their management. They are co- lease, perhaps—all fertile ground for can take a build snapshot at any time. authors of The Pragmatic Programmer and Programming Ruby, both from Addison-Wesley, and speak on development practices the seeds of automation. And then Second, you get to find out that the at conferences around the world. Contact them via www. there’s the lowly shipping process. delivery build process failed the day it pragmaticprogrammer.com. Here automation is especially crucial. failed. The fixes will be immediate If you can’t reliably go from source and incremental. in the repository to code on a CD, how do you know what you’re ship- Other uses of automation ping? Every delivery is a stressful sit- We’ve barely scratched this topic’s uation, where each manual step must surface. Consider that you needn’t be completed correctly if the four-bil- restrict automation lion-odd bits on the CD are to be the to the build or even correct ones. Too often, though, to just develop- transferring and replicating com- ment. Perhaps your pleted software is a heavily manual project has strict re- MIT process, one that allows the intro- porting require- duction of all sorts of needless risks. ments, review and SOFTWARE ENGINEERING What this part of the whole process approval processes, FACULTY POSITION needs is an automated delivery build. or other onerous The Aeronautics and Astronautics Department at MIT, a leader in the What is an automated delivery secretarial chores. design and development of complex aircraft, space, transportation, build? At a minimum, it involves Where possible, try information and communications systems, has a faculty opening in the clean-room compilation, automated to automate these Aerospace Information Systems Division. The department seeks candidates for a position in software engineering for aerospace running of the unit tests, automated bits of drudgery as applications, available in September 2002. The successful candidate will running of whatever functional tests well. There’s more have a Ph.D. and relevant SW engineering research credentials in one or can be automated, and automated to constructing more of these areas: requirements specification and analysis, assurance techniques, human-machine interaction, for collection of the deliverable compo- software than just embedded systems, safety, reliability and other quality attributes, nents (not forgetting documentation) constructing soft- software fault tolerance, or real-time application issues like scheduling into some staging area. (Speaking of ware, and we can and verification. A joint professorship with Computer Science is possible. documentation, how much do you leverage automa- MIT encourages women and underrepresented minorities to apply. Send two copies of cover letter (which includes a statement of interest) and of currently produce automatically? How tion throughout the your c.v. with the names and addresses of three individuals who will much could you? After all, the more process. provide letters of recommendation, by January 15, 2002, to: Professor documentation you automate, the Edward F. Crawley, Head, MIT Department of Aeronautics and Astronautics, 33-207, 77 Massachusetts Avenue, Cambridge, MA more likely it will be up-to-date.) The cobbler’s 02139-4307; or by electronic mail to: [email protected] (MS Word or Once you’ve generated your ship- children plain text). http://web.mit.edu/aeroastro/www/core/html pable software, take it to the next As we said in level, and automate the testing of the The Pragmatic Pro- MASSACHUSETTS INSTITUTE OF TECHNOLOGY An Equal Opportunity/Affirmative Action Employer result. Can the pile of bits you’re grammer (Addison- Non-Smoking Environment proposing to deliver be installed in Wesley, 2000), the web.mit.edu/personnel/www typical customer environments? Does cobbler’s children

January/February 2002 IEEE SOFTWARE 13