Advances
in COMPUTERS VOLUME 56
This Page Intentionally Left Blank
Advances in
COMPUTERS EDITED BY
MARVIN V. ZELKOWITZ Department of Computer Science and Institute for Advanced Computer Studies University of Maryland College Park, Maryland
VOLUME 56
ACADEMIC PRESS An imprint of Elsevier Science Amsterdam Boston London New York Oxford Paris San Diego San Francisco Singapore Sydney Tokyo
This book is printed on acid-free paper. Copyright © 2002, Elsevier Science (USA) Except Chapter 5 All rights reserved. No part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopy, recording, or any information storage and retrieval system, without permission in writing from the publisher. The appearance of the code at the bottom of the first page of a chapter in this book indicates the Publisher's consent that copies of the chapter may be made for personal or internal use of specific clients. This consent is given on the condition, however, that the copier pay the stated per copy fee through the Copyright Clearance Center, Inc. (222 Rosewood Drive, Danvers, Massachusetts 01923), for copying beyond that permitted by Sections 107 or 108 of the U.S. Copyright Law. This consent does not extend to other kinds of copying, such as copying for general distribution, for advertising or promotional purposes, for creating new collective works, or for resale. Copy fees for pre-2002 chapters are as shown on the title pages. If no fee code appears on the title page, the copy fee is the same as for current chapters. ISSN#/2002 $35.00. Explicit permission from Academic Press is not required to reproduce a maximum of two figures or tables from an Academic Press chapter in another scientific or research publication provided that the material has not been credited to another source and that full credit to the Academic Press chapter is given. Academic Press An imprint of Elsevier Science 84 Theobald's Road, London WCIX 8RR http://www.academicpress.com Academic Press An imprint of Elsevier Science 525 B Street, Suite 1900, San Diego, California 92101-4495, USA http://www.academicpress.com ISBN 0-12-012156-5 A catalogue record for this book is available from the British Library Typeset by Devi Information Systems, Chennai, India Printed and bound in Great Britain by MPG Books Ltd, Bodmin, Cornwall 02 03 04 05 06 07 MP 9 8 7 6 5 4 3 2 1
Contents CONTRIBUTORS PREFACE
ix xiii
Software Evolution and the Staged Model of the Software Lifecycle Keith H. Bennett, Vaclav T. Rajlich, and Norman Wilde
1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
Introduction Initial Development Evolution—The Key Stage Servicing Phase-Out and Closedown Case Studies Software Change and Comprehension Sustaining Software Value Future Directions: Ultra Rapid Software Evolution Conclusions Acknowledgments References
3 13 16 19 23 24 31 38 44 47 47 48
Embedded Software Edward A. Lee
1. What is Embedded Software? 2. Just Software on Small Computers? 3. Limitations of Prevailing Software Engineering Methods 4. Actor-Oriented Design 5. Examples of Models of Computation 6. Choosing a Model of Computation 7. Heterogeneous Models 8. Component Interfaces 9. Frameworks Supporting Models of Computation 10. Conclusions V
56 57 62 65 71 79 82 84 88 89
VI
CONTENTS
Acknowledgments References
89 90
Empirical Studies of Quality Models in Object-Oriented Systems Lionel C. Briand and Jurgen Wust
1. 2. 3. 4. 5.
Introduction Overview of Existing Studies Data Analysis Methodology Summary of Results Conclusions Appendix A Appendix B: Glossary References
98 99 112 131 150 157 161 162
Software Fault Prevention by Language Choice: Why C Is Not My Favorite Language Richard J. Fateman
1. 2. 3. 4. 5. 6. 7.
Introduction and Background Why Use C? Why does Lisp Differ from C? Root Causes of Flaws: A Lisp Perspective Arguments against Lisp, and Responses But Why Is C Used by Lisp Implementors? Conclusion Appendix 1: Cost of Garbage Collection Appendix 2: Isn't C Free? Acknowledgments and Disclaimers References
168 169 171 173 179 185 185 186 187 187 188
Quantum Computing and Communication Paul E. Black, D. Richard Kuhn, and Carl J. Williams
1. 2. 3. 4.
Introduction The Surprising Quantum World The Mathematics of Quantum Mechanics Quantum Computing
190 192 202 207
CONTENTS
5. Quantum Communication and Cryptography 6. Physical Implementations 7. Conclusions Appendix References
VII
220 231 240 240 242
Exception Handling Peter A. Buhr, Ashif Harji, and W. Y. Russell Mok
1. Introduction 2. EHM Objectives 3. Execution Environment 4. EHM Overview 5. Handling Models 6. EHM Features 7. Handler Context 8. Propagation Models 9. Propagation Mechanisms 10. Exception Partitioning 11. Matching 12. Handler Clause Selection 13. Preventing Recursive Resuming 14. Multiple Executions and Threads 15. Asynchronous Exception Events 16. Conclusions Appendix: Glossary References
246 248 249 253 254 263 272 273 277 280 282 283 285 290 292 297 298 301
Breaking the Robustness Barrier: Recent Progress on the Design of the Robust Multimodal System Sharon Oviatt
1. 2. 3. 4.
Introduction to Multimodal Systems Robustness Issues in the Design of Recognition-Based Systems Future Directions: Breaking the Robustness Barrier Conclusion Acknowledgments References
306 313 331 333 333 333
VIII
CONTENTS
Using Data Mining to Discover the Preferences of Computer Criminals Donald E. Brown, and Louise F. Gunderson
1. 2. 3. 4. 5. 6. 7.
Introduction The Target Selection Process of Criminals Predictive Modeling of Crime Discovering the Preferences of the Agents Methodology Testing with Synthetic Data Conclusions References
344 346 348 352 358 364 369 370
AUTHOR INDEX
375
SUBJECT INDEX
385
CONTENTS OF VOLUMES IN THIS SERIES
395
Contributors Keith H. Bennett is a full professor and former chair in the Department of Computer Science at the University of Durham. His research interests include new software architectures that support evolution. Bennett received a Ph.D. in computer science from the University of Manchester. He is a chartered engineer and a Fellow of the British Computer Society and lEE. Contact him at k e i t h . bennett Odurham.ac.uk. Paul E. Black is a computer scientist in the Information Technology Laboratory of the National Institute of Standards and Technology (NIST). He has published papers on software configuration control, networks and queuing analysis, formal methods, testing, and software verification. He has nearly 20 years of industrial experience in developing software for IC design and verification, assuring software quality, and managing business data processing. Black earned an M.S. in Computer Science from the University of Utah, and a Ph.D. from Brigham Young University. Lionel C. Briand is a professor with the Department of Systems and Computer Engineering, Carleton University, Ottawa, Canada, where he founded the Software Quality Engineering Laboratory ( h t t p : / / w w w . s c e . c a r l e t o n . c a / Squall/Squall.htm). Lionel has been on the program, steering, and organization committees of many international, IEEE conferences and the editorial boards of several scientific journals. His research interests include object-oriented analysis and design, inspections and testing in the context of object-oriented development, quality assurance and control, project planning and risk analysis, and technology evaluation. Donald Brown is a Professor and Chair of the Department of Systems Engineering, University of Virginia. Prior to joining the University of Virginia, Dr. Brown served as an officer in the U.S. Army and later worked at Vector Research, Inc. on projects in medical information processing and multisensor surveillance systems. He is currently a Fellow at the National Institute of Justice Crime Mapping Research Center. Dr. Brown is a Fellow of the IEEE and a past President of the IEEE Systems, Man, and Cybernetics Society. He is the recipient of the Outstanding Contribution Award from that society and the IEEE Millennium Medal. He is also a past Chairman of the Operations Research Society of America
ix
X
CONTRIBUTORS
Technical Section on Artificial Intelligence, and he is the recipient of the Outstanding Service Award from that society. Dr. Brown received his B.S. degree from the U.S. Military Academy, West Point, M.S. and M.Eng. degrees in operations research from the University of California—Berkeley, and a Ph.D. degree in industrial and operations engineering from the University of Michigan—Ann Arbor. His research focuses on data fusion, decision support, and predictive modeling with applications to security and safety. His email address is brown ©Virginia.edu. Peter A. Buhr received B.Sc. Hons/M.Sc. and Ph.D. degrees in computer science from the University of Manitoba in 1976, 1978, and 1985, respectively. He is currently an Associate Professor in the Department of Computer Science, University of Waterloo, Canada. His research interests include concurrency, concurrent profiling/debugging, persistence, and polymorphism. He is the principal designer and implementer for the //System project, thread library for C, the //C-I-+ project, extending C-h-1- with threads, and the MVD project, a collection of software tools to monitor, visuaUze, and debug concurrent //C-h+ programs. Dr. Buhr is a member of the Association for Computing Machinery. Richard J. Fateman received a B.S. degree in physics and mathematics from Union College, Schenectady, NY, and a Ph.D. degree in applied mathematics from Harvard University, Cambridge, MA, in 1966 and 1971, respectively. From 1971 to 1974 he taught in the Department of Mathematics at the Massachusetts Institute of Technology, where he also participated in research on symbolic computation and the Macsyma system. Since 1974 he has been at the University of California at Berkeley where he served as Associate Chair for Computer Science of the Department of Electrical Engineering and Computer Sciences from 1987 to 1990. His research interests include the design and analysis of symbolic mathematical algorithms and systems, implementation of programming languages, and the design of computer environments for scientific programming. He has also done research and teaching in document image analysis. Further details may be found at http://www.cs.berkeley.edu/~fateman. Louise Gunderson is a research assistant in the Department of Systems Engineering, University of Virginia. Prior to joining the University of Virginia, Ms. Gunderson worked for the U.S. Environmental Protection Agency as an Enforcement Specialist. Ms. Gunderson received a B.A. degree in chemistry from the University of California—Berkeley, a B.A. degree in biology from the University of Colorado—Denver, and an M.S. degree in environmental science from the University of Colorado—Denver. She is currendy a Ph.D. candidate in the Department of Systems Engineering, University of Virginia. Her interests involve the
CONTRIBUTORS
XI
modeling and simulation of natural and artificial systems. Her email address is
[email protected]. Ashif Harji received BMath and MMath degrees in computer science from the University of Waterloo in 1997 and 1999, respectively. He is currently a Ph.D. student at the University of Waterloo, Waterloo, Canada. His research interests include concurrency, real-time, scheduling, and number theory. D. Richard Kuhn is a computer scientist in the Information Technology Laboratory of the National Institute of Standards and Technology (NIST). His primary technical interests are in software testing and assurance, and information security. Before joining NIST in 1984, he worked as a systems analyst with NCR Corporation and the Johns Hopkins University Applied Physics Laboratory. He received an M.S. in computer science from the University of Maryland at College Park, and an M.B.A. from the College of William and Mary. Edward A. Lee is a Professor in the Electrical Engineering and Computer Science Department at University of California—Berkeley. His research interests center on design, modeling, and simulation of embedded, real-time computational systems. He is director of the Ptolemy project at UC—Berkeley. He is co-author of four books and numerous papers. His B.S. is from Yale University (1979), his M.S. from MIT (1981), and his Ph.D. from UC—Berkeley (1986). From 1979 to 1982 he was a member of technical staff at Bell Telephone Laboratories in Holmdel, NJ, in the Advanced Data Communications Laboratory. He is a cofounder of BDTI, Inc., where he is currently a Senior Technical Advisor, is cofounder of Agile Design, Inc., and has consulted for a number of other companies. He is a Fellow of the IEEE, was an NSF Presidential Young Investigator, and won the 1997 Frederick Emmons Terman Award for Engineering Education. W.Y. Russell Mok received the BCompSc and MMath degrees in computer science from Concordia University (Montreal) in 1994 and University of Waterloo in 1998, respectively. He is currently working at Algorithmics, Toronto. His research interests include object-oriented design, software patterns, and software engineering. Sharon Oviatt is a Professor and Co-Director of the Center for Human-Computer Communication (CHCC) in the Department of Computer Science at Oregon Health and Sciences University. Previously she has taught and conducted research at the Artificial Intelligence Center at SRI International, and the Universities of Illinois, California, and Oregon State. Her research focuses on human-computer interaction, spoken language and multimodal interfaces, and mobile and highly interactive systems. Examples of recent work involve the development of novel design
XII
CONTRIBUTORS
concepts for multimodal and mobile interfaces, robust interfaces for real-world field environments and diverse users (children, accented speakers), and conversational interfaces with animated software "partners." This work is funded by grants and contracts from the National Science Foundation, DARPA, ONR, and corporate sources such as Intel, Motorola, Microsoft, and Boeing. She is an active member of the international HCI and speech communities, has published over 70 scientific articles, and has served on numerous government advisory panels, editorial boards, and program committees. Her work is featured in recent special issues of Communications for the ACM, Human-Computer Interaction, and IEEE Multimedia. Further information about Dr. Oviatt and CHCC is available at h t t p : / / www.cse.ogi.edu/CHCC. Vaclav T. Rajlich is a full professor and former chair in the Department of Computer Science at Wayne State University. His research interests include software change, evolution, comprehension, and maintenance. Rajlich received a Ph.D. in mathematics from Case Western Reserve University. Contact him at rajlich® wayne.edu. Norman Wilde is a full professor of computer science at the University of West Florida. His research interests include software maintenance and comprehension. Wilde received a Ph.D. in mathematics and operations research from the Massachusetts Institute of Technology. Contact him at nwilde^uwf . edu. Carl J. Williams is a research physicist in the Quantum Processes Group, Atomic Physics Division, Physics Laboratory of the National Institute of Standards and Technology (NIST). Before joining NIST in 1998, he worked as a systems analyst for the Institute of Defense Analyses and was a research scientist studying atomic and molecular scattering and molecular photodissociation at the James Franck Institute of the University of Chicago. He is an expert in the theory of ultra-cold atomic collisions, does research on the physics of quantum information processors, and coordinates quantum information activities at NIST. Williams received his Ph.D. from the University of Chicago in 1987. Jiirgen Wiist received the degree Dipkrm-Informatiker (M.S.) in computer science from the University of Kaiserslaulern, Germany, in 1997. He is currently a researcher at the Fraunhofer Institute for Experimental Software Engineering (lESE) in Kaiserslautern, Germany. His research activities and industrial activities include software measurement, software product evaluation, and objectoriented development techniques.
Preface
Advances in Computers, continually published since 1960, is the oldest series still in publication to provide an annual update to the rapidly changing information technology scene. Each volume provides six to eight chapters describing how the software, hardware, or applications of computers is changing. In this volume, the 56th in the series, eight chapters describe many of the new technologies that are changing the use of computers during the early part of the 21st century. In Chapter 1, "Software Evolution and the Staged Model of the Software Lifecycle" by K. H. Bennett, V. T. Rajlich, and N. Wilde, the authors describe a new view of software maintenance. It is well known that maintenance consumes a major part of the total lifecycle budget for a product; yet maintenance is usually considered an "end game" component of development. In this chapter, the authors view software maintenance as consisting of a number of stages, some of which can start during initial development. This provides a very different perspective on the lifecycle. The chapter introduces a new model of the lifecycle that partitions the conventional maintenance phase in a much more useful, relevant, and constructive way. Chapter 2, "Embedded Software" by E. A. Lee, explains why embedded software is not just software on small computers, and why it therefore needs fundamentally new views of computation. Time, concurrency, liveness, robustness, continuums, reactivity, and resource management are all functions that are part of the computation of a program; yet prevailing abstractions of programs leave out these "nonfunctional" aspects. This chapter explains why embedded software is not just software on small computers, and why it therefore needs fundamentally new views of computation. Object-oriented system design is a current approach toward developing quality systems. However, how do we measure the quality of such systems? In order to measure a program's quality, quality models that quantitatively describe how internal structural properties relate to relevant external system qualities, such as reliability or maintainability, are needed. In Chapter 3, "Empirical Studies of Quality Models in Object-Oriented Systems" by L. C. Briand and J. Wiist, the authors summarize the empirical results that have been reported so far with modeling external system quality based on structural design properties. They perform a critical review of existing work in order to identify lessons learned regarding the way these studies are performed and reported.
xiii
XIV
PREFACE
Chapter 4, "Software Fault Prevention by Language Choice: Why C is Not My Favorite Language" by R. Fateman, presents an opposing view of the prevaihng sentiment in much of the software engineering world. Much of software design today is based on object-oriented architecture using C-I-+ or Java as the implementation language. Both languages are derived from the C language. However, is C an appropriate base in which to write programs? Dr. Fateman argues that it is not and that a LISP structure is superior. How fast can computers ultimately get? As this is being written, a clock speed of around 2 GHz is available. This speed seems to double about every 18 months ("Moore's Law"). However, are we reaching the limits on the underlying "silicon" structure the modem processor uses? One of the more exciting theoretical developments today is the concept of quantum computing, using the quantum states of atoms to create extremely fast computers, but quantum effects are extremely fragile. How can we create reliable machines using these effects? In "Quantum Computing and Communication" by P. E. Black, D. R. Kuhn, and C. J. WiUiams, the authors describe the history of quantum computing, and describe its applicability to solving modern problems. In particular, quantum computing looks like it has a home in modern cryptography, the ability to encode information so that some may not decipher its contents or so that other codebreakers may decipher its contents. In Chapter 6, "Exception Handling" by P. A. Buhr, A. Harji, and W. Y. R. Mok, the authors describe the current status of exception handling mechanisms in modem languages. Exception handling in languages like PL/I (e.g., the Oncondition) and C (e.g., the Throw statement) can be viewed as add-on features. The authors argue it is no longer possible to consider exception handling as a secondary issue in a language's design. Exception handling is a primary feature in language design and must be integrated with other major features, including advanced control flow, objects, coroutines, concurrency, real-time, and polymorphism. In Chapter 7, "Breaking the Robustness Barrier: Recent Progress on the Design of the Robust Multimodal Systems" by S. Oviatt, goes into the application of applying multimodal systems, two or more combined user input modes, in user interface design. Multimodal interfaces have developed rapidly during the past decade. This chapter specifically addresses the central performance issue of multimodal system design techniques for optimizing robustness. It reviews recent demonstrations of multimodal system robustness that surpass that of unimodal recognition systems, and also discusses future directions for optimizing robustness further through the design of advanced multimodal systems. The final chapter, "Using Data Mining to Discover the Preferences of Computer Criminals" by D. E. Brown and L. F. Gunderson, discusses the ability to predict a
PREFACE
XV
new class of crime, the "cyber crime." With our increased dependence on global networks of computers, criminals are increasingly "hi-tech." The ability to detect illegal intrusion in a computer system makes it possible for law enforcement to both protect potential victims and apprehend perpetrators. However, warnings must be as specific as possible, so that systems that are not likely to be under attack do not shut off necessary services to their users. This chapter discusses a methodology for data-mining the output from intrusion detection systems to discover the preferences of attackers. I hope that you find these articles of interest. If you have any suggestions for future chapters, I can be reached at mvzOcs. umd. edu. MARVIN ZELKOWITZ
College Park, Maryland
This Page Intentionally Left Blank
Software Evolution and the Staged Model of the Software Lifecycle K. H. BENNETT Research Institute for Software University of Durham Durham DH1 3LE United Kingdom
[email protected]
Evolution
V.TRAJLICH Department of Computer Science Wayne State University Detroit, Ml 48202 USA vtr@cs. wayne. edu N.WILDE Department of Computer Science University of West Florida Pensacola, FL 32514 USA
[email protected]
Abstract Software maintenance is concerned with modifying software once it has been deUvered and has entered user service. Many studies have shown that maintenance is the dominant Hfecycle activity for most practical systems; thus maintenance is of enormous industrial and commercial importance. Over the past 25 years or so, a conventional view of software development and maintenance has been accepted in which software is produced, delivered to the user, and then enters a maintenance stage. A review of this approach and the state of the art in research and practice is given at the start of the chapter. In most lifecycle models, software maintenance is lumped together as one phase at the end. In the experience of the authors, based on how maintenance is really undertaken (rather than how it might or should be done), software ADVANCES IN COMPUTERS, VOL. 56 ISBN 0-12-012156-5
1
Copyright 2002 Elsevier Science Ltd Allrightsof reproduction in any form reserved.
K. H. BENNETT £7/A/..
maintenance actually consists of a number of stages, some of which can start during initial development. This provides a very different perspective on the lifecycle. In the chapter, we introduce a new model of the lifecycle that partitions the conventional maintenance phase in a much more useful, relevant, and constructive way. It is termed the staged model There are five stages through which the software and the development team progress. A project starts with initial development stage, and we then identify an explicit evolution stage. Next is a servicing stage, comprising simple tactical activities. Later still, the software moves to ?i phase-out stage in which no more work is done on the software other than to collect revenue from its use. Finally the software has a close-down stage. The key point is that software evolution is quite different and separate from servicing, from phase-out, and from close-down, and this distinction is crucial in clarifying both the technical and business consequences. We show how the new model can provide a coherent analytic approach to preserving software value. Finally, promising research areas are summarized. Introduction 1.1 Background 1.2 Early Work 1.3 Program Comprehension 1.4 Standards 1.5 Iterative Software Development 1.6 The Laws of Software Evolution 1.7 Stage Distinctions 1.8 The Business Context 1.9 Review 1.10 The Stages of the Software Lifecycle Initial Development 2.1 Introduction 2.2 Software Team Expertise 2.3 System Architecture 2.4 What Makes Architecture Evolvable? Evolution—The Key Stage 3.1 Introduction 3.2 Software Releases 3.3 Evolutionary Software Development Servicing 4.1 Software Decay 4.2 Loss of Knowledge and Cultural Change 4.3 Wrapping, Patching, Cloning, and Other "Kludges" 4.4 Reengineering Phase-Out and Closedown
3 3 5 6 7 7 8 9 9 10 12 13 13 14 15 15 16 16 17 17 19 19 20 21 22 23
SOFTWARE EVOLUTION
6. Case Studies 6.1 The Microsoft Corporation 6.2 The VME Operating System 6.3 The Y2K Experience 6.4 A Major Billing System 6.5 A Small Security Company 6.6 A Long-Lived Defense System 6.7 A Printed Circuits Program 6.8 Project PET 6.9 The FASTGEN Geometric Modeling Toolkit 6.10 A Financial Management Application 7. Software Change and Comprehension 7.1 The Miniprocess of Change 7.2 Change Request and Planning 7.3 Change Implementation 7.4 Program Comprehension 8. Sustaining Software Value 8.1 Staving off the Servicing Stage 8.2 Strategies during Development 8.3 Strategies during Evolution 8.4 Strategies during Servicing 9. Future Directions: Ultra Rapid Software Evolution 10. Conclusions Acknowledgments References
1.
Introduction
1.1
Background
24 24 25 26 27 27 28 28 29 30 30 31 31 32 33 35 38 38 39 41 43 44 47 47 48
What is software maintenance? Is it different from software evolution? Why isn't software designed to be easier to maintain? What should we do with legacy software? How do we make money out of maintenance? Many of our conventional ideas are based on analyses carried out in the 1970s, and it is time to rethink these for the modem software industry. The origins of the term maintenance for software are not clear, but it has been used consistently over the past 25 years to refer to post-initial delivery work. This view is reflected in the IEEE definition of software maintenance [1] essentially as a post delivery activity: The process of modifying a software system or component after delivery to correct faults, improve performance or other attributes, or adapt to a changed environment. [1, p. 46]
4
K.H. BENNETT Er>^L
Implicit in this definition is the concept of software Ufecycle, which is defined as: The period of time that begins when a software product is conceived and ends when the software is no longer available for use. The software life cycle typically includes a concept phase, requirements phase, design phase, implementation phase, test phase, installation and checkout phase, operation and maintenance phase, and, sometimes, retirement phase. Note: These phases may overlap or be performed iteratively. [1, p. 68] A characteristic of established engineering disciplines is that they embody a structured, methodical approach to developing and maintaining artifacts [2, Chaps. 15 and 27]. Software lifecycle models are abstract descriptions of the structured methodical development and modification process typically showing the main stages in producing and maintaining executable software. The idea began in the 1960s with the waterfall model [3]. A lifecycle model, implicit or explicit, is the primary abstraction that software professionals use for managing and controlling a software project, to meet budget, timescale, and quality objectives, with understood risks, and using appropriate resources. The model describes the production of deliverables such as specifications and user documentation, as well as the executable code. The model must be consistent with any legal or contractual constraints within a project's procurement strategy. Thus, it is not surprising that lifecycle models have been given primary attention within the software engineering community. A good overview of software lifecycle models is given in [2] and a very useful model is the spiral model of Boehm [4], which envisages software production as a continual iterative development process. However, crucially, this model does not address the loss of knowledge, which in the authors' experience accompanies the support of long-lived software systems and which vitally constrains the tasks which can be performed. Our aim was to create a lifecycle model that would be useful for the planning, budgeting, and delivery of evolving systems, and that would take into account this loss of knowledge. Our new model is called the staged model. The aim of this chapter is to describe the new staged model [5]. We provide a broad overview of the state of the art in software maintenance and evolution. The emphasis is mainly on process and methods (rather than technology), since this is where the main developments have occurred, and is of most relevance to this chapter. There is much useful material available on software maintenance management, including very practical guides [6]. We start from the foundations established within the international standards community. We then briefly revisit previous research work, as an understanding of these results is essential. Program comprehension is identified as a key component; interestingly, very few
SOFTWARE EVOLUTION
5
textbooks on software engineering and even on software maintenance mention the term, so our review of the state of the art addresses the field to include this perspective. The new model and our view of research areas are influenced by program comprehension more than other aspects. The staged model is presented, and evidence drawn from case studies. Practical implications are then described, and finally, research directions are presented.
1.2
Early Work
In a very influential study, Lientz and Swanson [7,8] undertook a questionnaire survey in the 1970s, in which they analyzed then-current maintenance practices. Maintenance changes to software were categorized into: • perfective (changes to the functionality), adaptive (changes to the environment), corrective (the correction of errors), and preventive (improvements to avoid future problems). This categorization has been reproduced in many software engineering text books and papers (e.g., Sommerville [9], McDermid [2], Pressman [10], Warren [11]), and the study has been repeated in different application domains, in other countries and over a period of 20 years (see, for example, the Ph.D. thesis of Foster [12], who analyzes some 30 studies of this type). However, the basic analysis has remained essentially unchanged, and it is far from clear what benefits this view of maintenance actually brings. Implicit in the Lientz and Swanson model are two concepts: • That software undergoes initial development, it is delivered to its users, and then it enters a maintenance phase. • The maintenance phase is uniform over time in terms of the activities undertaken, the process and tools used, and the business consequences. These concepts have also suggested a uniform set of research problems to improve maintenance, see for example [2, Chap. 20]. One common message emerging from all these surveys is the very substantial proportion of lifecycle costs that are consumed by software maintenance, compared to software development. The figures range from 50 to 90% of the complete lifecycle cost [7]. The proportion for any specific systems clearly depends on the application domain and the successful deployment of the software (some long-lived software is now over 40 years old!).
6
K.H. BENNETT E r 4 L
The balance of lifecycle costs is subject to commercial pressures. It may be possible to discount the purchase price of a new software system, if charges can be recovered later through higher maintenance fees. The vendor may be the only organization capable (i.e., having the knowledge and expertise) of maintaining the system. Depending on the contractual arrangement between the producer and the consumer, and on the expectations for the maintenance phase, the incentive during development to produce maintainable software may vary considerably. Software maintenance is thus not entirely a technical problem. In the 1990s, the practice of outsourcing software maintenance became widespread. A customer company subcontracts all the support and maintenance of a purchased system to a specialist subcontractor. This has raised a set of new commercial issues, for example the potential risk of subcontracting out key company systems; and the difficulties in the future of recalling maintenance back in house or to another subcontractor if the first does not perform acceptably. It is important to recall that it is not simply the software application that evolves. Long-lived software may well outlast the environment within which it was produced. In the military domain, software has sometimes lasted longer than the hardware on which it was cross compiled (presenting major problems if the software has to be modified). Software tools are often advocated for software maintenance, but these may also evolve (and disappear from the market) at a faster rate than the software application under maintenance.
1.3
Program Comprehension
Program comprehension is that activity by which software engineers come to an understanding of the behavior of a software system using the source code as the primary reference. Studies suggest that program comprehension is the major activity of maintenance, absorbing around 50% of the costs [2, Chap. 20; 13]. Program comprehension requires understanding of the user domain that the software serves as well as software engineering and programming knowledge of the program itself. Further details are given in Section 7. The authors believe that comprehension plays a major role in the software lifecycle. During the early stages, the development team builds group understanding, and the system architects have a strategic understanding of the construction and operation of the system at all levels. At later stages, this knowledge is lost as developers disperse and the complexity of the software increases, making it more difficult to understand. Knowledge appears impossible to replace, once lost, and this forms the basis for our new model.
SOFTWARE EVOLUTION
1.4
7
Standards
Software maintenance has been included within more general software engineering standardization initiatives. For example, the IEEE has published a comprehensive set of standards [14], of which Std. 1219 on maintenance forms a coherent part. The IEEE standard defines seven steps in software maintenance change: • Problem modification/identification, classification, and prioritization, • Analysis and understanding (including ripple effects), • Design, • Implementation, • Regression/system testing, • Acceptance testing, • Delivery. Underpinning the standard is a straightforward iterative perspective of software maintenance; a change request is reviewed and its cost estimated; it is implemented; and then validation is carried out. The International Standards Organization (ISO) has also published a software maintenance standard [15]. This is in the context of Std. ISO/IEC 12207, which addresses how an agreement should be drawn up between a software acquirer and supplier (in which maintenance is included). The standard places considerable emphasis on planning.
1.5
Iterative Software Development
The iterative nature of software lifecycle was noted already in the 1970s by several authors. Wirth [16] proposed Stepwise Refinement where functionality is introduced into the program in successive iterations. Basili and Turner [17] described another process where the functionality is added to the program in successive iterative steps. Large software projects of that time already followed iterative scenarios. A notable project was the development of the IBM OS operating system. The experience of that project was described in [18,19]. These authors noted that a software lifecycle is inherently iterative, that a substantial proportion of the functionality is added iteratively, and that the initial development is simply the initialization stage of this process. See also [20].
8
K.H. BENNETT ET^/..
1.6
The Laws of Software Evolution
The evolution of a software system conforms to laws, which are derived from empirical observations of several large systems [21-23]: 1. Continuing change. A program that is used and that, as an implementation of its specification, reflects some other reality undergoes continuing change or becomes progressively less useful. 2. Increasing complexity. As an evolving program is continuously changed, its complexity, reflecting deteriorating structure, increases unless work is done to maintain or reduce it. The laws are only too apparent to anyone who has maintained an old heavily changed system. Lehman also categorized software into three types, as follows [24]: S-type software: this has a rigid specification (S means static) which does not change and which is well understood by the user. The specification defines the complete set of circumstances to which it applies. Examples are offered by many mathematical computations. It is therefore reasonable to prove that the implementation meets the specification. P-type software: this has a theoretical solution, but the implementation of the solution is impractical or impossible. The classic example is offered by a program to play chess, where the rules are completely defined, but do not offer a practical solution to an implementation (P means practical). Thus we must develop an approximate solution that is practical to implement. E-type software: this characterizes almost all software in everyday use, and reflects the real world situation that change is inevitable (E means embedded, in the sense of embedded in the real world). The solution involves a model of the abstract processes involved, which includes the software. Thus the system is an integral part of the world it models, so change occurs because both the world changes and the software is part of that world. For E-type systems, Lehman holds the view that (as in any feedback system), the feed-forward properties such as development technologies, environments, and methods are relatively unimportant and global properties of the maintenance process are insensitive to large variations in these factors. In contrast, he argues that the feedback components largely determine the behavior. So issues like testing, program understanding, inspection, and error reports are crucial to a wellunderstood stable process. This work may provide a theoretical perspective of why program comprehension is so important. He also amplified the concept of E-type software in his principle of uncertainty: the outcome of software system
SOFTWARE EVOLUTION
9
operation in the real world is inherently uncertain with the precise area of uncertainty also unknowable. This work to establish a firm scientific underpinning for software evolution continues in the FEAST project [25-28].
1.7
Stage Distinctions
Sneed [29] and Lehner [30,31] are among the few authors to have observed that the maintenance phase is not uniform. Sneed classified systems into three categories: throw-away systems that typically have a lifetime of less than two years and are neither evolved nor maintained. Then there are static systems that are implemented in a well-defined area and after being developed, their rate of change is less than 10% in a year, or are relatively static after development. Finally there are evolutionary systems that undergo substantial change after the initial development and last many years. The stages of these systems are initial development, evolution (called "further development" by Sneed), "maintenance" (i.e., servicing), and "demise" (i.e., phase-out). Lehner [30] used this model and investigated the lifecycle of 13 business systems from Upper Austria to confirm the existence of the stages. He found that some systems belong to the category of static systems, where there is a very short evolution after the initial development and then the maintenance work very dramatically decreases. Other systems consume substantial effort over many years. Lehner confirmed a clear distinction between evolution (called "growth" in his paper) and servicing (called "saturation") where the maintenance effort is substantially lower [31]. He thus refuted earlier opinions that the evolution and growth of software can continue indefinitely and confirmed Sneed's earlier observation about the distinctions between the several stages, through observation of long-term data from several systems.
1.8
The Business Context
Some of the problems of the traditional lifecycle model stem from recent trends in the business context of software development. Different categories of software application are subjected to radically different kinds of business pressures. Most software engineering techniques available today for software specification, design, and verification have been presented as conventional supply-side methods, driven by technological advance. Such methods may work well for systems with rigid boundaries of concern, such as embedded systems, which may be characterized as risk-averse. In such domains, users have become familiar with long periods between requests for new features and their release in new versions (the so-called "applications backlog").
10
K. H. BENNETT E7>^/..
However such techniques break down for appHcations where system boundaries are not fixed and are subject to constant urgent change. These applications are typically found in emergent organizations—"organizations in a state of continual process change, never arriving, always in transition" [32]. Examples include e-businesses as well as more traditional companies that continually need to reinvent themselves to gain competitive advantage [33]. A stockbroker, for example, may have a need to introduce a new service overnight; the service may only exist for another 24 hours before it is replaced by an updated version. In such organizations we have a demand-led approach to the provision of software services, addressing delivery mechanisms and processes which, when embedded in emergent organizations, give a software solution in emergent terms—one with continual change. The solution never ends and neither does the provision of software. The user demand is for change in 'Internet time" and the result is sometimes termed engineering for emergent solutions. Yet a third category is provided by so-called "legacy systems," which have been defined [34] as "systems which are essential to our organization but we don't know what to do with them." They pose the epitome of the maintenance challenge, because for the great majority, remedial action has never taken place, so whatever structure originally existed has long since disappeared. Legacy systems have been extensively addressed in the literature (see, e.g., [35,36]). The main conclusion is that there is no magic silver bullet; the future of each system needs to be analyzed, planned, and implemented based on both technical and business drivers, and taking into account existing and future staff expertise. Finally, as software systems become larger and more complex, organizations find that it does not make sense to develop in-house all the software they use. Commercial-off-the-shelf (COTS) components are becoming a larger part of most software projects. Selecting and managing such software represents a considerable challenge, since the user becomes dependent on the supplier, whose business and products may evolve in unexpected ways. Technical concerns about software's capabilities, performance, and reliability may become legal and contractual issues, and thus even more difficult to resolve. It appears that many organizations are now or soon will be running, at the same time, a mixture of embedded or legacy software, with added COTS components, and interfaced to new e-business applications. The processes and techniques used in each category clash, yet managers need somehow to make the whole work together to provide the services that clients demand.
1.9
Review
We began by drawing on currently available evidence. Many ideas are now sufficiently mature that process standards have been defined or are emerging, at
SOFTWARE EVOLUTION
11
least for large scale, embedded risk-averse systems. Empirical studies have shown that program comprehension is a crucial part of software maintenance, yet it is an activity that is difficult to automate and relies on human expertise. The increasing business stress on time to market in emergent organizations is increasing the diversity of software types that must be managed, with different processes being appropriate for each type. We conclude that: • Human expertise during the maintenance phase represents a crucial dimension that cannot be ignored. At the moment, some of the hardest software engineering evolution tasks (such as global ripple analysis) need senior engineers fully to comprehend the system and its business role. • We need to explore maintenance to reflect how it is actually done, rather than prescriptively how we would like it to be done. The major contribution of this chapter is to propose that maintenance is not a single uniform phase, the final stage of the conventional lifecycle, but is comprised of several distinct stages and is in turn distinct from evolution. The stages are not only technically distinct, but also require a different business perspective. Our work is motivated by the fact that the Lientz and Swanson approach does not accord with modem industrial practice, based on analysis of a number of case studies. Knowing the fraction of effort spent on various activities during the full lifecycle does not help a manager to plan those activities or make technical decisions about multisourced component-based software, or address the expertise requirements for a team. The conventional analysis has not, over many years, justified the production of more maintainable software despite the benefits that should logically accrue. Especially, the conventional model does not sensibly apply to the many modem projects, which are heavily based on COTS technology. Finally, it is only a technical model and does not include business issues. We also had other concems that the conventional Lientz and Swanson model did not elucidate. For example, there are few guidelines to help an organization assess if a reverse engineering project would be commercially successful, despite the large amount of research and development in this field, and it was not clear why this was the case. The skills of staff involved in post-delivery work seem very important, but the knowledge needed both by humans and in codified form has not been clearly defined, despite a large number of projects which set out to recapture such knowledge. Our motivation for defining a new perspective came from the very evident confusion in the area. A brief examination of a number of Web sites and papers concemed with software engineering, software evolution, and software maintenance also illustrated the confusion between terms such as maintenance and
12
K. H. BENNETT E 7 / \ L
evolution (with a completely uniform maintenance phase), and the almost universal acceptance of the Lientz and Swanson analysis. We found this situation inadequate for defining a clear research agenda that would be of benefit to industry. For these reason, we shall largely restrict our use of the term "software maintenance" from now on in this chapter to historical discussions. We have estabHshed a set of criteria forjudging success of our new perspective: • It should support modern industrial software development which stresses time to delivery and rapid change to meet new user requirements. • It should help with the analysis of COTS-type software. • It should be constructive and predictive—we can use it to help industry to recognize and plan for stage changes. • It should clarify the research agenda—each stage has very different activities and requires very different techniques to achieve improvement. • It should be analytic—we can use it to explain and clarify observed phenomena, e.g., that reverse engineering from code under servicing is very hard. • It should be used to model business activity as well as technical activity. • It should transcend as far as possible particular technologies and application domains (such as retail, defense, embedded, etc.) while being applicable to modem software engineering approaches. • It should also transcend detailed business models and support a variety of product types. On one hand we have the shrink-wrap model where time to market, etc., are important considerations; at the other extreme we have customer-tailored software where the emphasis may be on other attributes like security, reliability, and ease of evolution. • It should be supported by experimental results from the field. • It should help to predict and plan, rather than simply be descriptive. Our perspective is amplified below and is called the staged model.
1.10
The Stages of the Software Lifecycle
The basis of our perspective is that software undergoes several distinctive stages during its life. The following stages are: • Initial development—the first functioning version of the system is developed.
SOFTWARE EVOLUTION
13
• Evolution—if initial development is successful, the software enters the stage of evolution, where engineers extend its capabilities and functionality, possibly in major ways. Changes are made to meet new needs of its users, or because the requirements themselves had not been fully understood, and needed to be given precision through user experience and feedback. The managerial decision to be made during this stage is when and how software should be released to the users (alpha, beta, commercial releases, etc.). • Servicing—the software is subjected to minor defect repairs and very simple changes in function (we note that this term is used by Microsoft in referring to service packs for minor software updates). • Phase-out—no more servicing is being undertaken, and the software's owners seek to generate revenue for its use for as long as possible. Preparation for migration routes is made. • Closedown—the software is withdrawn from the market, and any users directed to a replacement system if this exists. The simplest variant of the staged software lifecycle is shown in Fig. 1. In the following sections, we describe each of these stages in more detail.
2.
Initial Development 2.1
Introduction
The first stage is initial development, when the first version of the software is developed from scratch. This stage has been well described in the software engineering literature and there are very many methods, tools, and textbooks that address it in detail (for example, see [2,9,10,37]). The stage is also addressed by a series of standards by IEEE and ISO, or by domain- or industry-specific standards (for example, in the aerospace sector). Such initial development very rarely now takes place starting from a "green field" situation since there may be an inheritance of old legacy software, as well as external suppliers of new COTS components. Over the past 30 years, since the recognition of software engineering as a discipline [38], a great deal of attention has been paid to the process of initial development of reliable software within budget and to predictable timescales. Software project managers welcomed the earliest process model, called the waterfall model, because it offered a means to make the initial development process more visible and auditable through identifiable deliverables. Since there is such an extensive
14
K. H.BENNETT E T ^ / . .
I Initial development first running version evolution changes
Evolution
loss of evolvability servicing patchies
Servicing
servicing discontinued
Phase-out
Switch-off Close-down
FIG. 1. The simple staged model.
literature dealing with initial development, we will cover only selected aspects of it.
2.2
Software Team Expertise
From the point of view of the future stages, several important foundations are laid during initial development. The first foundation is that the expertise of the software engineering team and in particular of the system architects is established. Initial development is the stage during which the team learns about the domain and the problem. No matter how much previous experience had been accumulated before the project started, new knowledge will be acquired during initial development. This experience is of indispensable value in that it will make future evolution of the software possible. So this aspect—the start of team learning— characterizes the first stage. Despite the many attempts to document and record such team learning, much of it is probably tacit—it is the sort of experience that is extremely difficult to record formally.
SOFTWARE EVOLUTION
2.3
15
System Architecture
Another important result and deliverable from initial development is the architecture of the system, i.e., the components from which the system is built, their interactions, and their properties. The architecture will either facilitate or hinder the changes that will occur during evolution and it will either withstand those changes or break down under their impact. It is certainly possible to document architecture, and standard approaches to architectures (e.g., [39]) provide a framework. In practice, one of the major problems for architectural integrity during initial development is "requirements creep." If the requirements of the software system are not clear, or if they change as the software is developed, then a single clear view of the architecture is very difficult to sustain. Numerous approaches to ameliorating this problem have been devised, such as rapid application development, prototyping, and various management solutions, such as the Chief Programmer team, and (more recently) extreme programming [40]. The approach chosen can be strongly influenced by the form of legal contract between the vendor and customer which may induce either a short- or long-term view of the trade-off between meeting a customer's immediate needs and maintaining a clean software architecture.
2.4
What Makes Architecture Evolvable?
Thus for software to be easily evolved, it must have an appropriate architecture, and the team of engineers must have the necessary expertise. For example, in long-lived systems such as the ICL VME operating system, almost all subcomponents have been replaced at some stage or another. Yet despite this, the overall system has retained much of its architectural integrity [41]. In our experience, the evolution of architecture needs individuals of very high expertise, ability, and leadership. There may be financial pressures to take technical shortcuts in order to deliver changes very quickly (ignoring the problem that these conflict with the architectural demands). Without the right level of human skill and understanding it may not be realized that changes are seriously degrading the software structure until it is too late. There is no easy answer or "prescription" to making an architecture easily evolvable. Inevitably there is a trade-off between gains now, and gains for the future, and the process is not infallible. A pragmatic analysis of software systems which have stood the test of time (e.g., VME, or UNIX) typically shows the original design was undertaken by one, or a few, highly talented individuals. Despite a number of attempts, it has proved very difficult to establish contractually what is meant by maintainable or evolvable software and to define processes
16
K. H. BENNETT ET/^/..
that will produce software with these characteristics. At a basic level, it is possible to insist on the adoption of a house style to programming, to use IEEE or ISO standards in the management and technical implementation, to use modem tools, to document the software, and so on. Where change can be foreseen at design time, it may be possible to parameterize functionality. These techniques may be necessary, but experience shows that they are not sufficient. The problem may be summarized easily: a successful software system will be subjected to changes over its lifetime that the original designers and architects cannot even conceive of. It is therefore not possible to plan for such change, and certainly not possible to create a design that will accommodate it. Thus, some software will be able to evolve, but other systems will have an architecture that is at cross-purposes with a required change. To force the change may introduce technical and business risks and create problems for the future.
3.
Evolution—The Key Stage 3.1
Introduction
The evolution stage is characterized as an iterative addition, modification, or deletion of nontrivial software functionality (program features). This stage represents our first major difference from the traditional model. The usual view is that software is developed and then passed to the maintenance team. However, in many of the case studies described later, we find that this is not the case. Instead, the software is released to customers, and assuming it is successful, it begins to stimulate enthusiastic users. (If it is not successful, then the project is cancelled!) It also begins to generate income and market share. The users provide feedback and requests for new features. The project team is living in an environment of success, and this encourages the senior designers to stick around and support the system through a number of releases. In terms of team learning, it is usually the original design team that sees the new system through its buoyant early days. Of course, errors will be detected during this stage, but these are scheduled for correction in the next release. During the evolution stage, the continued availability of highly skilled staff makes it possible to sustain architectural integrity. Such personnel would seem to be essential. Unfortunately we note that making this form of expertise explicit (in a textbook, for example) has not been successful despite a number of projects concerned with "knowledge-based software engineering." The increase in size, complexity, and functionality of software is partly the result of the learning process in the software team. Cusumano and Selby reported that a feature set during each iteration may change by 30% or more, as a direct
SOFTWARE EVOLUTION
17
result of the learning process during the iteration [42]. Brooks also comments that there is a substantial "learning curve" in building a successful new system [18]. Size and complexity increases are also caused by customers' requests for additional functionality, and market pressures add further to growth, since it may be necessary to match features of the competitor's product. In some domains, such as the public sector, legislative change can force major evolutionary changes, often at short notice, that were never anticipated when the software was first produced. There is often a continuous stream of such changes.
3.2
Software Releases
There are usually several releases to customers during the software evolution stage. The time of each release is based on both technical and business considerations. Managers must take into account various conflicting criteria, which include time to market or time to delivery, stability of software, fault rate reports, etc. Moreover the release can consist of several steps, including alpha and beta releases. Hence the release, which is the traditional boundary between software development and software maintenance, can be a blurred and to a certain degree an arbitrary milestone. For software with a large customer base, it is customary to produce a sequence of versions. These versions coexist among the users and are independendy serviced, mostly to provide bug fixes. This servicing may take the form of patches or minor releases so that a specific copy of the software in the hands of a user may have both a version number and release number. The releases rarely implement a substantial new functionality; that is left to the next version. This variant of the staged lifecycle model for this situation is shown in Fig. 2.
3.3
Evolutionary Software Development
The current trend in software engineering is to minimize the process of initial development, making it into only a preliminary development of a skeletal version or of a prototype of the application. Full development then consists of several iterations, each adding certain functionality or properties to the already existing software system. In this situation, software evolution largely replaces initial development, which then becomes nothing more than the first among several equal iterations. The purpose of evolutionary development is to minimize requirements risks. As observed earlier, software requirements are very often incomplete because of the difficulties in eliciting them. The users are responsible for providing a complete set of accurate requirements, but often provide less than that, because of the lack of knowledge or plain omissions. On top of that, the requirements change
18
K. H.BENNETT E7/\L Initial development
first running version
evolution clianges
Evolution Version 1 -^.^ - -
servicing pa tches
Servicing Version 1 evolution of new version evolution changes Phase-out Version 1 Evolution Version 2 servicing patches
"^\
Close-down Version 1 Servicing Version 2
evolution of new version Phase-out Version 2
I ! Evolution Version . . .
Close-down Version 2
I
L
_._.__ FIG. 2. The versioned staged model.
during development, because the situation in which the software operates changes. There is also a process of learning by both users and implementers and that again contributes to changing requirements. Because of this, a complete set of requirements is impossible or unlikely in many situations so one-step implementation of large software carries a substantial risk. Evolutionary software development that is divided into incremental steps lessens the risk because it allows the users to see and experience the incomplete software after each iteration. One of the well-known and well-described processes of evolutionary software development is the Unified Software Development Process [43]. This process describes in detail how software is to be developed in incremental iterations. Each
SOFTWARE EVOLUTION
19
incremental iteration adds a new functionality or a new property (e.g., security, effectiveness) to the already existing software. This gradual increase in requirements lessens the risk involved, because each iteration provides a fresh feedback about the progress of the project. The Unified Software Development Process describes the number of activities and specifies the documents to be produced during the iterations. However, Booch reports that a major criticism leveled at the Unified Software Development Process and similar approaches is that the resulting processes are rigid, require extensive documentation and many steps, and consequently are too expensive in time for many modem businesses [44]. An emerging alternate approach for systems that require rapid evolution is the agile method, an example of which is Extreme Programming (XP) [40]. XP almost abolishes the initial development phase. Instead, programmers work closely with customers to develop a set of "stories" describing desired features of the new software. Then a series of releases is implemented, with typically only a few weeks between releases. The customer defines the next release by choosing the stories to implement. Programmers take the stories and define more fine-grained tasks, with one programmer taking responsibility for each. Test cases are defined before programming begins. An interesting aspect of XP is that the responsible programmer signs up a partner for the task; all work is done in pairs with both working at the same workstation. Thus, knowledge is shared between at least two programmers, and some self-checking is built in without requiring organized walkthroughs or inspections. Pairs are broken up and reformed for different tasks so experience can be distributed. There is little documentation of code or design, although considerable care is taken to maintain tests that can be rerun in the future. Agile methods seem to discard all the software engineering experience of the past 20 years and place their reliance purely on the retention of expert team personnel for as long as the software needs to evolve. They thus gain valuable time, but perhaps at considerable risk. It remains to be seen whether this kind of methodology will be viable beyond the short term or whether managers and stockholders will instead discover that their critical applications have suddenly made unplanned and costly transitions to servicing.
4.
Servicing
4.1 Software Decay As previously mentioned, software enters the servicing stage as human expertise and/or architectural integrity are lost. Servicing has been alternatively called
20
K. H. BENNETT ET/^L
"saturation" [30,31], "aging software," "decayed software," "maintenance proper," and "legacy software." During this stage, it is difficult and expensive to make changes, and hence changes are usually limited to the minimum. At the same time, the software still may have a "mission critical" status; i.e., the user organization may rely on the software for services essential to its survival. Code decay (or aging) was discussed in [45] and empirical evidence for it was summarized in [46]. The symptoms of code decay include: — excessively complex (bloated) code, i.e., code that is more complex than it needs to be, — vestigial code that supports features no longer used or required, — frequent changes to the code, — history of faults in the code, — delocalized changes are frequent, i.e., changes that affect many parts of the code, — programmers use "kludges," i.e., changes done in an inelegant or inefficient manner, for example, clones or patches, — numerous dependencies in the code. As the number of dependencies increases, the secondary effects of change become more frequent and the possibility of introducing an error into software increases.
4.2
Loss of Knowledge and Cultural Change
In order to understand a software system, programmers need many kinds of knowledge. The programmers must understand the domain of the application in detail. They must understand the objects of the domain, their properties, and their relationships. They must understand the business process that the program supports, as well as all activities and events of that process. They also must understand the algorithms and data structures that implement the objects, events, and processes. They must understand the architecture of the program and all its strengths and weaknesses, imperfections by which the program differs from an ideal. This knowledge may be partially recorded in program documentation, but usually it is of such a size and complexity that a complete recording is impractical. A great part of it usually is not recorded and has the form of individuals' experiences or groups' oral tradition. This knowledge is constantly at risk. Changes in the code make knowledge obsolete. As the symptoms of decay proliferate, the code becomes more and more complicated, and larger and deeper knowledge is necessary in order to understand it. At the same time, there is usually a turnover of programmers on the project. Turnover may have different causes, including the natural turnover of the programmers for their personal reasons, or the needs of other projects that forces
SOFTWARE EVOLUTION
21
managers to reassign programmers to other work. Based on the success of the project, team members are promoted, moved to other projects, and generally disperse. The team expertise to support strategic changes and evolution to the software is thus lost; new staff members joining the team have a much more tactical perspective (e.g., at code level) of the software. Evolvability is lost and, accidentally or by design, the system slips into servicing. However, management that is aware of the decline may recognize the eventual transition by planning for it. Typically, the current software is moved to the servicing stage, while the senior designers initiate a new project to release a radically new version (often with a new name, a new market approach, etc.). A special instance of the loss of knowledge is cultural change in software engineering [47]. Software engineering has almost a half-century of tradition, and there are programs still in use that were created more than 40 years ago. These programs were created in a context of completely different properties of hardware, languages, and operating systems. Computers were slower and had much smaller memories, often requiring elaborate techniques to deal with these limitations. Program architectures in use were also different; modem architectures using techniques such as object orientation were rare at that time. The programmers who created these programs are very often unavailable. Current programmers who try to change these old programs face a double problem: not only must they recover the knowledge that is necessary for that specific program, but they also must recover the knowledge of the culture within which it and similar programs were created. Without that cultural understanding they may be unable to make the simplest changes in the program.
4.3
Wrapping, Patching, Cloning, and Other "Kludges"
During servicing, it is difficult and expensive to make changes, and hence changes are usually limited to the minimum. The programmers must also use unusual techniques for changes, the so-called "kludges." One such technique is wrapping. With wrapping, software is treated as a black box and changes are implemented as wrappers where the original functionality is changed into a new one by modifications of inputs and outputs from the old software. Obviously, only changes of a limited kind can be implemented in this way. Moreover each such change further degrades the architecture of the software and pushes it deeper into the servicing stage. Another kind of change that frequently is employed during servicing is termed cloning. If programmers do not understand fully the program, instead of finding where a specific functionality is implemented in the program, they create another implementation. Thus a program may end up having several implementations of
22
K. H. BENNETT EI>A/..
identical or nearly identical stacks or other data structures, several implementations of identical or almost identical algorithms, etc. Sometimes programmers intentionally create clones out of fear of secondary effects of a change. As an example, let us assume that function f o o () requires a change, but f o o () may be called from other parts of the code so that a change in fooO may create secondary effects in those parts. Since knowledge of the program in the servicing stage is low, the programmers choose a "safe" technique: they copy-and-paste fooO, creating an intentional clone f o o l (). Then they update f o o1 {) so that it satisfies the new requirements, while the old f o o () still remains in use by other parts of the program. Thus there are no secondary effects in the places where f o o () is called. While programmers solve their immediate problem in this way, they negatively impact the program architecture and make future changes harder. The presence of a growing number of clones in code is a significant symptom of code decay during servicing. Several authors have proposed methods of detecting clones automatically using substring matching [48] or subtree matching [49]. Software managers could consider tracking the growth of clones as a measure of code decay, and consider remedial action if the system seems to be decaying too rapidly [50,51]. Servicing patches are fragments of the code, very often in binary form, that are used to distribute bug fixes in a widely distributed software system.
4.4
Reengineering
In the servicing stage, it is difficult to reverse the situation and return to the stage of evolution. That would require regaining the expertise necessary for evolution, recapturing the architecture, restructuring the software, or all of these. Both restructuring and regaining expertise are slow and expensive processes, with many risks involved, and new staff may have to be recruited with appropriate and relevant skills. As analyzed by Olsem [52], the users of a legacy system build their work routines and expectations based on the services it provides and are thus very sensitive about any disruption of routine. Their tolerance of changes may be much smaller than the tolerance displayed by the users of brand new systems. Thus, user rigidity also makes reengineering a very risky proposition. In order to minimize the risk and the disruption of user routine, Olsem advocates incremental reengineering, where the system is reengineered one part at a time. The new parts temporarily coexist with the old parts and old parts are replaced one-by-one, without interruption of the service. A case study of such reengineering was published in [53].
SOFTWARE EVOLUTION
23
This approach to reengineering avoids disruption of the user's routines, but it also preserves the interfaces among the parts and hence the overall architecture of the system. If the architecture is also obsolete, the process provides only partial relief. This impacts the business case for reengineering, since the benefits returned compared to the investment required may be difficult to justify. In the worst case, we are spending resources for little or no benefit. A further difficulty with reengineering of widely used software is the problem of distribution. Getting the new version out to all users can be expensive or impossible, so the burden of servicing the old version may persist. This problem will surely become even greater as software is increasingly introduced to more consumer goods such as mobile phones. Once an object level code has been released in such devices, it is all but impossible to go back to the evolutionary stage. Based on our experience, complete reengineering as a way of stepping back from servicing to evolution is very rare and expensive, so that entrance into the servicing stage is for all practical purposes irreversible.
5.
Phase-Out and Closedown
At some stage the system is essentially frozen and no further changes are allowed. This stage, which we call phase-out, has also been called "decline" [31]. Help desk personnel may still be in place to assist users in running the system, but change requests are no longer honored. Users must work around any remaining defects instead of expecting them to be fixed. Finally, the system may be completely withdrawn from service and even this basic level of staffing is no longer provided. The exact course of phase-out and closedown will depend on the specific system and the contractual obligations in place. Sometimes a system in phase-out is still generating revenue, but in other cases (such as most shrink-wrap software) the user has already paid for it. In this second case, the software producer may be much less motivated to provide support. In a survey by Tamai and Torimitsu [54], an investigation was undertaken of the life span of software in Japan. The survey dealt with software from several application areas such as manufacturing, financial services, construction, and mass media. It found that for software larger than 1 million lines of code, the average life was 12.2 years with a standard deviation of 4.2 years. The lifetime varied more widely for smaller software. Tamai and Torimitsu's work also classified the causes of the closedowns in the following way. Hardware and/or system change caused the closedown in 18%
24
K. H.BENNETT Er/\L
of the cases. New technology was the reason in 23.7% of the cases. A need to satisfy new user requirements (that the old system was unable to satisfy) was the cause in 32.8% of the cases. Finally deterioration of software maintainability was the culprit in 25.4% of the cases. We can speculate that at the end of the lifetime, the software was in phase-out stage and in most of the cases, there was an event (hardware change, new technology, new requirements) that pushed software into closedown. Only in 25.4% of the cases did closedown occur naturally as a free management decision, without any precipitating event from the outside. There are a number of issues related to software shutdown. Contracts should define the legal responsibilities in this phase. In some cases, such as outsourced software in which one company has contracted with another to develop the system, the relationships may be quite complex. Final ownership and retention of the system, its source code, and its documentation should be clearly defined. Frequently system data must be archived and access must be provided to it. Examples of such data are student transcripts, birth certificates, and other longlived data. The issues of data archiving and long-term access must be solved before the system is shut down.
6.
Case Studies
Our new lifecycle model was derived from involvement with and observation of real industrial and commercial software development projects in a number of domains. We then abstracted from the particular experiences and practices of these projects, in order to draw our new perspective. Lehner [30,31] has provided empirical evidence that the activities of "maintenance" change during the lifecycle of a project. However, other than this, very little data have been collected, and our evidence is gleaned from published case studies and personal practical experience. The experience from these projects is summarized in the rest of this section.
6.1 The Microsoft Corporation The description of the Microsoft development process, as given by Cusumano and Selby [42], illustrates the techniques and processes used for high-volume mass market shrink-wrapped software. In particular, we can draw on the following evidence: 1. At Microsoft, there is a substantial investment in the initial development stage, before revenue is generated from sales. This includes testing.
SOFTWARE EVOLUTION
25
2. The division between initial development and evolution is not sharp; the technique of using beta releases to gain experience from customers is widely used. 3. Microsoft tries to avoid quite explicitly the traditional maintenance phase. It is realized that with such a large user base, this is logistically impossible. Object code patches (service packs) are released to fix serious errors, but not for feature enhancement. 4. The development of the next release is happening while the existing release is still achieving major market success. Thus Windows 98 was developed while Windows 95 was still on its rising curve of sales. Microsoft did not wait until Windows 95 sales started to decline to start development, and to do so would have been disastrous. Market strategy is based upon a rich (and expanding) set of features. As soon as Windows 98 reached the market, sales of Windows 95 declined very rapidly. Shortcomings and problems in Windows 95 were taken forward for rectification in Windows 98; they were not addressed by maintenance of Windows 95. 5. Microsoft does not support old versions of software, which have been phased out, but they do provide transition routes from old to new versions. 6. Organizational learning is becoming evident through the use of shared software components. Interestingly, Microsoft has not felt the need for substantial documentation, indicating that the tacit knowledge is retained effectively in design teams. We conclude that evolution represents Microsoft's main activity, and servicing by choice a very minor activity.
6.2
The VME Operating System
This system has been implemented on ICL (and other) machines for the past 30 years or so, and has been written up by International Computers Ltd. [41]. It tends to follow the classical X.Y release form, where X represents a major release (evolution) and Y represents minor changes (servicing). In a similar way to Microsoft, major releases tend to represent market-led developments incorporating new or better facilities. The remarkable property of VME is the way in which its original architectural attributes have remained over such a long period, despite the huge evolution in the facilities. It is likely that none of the original source code from the early 1970s still is present in the current version. Yet its architectural integrity is clearly preserved. We can deduce that: 1. There was a heavy investment in initial development, which has had the effect of a meticulous architectural design. The system has been evolved
26
K. H. BENNETT FT/^/..
by experts with many years of experience, but who also have been able to sustain architectural integrity. 2. Each major release is subject to servicing, and eventually that release is phased-out and closed down. 3. Reverse engineering is not used from one major release to another; evolution is accomplished by team expertise and an excellent architecture.
6.3
The Y2K Experience
An excellent example of software in its servicing stage and its impact has been provided by the "Y2K" episode. It was caused by a widespread convention that limited the representation of a year in a date to the last two digits; for example, the year 1997 was represented by two digits "97." Based on this convention, when January 1, 2000 was reached, the year represented as "00" would be interpreted by computers as 1900, with all accompanying problems such misrepresentation could cause. The origin of the two-digit convention goes back to the early programs of the 1950s when the memory space was at a premium and hence to abbreviate the year to its two final digits seemed reasonable, while the problems this would cause seemed very remote. Even as the time was moving closer toward the fateful January 1, 2000, programmers continued to use the entrenched convention, perhaps out of inertia and habit. The extent of the problem became obvious in the late 1990s and a feverish attempt to remedy the problem became widespread. Articles in the popular press and by pessimists predicted that the programs would not be updated on time, that the impacts of this failure would be catastrophic, disrupting power supplies, goods distribution, financial markets, etc. At the height of the panic, the president of the USA appointed a "Y2K czar" with an office close to the White House whose role was to coordinate the efforts to fix the Y2K problem (and if this did not succeed, to deal with the ensuing chaos). Similar appointments were made in other countries, such as the UK. Fortunately, the dire Y2K predictions did not materialize. Many old programs were closed down. The programs that could not be closed down and needed to be repaired were indeed fixed, mostly by a technique called "windowing," which is a variant of wrapping. The two-digit dates are reinterpreted by moving the "window" from years 1900-1999 to a different period, for example, 1980-2080. In the new window, "99" is still interpreted as 1999, but "00", "01", ..., are now interpreted as 2000, 2001, etc. This worked well (for the time being) and has postponed the problem to the time when the new "window" will run out. The Y2K czar quietly closed his office and left town. There were, in fact, very few reported problems.
SOFTWARE EVOLUTION
27
However the whole Y2K effort is estimated to have had a staggering cost. It is estimated that worldwide, about 45% of all applications were modified and 20% were closed down, at the cost between $375 and $750 billion [55]. From the viewpoint of our model, the Y2K problem was caused by the fact that many legacy systems were in the servicing stage, and although Y2K rectification would be only a routine change during the evolution stage, it was a hard or very hard change during the servicing stage. At heart, the problem was caused by a design decision (a key data representation choice) and changes in design are very hard to achieve successfully during servicing. The reason why the Y2K problem caught so many managers by surprise is the fact that the difference between evolutionary and servicing stages was not well understood.
6.4
A Major Billing System
This 20-year-old system generates revenue for its organization, and is of strategic importance. However, the marketplace for the organization's products has changed rapidly in recent years, and the billing system can no longer keep up with market-led initiatives (such as new products). Analysis shows that this system has slid from evolution into servicing without management realizing it, the key designers have left, the architectural integrity has been lost, changes take far too long to implement, and revalidation is a nightmare; it is a classical legacy system. The only solution (at huge expense) is to replace it.
6.5
A Small Security Company
A small company has a niche market in specialized hardware security devices. The embedded software is based around Microsoft's latest products. The products must use rapidly changing hardware peripherals, and the company must work hard to keep ahead of the competition in terms of the sophistication of the product line. The software therefore consists of COTS components (e.g., special device drivers), locally written components, some legacy code, and glue written in a variety of languages (e.g., C, C-l-l-, BASIC). The system was not planned in this way, but has evolved into this form because of "happenstance." The software is the source of major problems. New components are bought, and must work with the old legacy. Powerful components are linked via very low-level code. Support of locally written components is proving very hard. From our perspective, we have a software system in which some parts are in initial development, some are in evolution, others are in servicing, while others are ready for phase-out. There is no sustained architectural design.
28
K. H.BENNETT E r ^ L
The existing (Lientz and Swanson) type analysis sheds Uttle Ught on this problem. Our model allows each component and connector to be assessed in terms of its stage. This should then allow the company to develop a support plan. For example, a component being serviced can have a dependency on another component being evolved.
6.6
A Long-Lived Defense System
A different type of case study is represented by a long-lived, embedded, defense system which is safety related. This was developed initially many years ago (in Assembler) and needs to be continually updated to reflect changes in the supporting hardware. In classic terms, this system would be thought of as being in the maintenance phase, but according to our analysis, it is still being evolved, yet surely but inexorably slipping into servicing: 1. The software is still core to the organization, and will be for many years. Failure of the software in service would be a disaster. 2. Many experts with in-depth knowledge of the software (and hardware) are working on the system. They understand the architecture and are Assembler experts. The software is being changed to meet quite radical new requirements. It is free from ad hoc patches, and consistent documentation is being produced, although structurally it is decaying. Comprehensive test procedures are in place and are used rigorously. The system engineers understand the impact of local changes on global behavior. Mature, well-understood processes are employed. 3. Conversely, some experts have recently left the organization, and this loss of expertise, accompanied by structural decay mentioned above, is a symptom of serious software decay. Reverse engineering is not considered feasible, partly because of the lack of key expertise. If the process of the decay reaches a certain point, it is likely that the system will be developed again ab initio.
6.7
A Printed Circuits Program
One of the co-authors was for several years a software manager of a software department. One of the projects in that department was a program that designed printed circuit boards, and was used by customers within the same institution. Because of the critical nature of the product, it had to be constantly evolved as new requirements appeared and had to be satisfied. The original developers were evolving the program but at the same time, they were some of the most qualified program developers in the department.
SOFTWARE EVOLUTION
29
Since there was a backlog of other projects that required high expertise, and the difference between evolution and servicing was not understood at the time, the manager tried several times unsuccessfully to transfer the evolution responsibility to different people. However all attempts to train new programmers so that they would be able to take over the evolution task and relieve the original developers turned out to be unsuccessful. In all instances, the new trainees were able to do only very limited tasks and were unable to make strategic changes in the program. At that time, this inability to transfer a "maintenance" task proved to be baffling to the manager. In hindsight, the expertise needed for evolution was equivalent or perhaps even greater than the expertise to create the whole program from scratch. It proved more cost effective to assign the new programmers to the new projects and to leave the experienced developers to evolve the printed circuit program.
6.8
Project PET
This case study is an example of an attempted reengineering project. PET is a CAD tool developed by a car company [56,57] to support the design of the mechanical components (transmission, engine, etc.) of a car. It is implemented in C-h-1-, and every mechanical component is modeled as a C-I-+ class. The mechanical component dependency is described by a set of equations that constitute a complex dependency network. Whenever a parameter value is changed, an inference algorithm traverses the entire network and recalculates the values of all dependent parameters. PET consists of 120,000 lines of C-l-l- code and is interfaced with other CAD software, including 3-D modeling software. After the initial implementation, there was a massive stage of evolution where, in our estimate, more than 70% of the current functionality was either radically changed or newly introduced. The evolution was driven mostly by the user requests. All changes to PET were performed as quickly as possible in order to make the new functionality available. This situation prevented conceptual changes to the architecture, and the architecture progressively deteriorated. Also the original architecture was not conceived for changes of this magnitude. As a result, the architecture has drastically deteriorated to the point where the requested evolutionary changes are becoming increasingly difficult. The symptoms of deterioration include the introduction of clones into the code and the misplacement of code into the wrong classes. During a code review we identified 10% of the PET code as clones. Because of code deterioration, the evolvability of the PET software has been decreasing and some evolutionary changes are becoming very hard. An example of a hard change is a modification to the inferencing algorithms. As mentioned above, the program uses inferencing by which the relationships between the mechanical components are maintained. The program would greatly benefit from
30
K. H. BENNETT E7/\L
an introduction of a commercially available component for inferencing that contains more powerful inferencing algorithms, but the current architecture with misplaced code and clones does not make that change feasible. Because of this, the changes done to the software have the character of patches that further corrode the architecture. Recently a decision was made to move PET software into a servicing stage, with work performed by a different group of people, and to stop all evolutionary changes. While PET will be serviced and should meet the needs of the users in this situation, a new version of PET will be developed from scratch, embodying all the expertise gained from the old PET evolution. The attempt to reengineer the old version of PET has been abandoned.
6.9
The FASTGEN Geometric Modeling Toolkit
FASTGEN is a collection of Fortran programs used by the U.S. Department of Defense to model the interactions between weapons (such as bombs or missiles) and targets (such as tanks or airplanes). Targets are modeled as large collections of triangles, spheres, donuts, and other geometric figures, and ray-tracing programs compute the effects of the explosion of a weapon. FASTGEN was originally developed in the late 1970s by one contractor, and has since been modified many times by other agencies and contractors at different sites ranging from California to Florida. Originally developed primarily for mainframe computers, it has been ported to supercomputer platforms such as CDC and Cray, Digital Equipment VAX, and, in the 1990s to PC and Unix workstations. A study of CONVERT, one of the FASTGEN programs, illustrates the impact of the original architecture on program comprehension and evolvability [58]. The original code was poorly modularized with large, noncohesive subroutines and heavy use of global data. The program still contains several optimizations that were important for the original mainframe environment, but that now make comprehension very difficult. For example, records are read and written in arbitrary batches of 200 at a time; in the original environment input/output could cause the program to be swapped out of memory so it was much more efficient to read many records before doing computations. Current versions of the program preserve this complex batching logic that is now obscure and irrelevant. FASTGEN is now in a late servicing stage, bordering on phase-out.
6.10
A Financial Management Application
This application dates from the 1970s, when it was implemented on DEC PDP computers. Recently it has been ported to PC/Windows machines. It is
SOFTWARE EVOLUTION
31
financially critical to its users. The software is modest in size (around 10,000 lines of code). Prior to the port, the software was stable and had evolved very little. In Lehman's terms this was an S-type system, with very little evolution, and very long lived. During the port, it had been decided to modify the code, preserving the original architecture as far as possible. Unfortunately, this had the following effects: (a) On the PDP series, different peripheral drivers (magnetic tapes, paper tape, disks, etc.) had very different interfaces. These differences were not well hidden, and impacted much of the application code. In the PC implementation, Windows has a much cleaner unified view of access to disks, CDs, etc. (i.e., byte vectors). Yet the original PDP peripheral code structure was retained, because the designers of the port could not be sure of correctly handling all side effects if the structure were changed. As a result, the code is much longer than it needs to be, with much redundancy and unwarranted complexity. (b) Even worse, the application needs to run in real time. The real time model employed in the original language has been retained in the port, yet the model for the new apphcation language has been added. The result is a labyrinthine real time program structure that is extremely hard to comprehend. This application has now slipped to the end of the servicing stage and only the simplest changes are possible. The expertise does not exist to reengineer it. If major changes are needed, the system will have to be rewritten.
7.
Software Change and Comprehension 7.1 The Miniprocess of Change
During both the evolution and the servicing stages, a software system goes through a series of changes. In fact, both evolution and servicing consist of repeated change, and hence understanding the process of software change is the key to understanding these stages and the problems of the whole software lifecycle. Accordingly in this section we look at the process of change in more detail, decomposing change into its constituent tasks. A particularly important task is program comprehension, because it consumes most of the programmer's time, and its success dominates what can or cannot be accomplished by software change. The tasks comprising software change are listed in [14] (see the Introduction). They are summarized in the miniprocess of change. In order to emphasize tasks
32
K. H. BENNETT Er/^L
that we consider important, we divide them differently than the standard and group them into the miniprocess in the following way: • Change request: the new requirements for the system are proposed. • Change planning: to analyze the proposed changes. o Program comprehension: understand the target system. o Change impact analysis: analyze the potential change and its scope. • Change implementation: the change is made and verified. o Restructuring (re-factoring) for change. o Initial change. o Change propagation: make secondary changes to keep the entire system consistent, o Validation and verification: to ensure whether the system after change meets the new requirement and that the old requirements have not been adversely impacted by the change, o Redocumentation: to project the change into all documentation. • Delivery. These tasks are discussed in more detail in this section.
7.2
Change Request and Planning
The users of the system usually originate the change requests (or maintenance requests). These requests have the form of fault reports or requests for enhancements. Standard practice is to have a file of requests (backlog) that is regularly updated. There is a submission deadline for change requests for the next release. After the deadline, the managers decide which particular requests will be implemented in that release. All requests that are submitted after the deadline or the requests that did not make it into the release will have to wait for the following release. Even this superficial processing of change requests requires some understanding of the current system so that the effort required may be estimated. It is a common error to underestimate drastically the time required for a software change and thus the time to produce a release. In small changes, it suffices to find the appropriate location in the code and replace the old functionality with the new one. However large incremental changes
SOFTWARE EVOLUTION
33
require implementation of new domain concepts. Consider a retail "point-ofsale" application for handling bar code scanning and customer checkout. The application would need to deal with several forms of payment, such as cash and credit cards. An enhancement to handle check payments would involve a new concept, related to the existing payment methods but sufficiently different to require additional data structures, processing for authorization, etc. There will be quite a lot of new code, and care is needed to maintain consistency with existing code to avoid degrading the system architecture. Concepts that are dependent on each other must be implemented in the order of their dependency. For example, the concept "tax" is dependent on the concept "item" because different items may have different tax rates and tax without an item is meaningless. Therefore, the implementation of "item" must precede the implementation of "tax." If several concepts are mutually dependent, they must be implemented in the same incremental change. Mutually independent concepts can be introduced in arbitrary order, but it is advisable to introduce them in the order of importance to the user. For example, in the point-of-sale program it is more important to deal correctly with taxes than to support several cashiers. An application with correct support for taxes is already usable in stores with one cashier. The opposite order of incremental changes would postpone the usability of the program. Change planning thus requires the selection of domain concepts to be introduced or further developed. It also requires finding in the old code the location where these concepts should be implemented so that they properly interact with the other already present concepts. Obviously these tasks require a deep understanding of the software and of its problem domain.
7.3
Change Implementation
Implementation of the software change requires several tasks, often with some looping and repetition. If the proposed change has a large impact on the architecture, there may be a preliminary restructuring of the program to maintain cleanness of design. In an object-oriented program, for example, this may involve refactoring to move data or functions from one class to another [59]. The actual change may occur in any one of several ways. For small changes, obsolete code is replaced by a new code. For large incremental changes, new code is written and then "plugged" into the existing system. Several new classes implementing a new concept may be written, tested, and interfaced with the old classes already in the code. Very often the change will propagate; that is, it will require secondary changes. In order to explain change propagation, we must understand that software consists
34
K. H.BENNETT £74/..
of entities (classes, objects, functions, etc.) and their dependencies. A dependency between entities A and B means that entity B provides certain services, which A requires. A function call is an example of a dependency among functions. Different programming languages or operating systems may provide different kinds of entities and dependencies. A dependency of A on 5 is consistent if the requirements of A are satisfied by what B provides. Dependencies can be subtle and of many kinds. The effect may be at the code level; for example, a module under change may use a global variable in a new way, so all uses of the global variable must be analyzed (and so on). Dependencies can also occur via nonfunctional requirements or business rules. For example, in a real time system, alteration of code may affect the timing properties in subtle ways. For this reason, the analysis of a change, and the determination of which code to alter often cannot easily be compartmentalized. Senior maintenance engineers need a deep understanding of the whole system and how it interacts with its environment to determine how a required change should be implemented while hopefully avoiding damage to the system architecture. The business rules may be extremely complex (e.g., the "business rules" that address the navigation and flight systems in an on-board safety critical flight control system); in an old system, any documentation on such rules has probably been lost, and determining the rules retrospectively can be an extremely time-consuming and expensive task (for example, when the domain expert is no longer available). Implementation of a change in software thus starts with a change to a specific entity of the software. After the change, the entity may no longer fit with the other entities of the software, because it may no longer provide what the other entities require, or it may now require different services from the entities it depends on. The dependencies that no longer satisfy the require-provide relationships are called inconsistent dependencies (inconsistencies for short), and they may arise whenever a change is made in the software. In order to reintroduce consistency into software, the programmer keeps track of the inconsistencies and the locations where the secondary changes are to be made. The secondary changes, however, may introduce new inconsistencies, etc. The process in which the change spreads through the software is sometimes called the ripple effect of the change [60,61]. The programmer must guarantee that the change is correctly propagated, and that no inconsistency is left in the software. An unforeseen and uncorrected inconsistency is one of the most common sources of errors in modified software. A software system consists not just of code, but also of documentation. Requirements, designs, test plans, and user manuals can be quite extensive and they often are also made inconsistent by the change. If the documentation is to be useful in the future, it must also be updated.
SOFTWARE EVOLUTION
35
Obviously the modified software system needs to be validated and verified. The most commonly used technique is regression testing, in which a set of system tests is conserved and rerun on the modified system. The regression test set needs to have fairly good coverage of the existing system if it is to be effective. It grows over time as tests are added for each new concept and feature added. The regression test set will also need to be rerun many times over the life of the project. Regression testing is thus not cheap, so it is highly desirable to automate the running of the tests and the checking of the output. Testing is, however, not enough to guarantee that consistency has been maintained. Inspections can be used at several points in the change miniprocess to confirm that the change is being introduced at the right point, that the resulting code meets standards, and that documentation has indeed been updated for consistency. It is evident that clear understanding of the software system is essential at all points during change implementation. Refactoring requires a vision of the architecture and of the division of responsibilities between modules or classes. Change propagation analysis requires tracing the dependencies of one entity on another, and may require knowledge of subtle timing or business rule dependencies. Documentation updating can be among the most knowledge-demanding tasks since it requires an awareness of the multiple places in each document where any particular concept is described. Even testing requires an understanding of the test set, its coverage, and of where different concepts are tested. In the previous paragraphs we have described what should be done as part of each software change. Given the effort required to "do it right" it is not surprising to discover that, in practice, some of these tasks are skipped or slighted. In each such case, a trade-off is being made between the immediate cost or time and an eventual long-term benefit. As we will discuss in Section 8 it is not necessarily irrational to choose the immediate over the long-term, but all such decisions need to be taken with full awareness of the potential consequences. As we have described earlier, program comprehension is a key determinant of the Hfecycle of any specific software product. To understand why this is so, we need to understand what it means to understand a program, why that understanding is difficult, and how it fits into the cycle of software change.
7.4
Program Comprehension
Program comprehension is carried out with the aim of understanding source code, documentation, test suite, design, etc., by human engineers. It is typically a gradual process of building up understanding, which can then be used further to explain the construction and operation of the program. So program comprehension is the activity of understanding how a program is constructed and its
36
K. H. BENNETT E7^/..
underlying intent. The engineer requires precise knowledge of the data items in the program, the way these items are created, and their relationships [62]. Various surveys have shown that the central activity in maintenance is understanding the source code. Chapin and Lau [63] describe program comprehension as the most skilled and labor-intensive part of software maintenance, while Oman [64] states that the key to effective software maintenance is program comprehension. Thus it is a human-intensive activity that consumes considerable costs. An early survey to the field is [13]; see also von Mayrhauser [65]. The understanding can then be used for: • Maintenance and evolution (e.g., [66]), • Reverse engineering (e.g., [13]), • Learning and training, • Redocumentation (e.g., [67,68]), • Reuse (e.g., [69]), • Testing and validation (e.g., [70]). The field has prompted several theories derived from empirical investigation of the behavior of programmers. There are three fundamental views, see Storey [71]: • Comprehension is undertaken in a top-down way, from requirements to implementation [72,73], • Comprehension is undertaken in a bottom-up way, starting with the source code, and deducing what it does and how it does it [74], and • Comprehension is undertaken opportunistically [75,76]. All three may be used at different times, even by a single engineer. It is encouraging to note that much work on comprehension has been supported by empirical work to gain understanding of what engineers actually do in practice (see, for example, [66,76,77]). To support comprehension, a range of tools has been produced and some of these present information about the program, such as variable usage, call graphs, etc., in a diagrammatic or graphical form. Tools divide into two types: • Static analysis tools, which provide information to the engineer based only on the source code (and perhaps documentation), • Dynamic analysis tools, which provide information as the program executes. More recent work is using virtual reality and much more sophisticated visualization metaphors to help understanding [78].
SOFTWARE EVOLUTION
37
The work on an integrated metamodel [65] has drawn together into a single framework the work on cognition of large software systems. It is based on four components: • Top-down structures, • Situation model, • Program model, and • The knowledge base. It combines the top-down perspective with the bottom-up approach (i.e., situation and program models). The knowledge base addresses information concerned with the comprehension task, and is incremented as new and inferred knowledge is determined. The model is not prescriptive, and different approaches to comprehension may be invoked during the comprehension activity. All authors agree that program comprehension is a human-oriented and timeintensive process, requiring expertise in the programming language and environment, deep understanding of the specific code and its interactions, and also knowledge of the problem domain, the tasks the software performs in that domain, and the relationships between those tasks and the software structure. As mentioned earlier, locating concepts in the code is a program comprehension task that is very important during the phase of change planning. Change requests are very often formulated as requests to change or introduce implementation of specific domain concepts, and the very first task is to find where these concepts are found in the code. A usual assumption behind the concept location task is that the user does not have to understand the whole program, but only the part that is relevant to the concepts involved in the change. In a widely cited paper, Biggerstaff et al. [79] presented a technique of concept location in the program based on the similarity of identifiers used in the program and the names of the domain concepts. When trying to locate a concept in the code, the programmer looks for the variables, functions, classes, etc., with a name similar to the name of the concept. For example when trying to locate implementation of breakpoints in a debugger, the programmer looks for variables with identifiers breakpoint. Breakpoint, break-point, brkpt, etc. Text pattern matching tools like "grep" are used for this purpose. Once the appropriate identifier is found, the programmer reads and comprehends the surrounding code in order to locate all code related to the concept being searched. Another technique of concept or feature location is based on analysis of program execution traces [80]. The technique requires instrumentation of the program so that it can be determined which program branches were executed for a given set of input data. Then the program is executed for two sets of data: data set A with the feature and data set B without the feature. The feature is most probably
38
K. H.BENNETT Ef/^L
located in the branches that were executed for data set A but were not executed for data set B. Another method of concept location is based on static search of code [81]. The search typically starts in function main() and the programmer tries to find the implementation of the concept there. If it cannot be located there, it must be implemented in one of the subfunctions called from main(); hence the programmer decides which subfunction is the most likely to implement the concept. This process is recursively repeated (with possible backtracks) until the concept is found. As remarked earlier, we believe that the comprehensibility of a program is a key part of software quality and evolvability, and that research in program comprehension is one of the key frontiers of research in software evolution and maintenance.
8. 8.1
Sustaining Software Value Staving off the Servicing Stage
One of the goals of our staged model of the software lifecycle is to aid software managers in thinking about the systems they control and in planning their futures. It is clear from our argument so far that a software system subtly loses much of its value to its owners when it makes the transition from the evolution to the servicing stage. A software system in the evolution stage is routinely adapted to changing organizational needs and can thus make a considerable contribution to the organization's mission and/or revenues. When the system transitions into servicing, only the simplest changes can be made; the software is a less valuable asset and may actually become a constraint on the organization's success. Thus, most software managers will want to stave off the servicing stage as long as possible. There are a number of strategies that can be adopted to sustain software value, but unfortunately all of them produce their benefits in the long term, but require an expenditure of effort or time in the short term. A software manager must seek an appropriate trade-off between the immediate budget and time pressures of doing business and the potential long-term benefits of increased software value. The appropriate choice of strategies will obviously not be the same for all companies. An e-business that must change almost daily to survive will focus on rapid change, whereas the owners of an embedded system with stable requirements but life-critical consequences of failure may be able to focus on long-term quality.
SOFTWARE EVOLUTION
39
Thus this section is not prescriptive, but merely tries to identify some of the issues that a software manager or chief architect should consider. We list some of the strategies and techniques that have been proposed, categorizing them by their stage in the lifecycle. Unfortunately, there seems to be very little published analysis that would aid a software manager in estimating the costs and benefits. Research into the actual effectiveness of each would seem to be a priority.
8.2
Strategies during Development
The key decisions during development are those that determine the architecture of the new system and the team composition. These decisions are, of course interrelated; as has been mentioned, many of the more famously evolvable systems such as Unix and VME were the product of a very few highly talented individuals. Advice to "hire a genius" is not misplaced, but is difficult to follow in practice. In the current state of the art, there is probably little that can be done to design an architecture to permit any conceivable change. However it is possible to address systematically those potential changes that can be anticipated, at least in general terms. For instance it is well known that changes are extremely common in the user interfaces to systems, to operating systems, and to hardware, while the underlying data and algorithms may be relatively stable. During initial development a roughly prioritized list of the anticipated changes can be a very useful guide to architectural design [82]. Once possible changes are identified, the main architectural strategy to use is information hiding of those components or constructs most likely to change. Software modules are structured so that design decisions, such as the choice of a particular kind of user interface or a specific operating system, are concealed within one small part of the total system, a technique described by Pamas since the early 1970s [83]. If the anticipated change becomes necessary in the future, only a few modules would need to be modified. The emergence of object-oriented languages in the 1990s has provided additional mechanisms for designing to cope with anticipated changes. These languages provide facilities such as abstract classes and interfaces which can be subclassed to provide new kinds of object which are then used by the rest of the program without modification. Designers can also make use of object-oriented design patterns, many of which are intended to provided flexibility to allow for future software enhancements [84]. For example, the Abstract Factory pattern provides a scheme for constructing a family of related objects that interact, such as in a user interface toolkit. The pattern shows how new object classes can be added, say to provide an alternate look-and-feel, with minimal change to the existing code.
40
K. H. BENNETT ET/AL
In both traditional and object-oriented systems, architectural clarity and consistency can greatly facilitate program comprehension. Similar features should always be implemented in the same way, and if possible by similarly named components. For example, one of the authors once studied a test coverage monitoring system that provided coverage of basic blocks, of decisions, and of several kinds of data flows [85]. The code for each kind of monitoring was carefully segregated into source files, with code to display blocks in a file called b d i s p. c, that to display decisions in d d i s p. c, and so on. Within each file, corresponding functions were named the same; for example, each file had a d i s p I a y () function to handle its particular kind of display. This consistency made it very easy for a maintainer to hypothesize where particular concepts were likely to be located, and greatly speeded up understanding of the program architecture, even in the absence of design documentation. On the other hand, inconsistency in design and naming can lead future maintainers into errors in understanding. Polymorphic object-oriented systems are particularly susceptible to this kind of error, since many member functions may have the same name. They thus cannot easily be distinguished by a maintainer reading the code. If they do not perform precisely the same task, or if one version has side effects not shared by others, then the maintainer may be seriously mislead in reading the code [86]. The best way to achieve architectural consistency is probably to leave the basic design in the hands of a very small team who work together very closely. Temptations to rotate personnel between projects should probably be strongly resisted at this stage. Other programmers may later maintain the consistent design if they are encouraged to study the structure of existing code before adding their own contributions. Consistency may then further be enforced by code inspections or walkthroughs. If the project architecture depends on purchased COTS components, as so many modem projects do, then particular care is needed. First, it would obviously be dangerous to depend heavily on a component that is already in the servicing or phase-out stages. It is thus important to understand the true status of each component, which may require information that the component supplier is reluctant to give. Second, the impact of the possible changes on the COTS component should be considered. For instance, if changes to the hardware platform are anticipated, will the COTS supplier, at reasonable cost, evolve his product to use the new hardware? If not, information hiding design might again be advisable to facilitate the possible substitution of a different COTS component in the future. Programming environments and software tools that generate code may create problems similar to those of COTS. Many such environments assume implicitly that all future changes will take place within the environment. The generated code
SOFTWARE EVOLUTION
41
may be incomprehensible for all practical purposes. Unfortunately, experience indicates that environments, and the companies that produce them, often have much shorter lifetimes than the systems developed using them. Finally, there are well-known coding practices that can greatly facilitate program comprehension and thus software change. In Section 2.4 we have mentioned the use of IEEE or ISO standards, the enforcement of house coding style to guarantee uniform layout and commenting, and an appropriate level of documentation to match the criticality of the project. One coding technique that should probably be used more often is to insert instrumentation into the program to aid in debugging and future program comprehension. Experienced programmers have used such instrumentation for years to record key events, interprocess messages, etc. Unfortunately instrumentation is rarely mandated, and more often introduced ad hoc only after a project has fallen into trouble [87]. If used systematically, it can be a great aid to understand the design of a complex system "as-built" [88]. We should mention again that all the above techniques involve a trade-off between evolvability and development time. The study of potential changes takes time and analysis. Design to accommodate change may require more complex code, which impacts both time and later program comprehension. (At least one project found it desirable to remove design patterns that had been introduced to provide unused flexibility [89].) COTS components and programming environments can greatly speed up initial development, but with serious consequences for future evolvability. Design consistency and coding standards are difficult to enforce unless almost all code is inspected, a time-consuming and thus far from universal practice. In the rush to get a product to market, a manager must be careful about decisions that sacrifice precious time against future benefit.
8.3
Strategies during Evolution
During the evolution phase, the goal must be to delay servicing as long as possible by preserving a clean architecture and by facilitating program comprehension. As previously mentioned, most modem projects transition to the evolution phase with at least some key members of the original development team in place. There are, of course, circumstances when this may not be possible and a transition to a new team is unavoidable. This is a strategy that risks an almost immediate slide into servicing due to the difficulties of program comprehension. If a new team is, however, absolutely essential, then there are some steps that can be taken, such as having developers on-site for some months to aid the transition. Software managers placed in this situation may want to consult some of the papers by Pigoski and others that discuss experiences in software transition [90-92].
42
K. H.BENNETT Er/^L
If it has not already been done, the system should now be placed under configuration management control. From here on, different customers will have different versions, and it is essential to have a mechanism for tracking the revisions of each file that went into making up each version. Without such a mechanism it will be very difficult to interpret problem reports arriving from the field. Change control may be formal or informal, depending on the process used, but change control procedures should be well defined, and it is highly desirable to have one person designated as configuration manager, with responsibility for change control and version tracking. At this stage, if not earlier, the project needs to have a clear strategy for program comprehension. That strategy can include combinations of at least three elements: • Team knowledge, carried by team members who commit to long-term participation in the project, • Written documentation of specifications, design, configurations, tests, etc., or its equivalent in the repository of a software tool, and • Reverse engineering tools to recover design information from the system itself. As evolution starts, team composition may change somewhat, often with some shrinkage. If the project manager intends to rely mainly on team knowledge for program comprehension, this is a good point to take inventory of the available knowledge and to try to avoid over concentration in one or two team members. As previously mentioned, agile development methods such as Extreme Programming often use pair programming, in which two programmers work together on each task [40]. As indicated by the printed circuits program case described in Section 6.7 it is probably unrealistic to expect new programmers to undertake major changes alone, but it may be possible to get them to work in a pair with a more experienced programmer. It is desirable to avoid the well-known ''guru" phenomenon, in which one person is the only expert in an important part of the project. The guru often tends to adopt that part as his territory, and makes it difficult for anyone else to work with that code. Once this situation is established, it can be very difficult to manage. A guru problem is obviously dangerous for the future of the project and can also have a bad impact on team morale. If the manager decides to emphasize written documentation for program comprehension, then there will be considerable overhead to revise and update all such documentation as the system evolves. It is likely that any design documentation available at the beginning of evolution will represent the system the developers intended to build, which may differ substantially from what was actually built.
SOFTWARE EVOLUTION
43
A useful technique is incremental redocumentation, in which documentation is generated or updated as modules are modified. A trainee programmer may be assigned to do the write-up, based on notes or an interview with the experienced programmer who actually made the modification, thus reducing the cost and schedule impact of the redocumentation. One of the authors has given a case study showing how this strategy was applied to a large C-I~l- system [93]. The manager needs to establish a tricky balance between programmers' desire to restructure or rewrite code and the economics of the project. Unless they wrote it themselves, programmers will almost always complain of the quaUty of the code they encounter! Some such complaints are certainly well founded as restructuring and refactoring may be needed to maintain a clean architecture. However, if all such requests are approved, the burden of coding, inspecting, and especially testing will become unsustainable. Key decisions in the evolution phase concern the creation of new versions and the transition to servicing. If the versioned staged model of Fig. 2 is followed, the new version will probably start development well before the old one passes into servicing. Management should make a conscious decision as to the paths to be followed, based on judgments about the state of the system and the demands of the market.
8.4 Strategies during Servicing The transition into servicing implies that further change will be relatively minor, perhaps involving bug fixes and peripheral new features. It is important to understand that the transition is largely irreversible since essential knowledge and architectural integrity have probably been lost. If the product is to be reengineered, it is likely that the best strategy will be simply to try to reproduce its black-box behavior rather than to study and reuse its current code or design [94]. Often there may be a transition to a new maintenance team as servicing begins. Expectations about what can be accomplished by such a team should be kept modest to avoid impossible commitments. Configuration management must continue in place to be able to understand reports from the field. Strategies such as opportunistic redocumentation may still be desirable, but fixes that degrade the code may be tolerated since the basic strategy is to minimize cost while maintaining revenue in the short run. Finally, the servicing stage is the time to make and implement a plan for phaseout. Migration paths to a new version in development should be provided. The main issue is often the need to recover and reformat vital organizational data so that it can be used in the new version.
44
9.
K. H. BENNETT Er/\L.
Future Directions: Ultra Rapid Software Evolution
It is possible to inspect each activity of the staged software model and determine how it may be speeded up. Certainly, new technology to automate parts may be expected, supported by tools (for example, in program comprehension, testing etc.). However, it is very difficult to see that such improvements will lead to a radical reduction in the time to evolve a large software system. This prompted us to believe that a new and different way is needed to achieve "ultra rapid evolution"; we term this "evolution in Internet time." It is important to stress that such ultra rapid evolution does not imply poor quality, or software that is simply hacked together without thought. The real challenge is to achieve very fast change yet provide very-high-quality software. Strategically, we plan to achieve this by bringing the evolution process much closer to the business process. The generic problem of ultra rapid evolution is seen as one of the grand challenges for software engineering (see [95,96]). The staged model allows us to address a large system built out of many parts (and so on recursively). Each part may be in one of the five stages (although we would expect the main stress to be the first three stages). This has been ignored in previous research. The integration mechanism is market-led, not simply a technical binding, and requires the representation of nontechnical and nonfunctional attributes of the parts. The new perspective offered by the staged model has been a crucial step in developing a seniceware approach. For software evolution, it is useful to categorize contributing factors into those which can rapidly evolve, and those which cannot, see Table I. We concluded that a "silver bullet," which would somehow transform software into something that could be changed (or could change itself) far more quickly than at present, was not viable. Instead, we take the view that software is actually TABLE I CONTRIBUTING FACTORS OF SOFTWARE EVOLUTION
Fast moving
Slow moving
Software requirements Marketplaces Organizations Emergent companies Demand led Competitive pressures Supply chain delivery Risk taking New business processes Near-business software
Software functionality Skills bases Standards Companies with rigid boundaries Supply led Long-term contracts Software technology Risk averse Software process evolution Software infrastructure
SOFTWARE EVOLUTION
45
hard to change, and thus that change takes time to accompHsh. We needed to look for other solutions. Let us now consider a very different scenario. We assume that our software is structured into a large number of small components that exactly meet the user's needs and no more. Suppose now that a user requires an improved component C. The traditional approach would be to raise a change request with the vendor of the software, and wait for several months for this to be (possibly) implemented, and the modified component integrated. In our solution, the user disengages component C, and searches the marketplace for a replacement D that meets the new needs. When this is found, it replaces C, and is used in the execution of the application. Of course, this assumes that the marketplace can provide the desired component. However, it is a wellestablished property of marketplaces that they can spot trends, and make new products available when they are needed. The rewards for doing so are very strong and the penalties for not doing so are severe. Note that any particular component supplier can (and probably will) use traditional software maintenance techniques to evolve their components. The new dimension is that they must work within a demand-led marketplace. Therefore, if we can find ways to disengage an existing component and bind in a new one (with enhanced functionality and other attributes) ultra rapidly, we have the potential to achieve ultra-rapid evolution in the target system. This concept led us to conclude that the fundamental problem with slow evolution was a result of software that is marketed as a product, in a supply-led marketplace. By removing the concept of ownership, we have instead a service, i.e., something that is used, not owned. Thus, we generalized the component-based solution to the much more generic service-based software in a demand-led marketplace [97]. This service-based model of software is one in which services are configured to meet a specific set of requirements at a point in time, executed and disengaged— the vision of instant service. A service is used rather than owned [98]; it may usefully be considered to comprise a communications protocol together with a service behavior. Services are composed from smaller ones (and so on recursively), procured and paid for on demand. A service is not a mechanized process; it involves humans managing supplier-consumer relationships. This is a radically new industry model, which could function within markets ranging from a genuine open market (requiring software functional equivalence) to a keisetzu market, where there is only one supplier and consumer, both working together with access to each other's information systems to optimize the service to each other. This strategy potentially enables users to create, compose, and assemble a service by bringing together a number of suppliers to meet needs at a specific
46
K. H. BENNETT Er>^L
point in time. An analogy is selling cars: today manufacturers do not sell cars from a premanufactured stock with given color schemes, features, etc.; instead customers configure their desired car from a series of options and only then is the final product assembled. This is only possible because the technology of production has advanced to a state where assembly of the final car can be undertaken sufficiently quickly. Software vendors attempt to offer a similar model of provision by offering products with a series of configurable options. However, this offers extremely limited flexibility—consumers are not free to substitute functions with those from another supplier since the software is subject to binding, which configures and links the component parts, making it very difficult to perform substitution. The aim of this research is to develop the technology which will enable binding to be delayed until immediately before the point of execution of a system. This will enable consumers to select the most appropriate combination of services required at any point in time. However, late binding comes at a price, and for many consumers, issues of reliability, security, cost, and convenience may mean that they prefer to enter into contractual agreements to have some early binding for critical or stable parts of a system, leaving more volatile functions to late binding and thereby maximizing competitive advantage. The consequence is that any future approach to software development must be interdisciplinary so that nontechnical issues, such as supply contracts, terms, and conditions, and error recovery are addressed and built into the new technology. A truly service-based role for software is far more radical than current approaches, in that it seeks to change the very nature of software. To meet users' needs of evolution, flexibility, and personalization, an open marketplace framework is necessary in which the most appropriate versions of software products come together, and are bound and executed as and when needed. At the extreme, the binding that takes place prior to execution is disengaged immediately after execution in order to permit the "system" to evolve for the next point of execution. Flexibility and personalization are achieved through a variety of service providers offering functionality through a competitive marketplace, with each software provision being accompanied by explicit properties of concern for binding (e.g., dependability, performance, quality, license details, etc.). A component is simply a reusable software executable. Our serviceware clearly includes the software itself, but in addition has many nonfunctional attributes, such as cost and payment, trust, brand allegiance, legal status and redress, and security. Binding requires us to negotiate across all such attributes (as far as possibly electronically) to establish a binding, at the extreme just before execution.
SOFTWARE EVOLUTION
47
Requirements for software need to be represented in such a way that an appropriate service can be discovered on the network. The requirements must convey therefore both the description and intention of the desired service. Given the highly dynamic nature of software suppUed as a service, the maintainabiUty of the requirements representation becomes an important consideration. However, the aim of the architecture is not to prescribe such representation, but support whatever conventions users and service suppliers prefer. Automated negotiation is another key issue for research, particularly in areas where nonnumeric terms are used, e.g., legal clauses. Such clauses do not lend themselves to offer/counteroffer and similar approaches. In relation to this, the structure and definition of profiles and terms need much work, particularly where terms are related in some way (e.g., performance and cost). Also we need insight to the issue of when to select a service and when to enter negotiations for a service. It is in this area that multidisciplinary research is planned. We plan to concentrate research in these areas, and use as far as possible available commercial products for the software infrastructure. Finally, many issues need to be resolved concerning mutual performance monitoring and claims of legal redress should they arise.
10.
Conclusions
We have presented a new staged model of the software lifecycle, motivated by the need to formulate an abstraction that is supported partly by empirical published evidence, and partly by the authors' field experiences. In particular, we have observed how the "project knowledge" has been progressively lost over the lifecycle, and the enormous implications for our ability successfully to support the software. We have argued that by understanding the staged model, a manager can better plan and resource a project, in particular to avoid it slipping into servicing irreversibly. We also indicated some future directions based on this approach. ACKNOWLEDGMENTS
Keith Bennett thanks members of the Pennine Research Group at Durham, UMIST, and Keele Universities for the collaborative research which has led to the author's input to this chapter (in particular Malcolm Munro, Paul Layzell, Linda Macauley, Nicolas Gold, Pearl Brereton, and David Budgen). He also thanks the Leverhulme Trust, BT, and EPSRC for generous support, and Deborah Norman for help in preparing the chapter. Vaclav Rajlich thanks Tony Mikulec from Ford Motor Co. for generous support of research in software maintenance. Also discussions with Franz Lehner while visiting University of Regensburg, and with Harry Sneed on several occasions influenced the author's thinking about this area.
48
K. H.BENNETT Er/\/..
Norman Wilde thanks the support of the Software Engineering Research Center (SERC) over the past 15 years; its industrial partners have taught him most of what he knows about software maintenance. More recently the US Air Force Office of Scientific Research under Grant F49620-99-1-0057 has provided an opportunity to study the FASTGEN system mentioned as one of the case studies. REFERENCES
[1] IEEE (1990). Standard Glossary of Software Engineering Terminology, standard IEEE Std 610.12-1990, IEEE, Los Alamitos, CA. Also IEEE Software EngineeringIEEE Standards Collection. IEEE, New York, 1994. [2] McDermid, J. A. (Ed.) (1991). The Software Engineer's Reference Book, Butterworth-Heinemann, London. [3] Royce, W. W. (1970). "Managing the development of large software systems." Proc. IEEE WESCON 1970, pp. 1-9. IEEE, New York. [Reprinted in Thayer, R. H. (Ed.). IEEE Tutorial on Software Engineering Project Management.] [4] Boehm, B. W. (1988). 'A spiral model of software development and enhancement." IEEE Computer, May, 61-72. [5] Rajlich, V. T., and Bennett, K. H. (2000). 'A staged model for the software Hfecycle." IEEE Computer, 33, 66-71. [6] Pigoski, T. R (1997). Practical Software Maintenance: Best Practices for Managing Your Software Investment. Wiley, New York. [7] Lientz, B., and Swanson, E. B. (1980). Software Maintenance Management: a Study of the Maintenance of Computer Application Software in 487 Data Processing Organisations. Addison-Wesley, Reading, MA. [8] Lientz, B., Swanson, E. B., and Tompkins, G. E. (1978). "Characteristics of applications software maintenance." Communications of the ACM, 21, 466-471. [9] Sommerville, I. (1995). Software Engineering. Addison Wesley, Reading, MA. [10] Pressman, R. S. (1996). Software Engineering. McGraw-Hill, New York. [11] Warren, I. (1999). The Renaissance of Legacy Systems. Springer-Verlag, London. [12] Foster, J. R. (1993). Cost Factors in Software Maintenance, Ph.D. Thesis. Computer Science Department, University of Durham. [13] Robson, D. J., Bennett, K. H., Munro, M., and ComeHus, B. J. (1991). "Approaches to program comprehension." Journal of Systems and Software, 14, 79-84. [Reprinted in Arnold, R. (Ed.) (1992). Software Re-engineering. IEEE Computer Society Press, Los Alamitos, CA.] [14] IEEE. Standard for Software Maintenance, p. 56. IEEE, Los Alamitos, CA. [15] International Standards Organisation (1999). International Standard Information Technology: Software Maintenance, ISO/IEC 14764:1999. International Standards Organisation. [16] Wirth, N. (1971). "Program development by stepwise refinement." Communications of the ACM, U.
SOFTWARE EVOLUTION
49
[17] Basili, V. R., and Turner, A. J. (1975). "Iterative enhancement: A practical technique for software development." IEEE Transactions on Software Engineering 1, 90-396. (An updated version was pubUshed as Auerbach Report 14-01-05, 1978, and in Tutorial on Software Maintenance, IEEE Computer Society Press, Los Alamitos, CA, 1982). [18] Brooks, F. The Mythical Man-Month: Essays on Software Engineering. AddisonWesley, Reading, MA. [ 19] Lehman, M. M., and Beladay, L. A. (1976). "A model of large program development." IBM System Journal 3, 225-252. [20] Burch, E., and Kunk, H. (1997). "Modeling software maintenance requests: A case study." Proc. IEEE International Conference on Software Maintenance, pp. 40-47. IEEE Computer Society Press, Los Alamitos, CA. [21] Lehman, M. M. (1980). "Programs, lifecycles, and the laws of software evolution." IEEE Transactions on Software Engineering, 68, 1060-1076. [22] Lehman, M. M. (1984). "Program evolution." Information Processing Management, 20, 19-36. [23] Lehman, M. M. (1985). Program Evolution. Academic Press, London. [24] Lehman, M. M. (1989). "Uncertainty in computer application and its control through the engineering of software." Journal of Software Maintenance, 1, 3-28. [25] Lehman, M. M., and Ramil, J. F. (1998). "Feedback, evolution and software technology—Some results from the FEAST Project, Keynote Lecture." Proceedings 11th International Conference on Software Engineering and its Application, Vol. 1, Paris, 8-10 Dec, pp. 1-12. [26] Ramil, J. R, Lehman, M. M., and Kahen, G. (2000). "The FEAST approach to quantitative process modelling of software evolution processes." Proceedings PROFES'2000 2nd International Conference on Product Focused Software Process Improvement, Oulu, Finland, 20-22 June (F. Bomarius and M. Oivo, Eds.), Lecture Notes on Computer Science 1840, pp. 311-325. Springer-Verlag, Berlin. This paper is a revised version of the report: Kahen, G., Lehman, M. M., Ramil, J. F. (2000). "Model-based assessment of software evolution processes." Research Report 2000/4. Department of Computers, Imperial College. [27] Lehman, M. M., Perry, D. E., and Ramil, J. F. (1998). "Implications of evolution metrics on software maintenance." International Conference on Soft. Maintenance (ICSM'98), Bethesda, Maryland, Nov. 16-24, pp. 208-217. [28] Ramil, J. F., and Lehman, M. M. (1999). "Challenges facing data collection for support and study of software evolution processes," position paper. ICSE 99 Workshop on Empirical Studies of Software Development and Evolution, Los Angeles, May 18. [29] Sneed, H. M. (1989). Software Engineering Management (I. Johnson, TransL). Ellis Horwood, Chichester, West Sussex, pp. 20-21. Original German ed. Software Management, Rudolf Mueller Verlag, Koln, 1987. [30] Lehner, F. (1989). "The software lifecycle in computer applications." Long Range Planning, Vol. 22, No. 5, pp. 38-50. Pergamon Press, Elmsford, NY.
50
K. H.BENNETT E7^/..
[31] Lehner, F. (1991). "Software lifecycle management based on a phase distinction method." Microprocessing and Microprogramming, Vol. 32, pp. 603-608. NorthHolland, Amsterdam. [32] Truex, D. P., Baskerville, R., and Klein, H. (1999). "Growing systems in emergent organizations." Commun. ACM 42, 117-123. [33] Cusumano, M., and Yoffe, D. (1998). Competing on Internet Time-Lessons from Netscape and Its Battle with Microsoft. Free Press (Simon & Schuster), New York. [34] Bennett, K. H. (1995). "Legacy systems: Coping with success." IEEE Software 12, 19-23. [35] Henderson, P. (Ed.) (2000). Systems Engineering for Business Process Change. Springer-Verlag, Berlin. [36] UK EPSRC (1999). "Systems Engineering for Business Process Change." Available at h t t p : / / w w w . s t a f f . e c s . s o t o n . a c . u k / ~ p h / s e b p c . [37] Pfleeger, S. L., and Menezes, W. (2000). "Technology transfer: Marketing technology to software practitioners." IEEE Software 17, 27-33. [38] Naur, P., and Randell, B. (Eds.) (1968). "Software engineering concepts and techniques," NATO Science Committee. Proc. NATO Conferences, Oct. 7-11, Garmisch, Germany. Petrocelli/Charter, New York. [39] Shaw, M., and Garland, D. (1996). Software Architectures. Prentice-Hall, Englewood
cuffs, NJ. [40] Beck, K. (1999). "Embracing change with extreme programming." IEEE Computer 32, 70-77. [41] International Computers Ltd., "The Architecture of Open VME," ICL publication ref. 55480001. ICL, Stevenage, Herts, UK, 1994. [42] Cusumano, M. A., and Selby, R. W. (1997). Microsoft Secrets. HarperCollins, New York. [43] Jacobson, I., Booch, G., and Rumbaugh, J. (1999). The Unified Software Development Process. Addison-Wesley, Reading, MA. [44] Booch, G. (2001). "Developing the future." Commun. ACM, 44, 119-121. [45] Pamas, D. L. (1994). "Software aging." Proceedings 16th International Conference on Software Engineering, pp. 279-287. IEEE Computer Society Press, Los Alamitos, CA. [46] Eick, S. G., Graves, T. L., Karr, A. R, Marron, J. S., and Mockus, A. (2001). "Does code decay? Assessing evidence from change management data." IEEE Transactions on Software Engineering, 27, 1-12. [47] Rajlich, V., Wilde, N., Buckellew, M., and Page, H. (2001). "Software cultures and evolution." IEEE Computer, 34, 24-28. [48] Johnson, J. H. (1994). "Substring matching for clone detection and change tracking." Proceedings IEEE International Conference on Software Maintenance, Victoria, Canada, Sept., pp. 120-126.
SOFTWARE EVOLUTION
51
[49] Baxter, D., Yahin, A., Moura, L., Sant'Anna, M., and Bier, L. (1998). "Clone detection using abstract trees." IEEE International Conference on Software Maintenance, pp. 368-377. [50] Lagu, B., Proulx, D., Mayrand, J., Merlo, E. M., and Hudepohl, J. (1997). "Assessing the benefits of incorporating function clone detection in a development process." IEEE International Conference on Software Maintenance, pp. 314-331. [51] Burd, E., and Munro, M. (1997). "Investigating the maintenance implications of the replication of code." IEEE International Conference on Software Maintenance, pp. 322-329. [52] Olsem, M. R. (1998). An incremental approach to software systems reengineering." Software Maintenance: Research and Practice 10, 181-202. [53] Canfora, G., De Lucia, A., and Di Lucca, G. (1999). "An incremental object-oriented migration strategy for RPG legacy systems." International Journal of Software Engineering and Knowledge Engineering, 9, 5-25. [54] Tamai, T., and Torimitsu, Y. (1992). "Software lifetime and its evolution process over generations." Proc. IEEE International Conference on Software Maintenance, pp. 63-69. [55] Kappelman, L. A. (2000). "Some strategic Y2K blessings." IEEE Software, 17, 42-46. [56] Fanta, R., and Rajlich, V. (1998). "Reengineering object-oriented code." Proc. IEEE International Conference on Software Maintenance, pp. 238-246. [57] Fanta, R., and Rajlich, V. "Removing clones from the code." Journal of Software Maintenance, 1, 223-243. [58] Wilde, N., Buckellew, M., Page, H., and Rajlich, V. (2001). "A case study of feature location in unstructured legacy Fortran code." Proceedings CSMR'Ol, pp. 68-76. IEEE Computer Society Press, Los Alamitos, CA. [59] Fowler, M. (1999). Refactoring: Improving the Design of Existing Code. AddisonWesley, Reading, MA. [60] Yau, S. S., Collofello, J. S., and MacGregor, T. (1978). "Ripple effect analysis of software maintenance." Proc. IEEE COMPSAC, pp. 60-65. [61] Rajlich, V. (2000). "Modeling software evolution by evolving interoperation graphs." Annals of Software Engineering, 9, 235-248. [62] Ogando, R. M., Yau, S. S., Liu, S. S., and Wilde, N. (1994). "An object finder for program structure understanding in software maintenance." Journal of Software Maintenance: Research and Practice, 6, 261-283. [63] Chapin, N., and Lau, T. S. (1996). "Effective size: An example of USE from legacy systems." Journal of Software Maintenance: Research and Practice, 8, 101-116. [64] Oman, P (1990). "Maintenance tools." IEEE Software, 1, 59-65. [65] Von Mayrhauser, A., and Vans, A. M. (1995). "Program comprehension during software maintenance and evolution." IEEE Computer, 28, 44-55.
52
K. H.BENNETT Er>^L
[66] Littman, D. C , Pinto, J., Letovsky, S.. and Soloway, E. (1986). "Mental models and software maintenance." Empirical Studies of Programmers (E. Soloway and S. Iyengar, Eds.), pp. 80-98. Ablex, Norwood, NJ. [67] Basili, V. R., and Mills, H. D. (1982). "Understanding and documenting programs." IEEE Transactions on Software Engineering, 8, 270-283. [68] Younger, E. J., and Bennett, K. H. (1993). "Model-based tools to record program understanding." Proceedings of the IEEE 2nd International Workshop on Program Comprehension, July 8-9, Capri, Italy, pp. 87-95. IEEE Computer Society Press, Los Alamitos, CA. [69] Standish, T. A. (1984). "An essay on software reuse." IEEE Transactions on Software Engineering, 10, 494^97. [70] Weiser, M., and Lyle, J. (1986). "Experiments on slicing-based debugging aids." Empirical Studies of Programmers (E. Soloway and S. Iyengar, Eds.), pp. 187-197. Albex, Norwood, NJ. [71] Storey, M. A. D., Fracchia, F. D., and Muller, H. A. (1997). "Cognitive design elements to support the construction of a mental model during software visualization." Proceedings of the 5th IEEE International Workshop on Program Comprehension, May 28-30, pp. 17-28. [72] Brooks, R. (1983). "Toward a theory of comprehension of computer programs." International Journal of Man-Machine Studies, 18, 542-554. [73] Soloway, E., and Ehrlich, K. (1984). "Empirical studies of programming knowledge." IEEE Transactions on Software Engineering, 10, 595-609. [74] Pennington, N. (1987). "Stimulus structures and mental representations in expert comprehension of computer programs." Cognitive Psychology, 19, 295-341. [75] Letovsky, S. (1987). "Cognitive processes in program comprehension." Journal of Systems and Software, 7, 325-339. [76] Von Mayrhauser, A., Vans, A. M., and Howe, A. E. (1997). "Program understanding behaviour during enhancement of large-scale software." Journal of Software Maintenance: Research and Practice, 9, 299-327. [77] Shneiderman, B., and Mayer, R. (1979). "Syntactic/semantic interactions in programmer behaviour: A model and experimental results." International Journal of Computer and Information Sciences, 8, 219-238. [78] Knight, C , and Munro, M. (1999). "Comprehension with[in] virtual environment visualisations." Proceedings IEEE 7th International Workshop on Program Comprehension, May 5-7, pp. 4-11. [79] Biggerstaff, T., Mitbander, B., and Webster, D. (1994). "Program understanding and concept assignment problem." Communications of ACM, 37, 72-83. [80] Wilde, N., and Scully, M. (1995). "Software reconnaissance: Mapping program features to code." Journal of Software Maintenance: Research and Practice, 1,49-62. [81] Chen, K., and Rajlich, V. (2000). "Case study of feature location using dependency graph." Proc. International Workshop on Program Comprehension, pp. 241-249. IEEE Computer Society Press, Los Alamitos, CA.
SOFTWARE EVOLUTION
53
[82] Hager, J. A. (1989). "Developing maintainable systems: A full life-cycle approach." Proceedings Conference on Software Maintenance, pp. 271-278. Oct. 16-19. IEEE Computer Society Press, Los Alamitos, CA. [83] Pamas, D. L. (1972). "On the criteria to be used in decomposing systems into modules." Communications of the ACM, 29, 1053-1058. [84] Gamma, E., Helm, R., Johnson, R., and Vlissides, J. (1995). Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading, MA. [85] Wilde, N., and Casey, C. (1996). "Early field experience with the software reconnaissance technique for program comprehension." Proceedings International Conference on Software Maintenance—ICSM'96, pp. 312-318. IEEE Computer Society Press, Los Alamitos, CA. [86] Wilde, N., and Huitt, R. (1992). "Maintenance support for object-oriented programs." IEEE Transactions on Software Engineering, 18, 1038-1044. [87] Wilde, N., and Knudson, D. (1999). "Understanding embedded software through instrumentation: Preliminary results from a survey of techniques," Report SERCTR-85-F, Software Engineering Research Center, Purdue University. Available at h t t p : //www. cs.uwf . edu/~wilde/publicatioiis/TecRpt85F_ExSuin. html. [88] Wilde, N., Casey, C , Vandeville, J., Trio, G., and Hotz, D. (1998). "Reverse engineering of software threads: A design recovery technique for large multi-process systems." Journal of Systems and Software, 43, 11-17. [89] Wendorff, P. (2001). "Assessment of design patterns during software reengineering: Lessons learned from a large commercial project." Proceedings Fifth European Conference on Software Maintenance and Reengineering—CSMR'Ol, pp. 77-84. IEEE Computer Society Press, Los Alamitos, CA. [90] Pigoski, T. M., and Sexton, J. (1990). "Software transition: A case study." Proceedings Conference on Software Maintenance, pp. 200-204. IEEE Computer Society Press, Los Alamitos, CA. [91] Vollman, T. (1990). "Transitioning from development to maintenance." Proceedings Conference on Software Maintenance, pp. 189-199. IEEE Computer Society Press, Los Alamitos, CA. [92] Pigoski, T. M., and Cowden, C. A. (1992). "Software transition: Experience and lessons learned." Proceedings Conference on Software Maintenance, pp. 294-298. IEEE Computer Society Press, Los Alamitos, CA. [93] Rajlich, V. (2000). "Incremental redocumentation using the web." IEEE Software, 17, 102-106. [94] Bollig, S., and Xiao, D. (1998). "Throwing off the shackles of a legacy system." IEEE Computer, 31, 104-109. [95] Bennett, K. H., Layzell, P J., Budgen, D., Brereton, O. P., Macaulay, L., and Munro, M. (2000). "Service-based software: The future for flexible software," IEEE APSEC2000. The Asia-Pacific Software Engineering Conference, Singapore, 5-8 December. IEEE Computer Society Press, Los Alamitos, CA.
b4
K. H. BENNETT E7>^/..
[96] Bennett, K. H., Munro, M., Brereton, O. P., Budgen, D., Layzell, P. J., Macaulay, L., Griffiths, D. G., and Stannet, C. (1999). 'The future of software." Communications of ACM, 42, 78-84. [97] Bennett, K. H., Munro, M., Gold, N. E., Layzell, P. J., Budgen, D., and Brereton, O. P. (2001). "An architectural model for service-based software with ultra rapid evolution." Proc. IEEE International Conference on Software Maintenance, Florence, to appear. [98] Lovelock, C., Vandermerwe, S., and Lewis, B. (1996). Services Marketing. PrenticeHall Europe, Englewood Cliffs, NJ. ISBN 013095991X.
Embedded Software EDWARD A. LEE Department of Electrical Engineering and Computer Science University of California—Berkeley 518 Cory Hall Berkeley CA 94720-1770 USA
[email protected]
Abstract The science of computation has systematically abstracted away the physical world. Embedded software systems, however, engage the physical world. Time, concurrency, liveness, robustness, continuums, reactivity, and resource management must be remarried to computation. Prevailing abstractions of computational systems leave out these "nonfunctional" aspects. This chapter explains why embedded software is not just software on small computers, and why it therefore needs fundamentally new views of computation. It suggests component architectures based on a principle called "actor-oriented design," where actors interact according to a model of computation, and describes some models of computation that are suitable for embedded software. It then suggests that actors can define interfaces that declare dynamic aspects that are essential to embedded software, such as temporal properties. These interfaces can be structured in a "system-level-type system" that supports the sort of design-time- and run-time-type checking that conventional software benefits from.
1. What is Embedded Software? 2. Just Software on Small Computers? 2.1 TimeUness 2.2 Concurrency 2.3 Liveness 2.4 Interfaces 2.5 Heterogeneity 2.6 Reactivity 3. Limitations of Prevailing Software Engineering Methods 3.1 Procedures and Object Orientation 3.2 Hardware Design ADVANCES IN COMPUTERS, VOL. 56 ISBN 0-12-012156-5
55
56 57 58 58 59 60 61 62 62 63 63
Copyright 2002 Elsevier Science Ltd All rights of reproduction in any form reserved.
56
EDWARD A. LEE
3.3 Real-Time Operating Systems 3.4 Real-Time Object-Oriented Models 4. Actor-Oriented Design 4.1 Abstract Syntax 4.2 Concrete Syntaxes 4.3 Semantics 4.4 Models of Computation 5. Examples of Models of Computation 5.1 Dataflow 5.2 Time Triggered 5.3 Synchronous/Reactive 5.4 Discrete Events 5.5 Process Networks 5.6 Rendezvous 5.7 Publish and Subscribe 5.8 Continuous Time 5.9 Finite State Machines 6. Choosing a Model of Computation 7. Heterogeneous Models 8. Component Interfaces 8.1 On-line-type Systems 8.2 Reflecting Program Dynamics 9. Frameworks Supporting Models of Computation 10. Conclusions Acknowledgments References
1.
64 65 65 66 67 68 69 71 71 72 73 74 74 75 76 76 76 79 82 84 85 86 88 89 89 90
What is Embedded Software?
Deep in the intellectual roots of computation is the notion that software is the realization of mathematical functions as procedures. These functions map a body of input data into a body of output data. The mechanism used to carry out the procedure is not nearly as important as the abstract properties of the function. In fact, we can reduce the mechanism to seven operations on a machine (the famous Turing machine) with an infinite tape capable of storing zeros and ones [1]. This mechanism is, in theory, as good as any other mechanism, and therefore, the significance of the software is not affected by the mechanism. Embedded software is not like that. Its principal role is not the transformation of data, but rather the interaction with the physical world. It executes on machines that are not, first and foremost, computers. They are cars, airplanes, telephones, audio equipment, robots, appliances, toys, security systems, pacemakers, heart
EMBEDDED SOFTWARE
b/
monitors, weapons, television sets, printers, scanners, climate control systems, manufacturing systems, and so on. Software with a principal role of interacting with the physical world must, of necessity, acquire some properties of the physical world. It takes time. It consumes power. It does not terminate (unless it fails). It is not the ideaUzed procedures of Alan Turing. Computer science has tended to view this physicality of embedded software as messy. Consequently, the design of embedded software has not benefited from the richly developed abstractions of the 20th century. Instead of using object modeling, polymorphic-type systems, and automated memory management, engineers write assembly code for idiosyncratic digital signal processors (DSPs) that can do finite impulse response filtering in one (deterministic) instruction cycle per tap. The engineers that write embedded software are rarely computer scientists. They are experts in the application domain with a good understanding of the target architectures they work with. This is probably appropriate. The principal role of embedded software is interaction with the physical world. Consequently, the designer of that software should be the person who best understands that physical world. The challenge to computer scientists, should they choose to accept it, is to invent better abstractions for that domain expert to do her job. Today's domain experts may resist such help. In fact, their skepticism is well warranted. They see Java programs stalling for one-third of a second to perform garbage collection and update the user interface, and they envision airplanes falling out of the sky. The fact is that the best-of-class methods offered by computer scientists today are, for the most part, a poor match to the requirements of embedded systems. At the same time, however, these domain experts face a serious challenge. The complexity of their applications (and consequent size of their programs) is growing rapidly. Their devices now often sit on a network, wireless or wired. Even some programmable DSPs now run a TCP/IP protocol stack, and the applications are getting much more dynamic, with downloadable customization and migrating code. Meanwhile, reliability standards for embedded software remain very high, unlike general-purpose software. At a minimum, the methods used for general-purpose software require considerable adaptation for embedded software. At a maximum, entirely new abstractions that embrace physicality and deliver robustness are needed.
2.
Just Software on Small Computers?
An arrogant view of embedded software is that it is just software on small computers. This view is naive. Timeliness, concurrency, liveness, reactivity, and
58
EDWARD A. LEE
heterogeneity need to be an integral part of the programming abstractions. They are essential to the correctness of a program. It is not sufficient to realize the right mapping from input data to output data.
2.1
Timeliness
Time has been systematically removed from theories of computation. 'Ture" computation does not take time, and has nothing to do with time. It is hard to overemphasize how deeply rooted this is in our culture. So-called "real-time" operating systems often reduce the characterization of a component (a process) to a single number, its priority. Even most "temporal" logics talk about "eventually" and "always," where time is not a quantifier, but rather a qualifier [2]. Attempts to imbue object-oriented design with real-time are far from satisfactory [3]. Much of the problem is that computation does take time. Computer architecture has been tending toward making things harder for the designers of embedded systems. A large part of the (architectural) performance gain in modern processors comes from statistical speedups such as elaborate caching schemes, speculative instruction execution, dynamic dispatch, and branch prediction. These techniques compromise the reliability of embedded systems. In fact, most embedded processors such as programmable DSPs and microcontrollers do not use these techniques. I believe that these techniques have such a big impact on average case performance that they are indispensable. However, software practitioners will have to find abstractions that regain control of time, or the embedded system designers will continue to refuse to use these processors. The issue is not just that execution takes time. Even with infinitely fast computers, embedded software would still have to deal with time because the physical processes, with which it interacts, evolve over time.
2.2
Concurrency
Embedded systems rarely interact with only a single physical process. They must simultaneously react to stimulus from a network and from a variety of sensors, and at the same time, retain timely control over actuators. This impHes that embedded software is concurrent. In general-purpose software practice, management of concurrency is primitive. Threads or processes, semaphores, and monitors [4] are the classic tools for managing concurrency, but I view them as comparable to assembly language in abstraction. They are very difficult to use reliably, except by operating system experts. Only trivial designs are completely comprehensible (to most engineers). Excessively conservative rules of thumb dominate (such as always grab locks in the same order [5]). Concurrency theory has much to offer that has not made its
EMBEDDED SOFTWARE
59
way into widespread practice, but it probably needs adaptation for the embedded system context. For instance, many theories reduce concurrency to "interleavings," which trivialize time by asserting that all computations are equivalent to sequences of discrete timeless operations. Embedded systems engage the physical world, where multiple things happen at once. Reconciling the sequentiality of software and the concurrency of the real world is a key challenge in the design of embedded systems. Classical approaches to concurrency in software (threads, processes, semaphore synchronization, monitors for mutual exclusion, rendezvous, and remote procedure calls) provide a good foundation, but are insufficient by themselves. Complex compositions are simply too hard to understand. An alternative view of concurrency that seems much better suited to embedded systems is implemented in synchronous/reactive languages [6] such as Esterel [7], which are used in safety-critical real-time applications. In Esterel, concurrency is compiled away. Although this approach leads to highly reliable programs, it is too static for some networked embedded systems. It requires that mutations be handled more as incremental compilation than as process scheduling, and incremental compilation for these languages proves to be challenging. We need an approach somewhere in between that of Esterel and that of today's realtime operating systems, with the safety and predictability of Esterel and the adaptability of a real-time operating system.
2.3
Liveness
In embedded systems, liveness is a critical issue. Programs must not terminate or block waiting for events that will never occur. In the Turing view of computation, all nonterminating programs fall into an equivalence class that is implicitly deemed to be a class of defective programs. In embedded computing, however, terminating programs are defective. The term "deadlock" pejoratively describes premature termination of such systems. It is to be avoided at all costs. In the Turing paradigm, given a sufficiendy rich abstraction for expressing procedures, it is undecidable whether those procedures halt. This undecidability has been inconvenient because we cannot identify programs that fail to halt. Now it should be viewed as inconvenient because we cannot identify programs that fail to keep running. Moreover, correctness cannot be viewed as getting the right final answer. It must take into account the timeliness of a continuing stream of partial answers, as well as other "nonfunctional" properties. A key part of the prevailing computation paradigm is that software is defined by the function it computes. The premise is that the function models everything interesting about the software. Even for the portions of embedded software that terminate (and hence have an
60
EDWARD A. LEE
associated "computable function"), this model is a poor match. A key feature of embedded software is its interaction with physical processes, via sensors and actuators. Nonfunctional properties include timing, power consumption, fault recovery, security, and robustness.
2.4
Interfaces
Software engineering has experienced major improvements over the past decade or so through the widespread use of object-oriented design. Object-oriented design is a component technology, in the sense that a large complicated design is composed of pieces that expose interfaces that abstract their own complexity. The use of interfaces in software is not new. It is arguable that the most widely applied component technology based on interfaces is procedures. Procedures are finite computations that take predefined arguments and produce final results. Procedure libraries are marketable component repositories, and have provided an effective abstraction for complex functionality. Object-oriented design aggregates procedures with the data that they operate on (and renames the procedures "methods"). Procedures, however, are a poor match for many embedded system problems. Consider, for example, a speech coder for a cellular telephone. It is artificial to define the speech coder in terms of finite computations. It can be done of course. However, a speech coder is more like a process than a procedure. It is a nonterminating computation that transforms an unbounded stream of input data into an unbounded stream of output data. Indeed, a commercial speech coder component for cellular telephony is likely to be defined as a process that expects to execute on a dedicated signal processor. There is no widely accepted mechanism for packaging the speech coder in any way that it can safely share computing resources with other computations. Processes, and their cousin, threads, are widely used for concurrent software design. Processes can be viewed as a component technology, where a multitasking operating system or multithreaded execution engine provides the framework that coordinates the components. Process interaction mechanisms, such as monitors, semaphores, and remote procedure calls, are supported by the framework. In this context, a process can be viewed as a component that exposes at its interface an ordered sequence of external interactions. However, as a component technology, processes and threads are extremely weak. A composition of two processes is not a process (it no longer exposes at its interface an ordered sequence of external interactions). Worse, a composition of two processes is not a component of any sort that we can easily characterize. It is for this reason that concurrent programs built from processes or threads are so hard to get right. It is very difficult to talk about the properties of the aggregate
EMBEDDED SOFTWARE
61
because we have no ontology for the aggregate. We don't know what it is. There is no (understandable) interface definition. Object-oriented interface definitions work well because of the type systems that support them. Type systems are one of the great practical triumphs of contemporary software. They do more than any other formal method to ensure correctness of (practical) software. Object-oriented languages, with their user-defined abstract data types, and their relationships between these types (inheritance, polymorphism) have had a big impact in both reusability of software (witness the Java class libraries) and the quality of software. Combined with design patterns [8] and object modeling [9], type systems give us a vocabulary for talking about larger structure in software than lines of code and procedures. However, object-oriented programming talks only about static structure. It is about the syntax of procedural programs, and says nothing about their concurrency or dynamics. For example, it is not part of the type signature of an object that the initialize() method must be called before the fire() method. Temporal properties of an object (method x() must be invoked every 10 ms) are also not part of the type signature. For embedded software to benefit from a component technology, that component technology will have to include dynamic properties in interface definitions.
2.5
Heterogeneity
Heterogeneity is an intrinsic part of computation in embedded systems. They mix computational styles and implementation technologies. First, such systems are often a mixture of hardware and software designs, so that the embedded software interacts with hardware that is specifically designed to interact with it. Some of this hardware has continuous-time dynamics, which is a particularly poor match to prevailing computational abstractions. Embedded systems also mix heterogeneous event handling styles. They interact with events occurring irregularly in time (alarms, user commands, sensor triggers, etc.) and regularly in time (sampled sensor data and actuator control signals). These events have widely different tolerances for timeliness of reaction. Today, they are intermingled in real-time software in ad hoc ways; for example, they might be all abstracted as periodic events, and rate-monotonic principles [10] might be used to assign priorities. Perhaps because of the scientific training of most engineers and computer scientists, the tendency is to seek a grand-unified theory, the common model that subsumes everything as a special case, and that can, in principle, explain it all. We find it anathema to combine multiple programming languages, despite the fact that this occurs in practice all the time. Proponents of any one language are sure, absolutely sure, that their language is fully general. There is no need for
62
EDWARD A. LEE
any other, and if only the rest of the world would understand its charms, they would switch to using it. This view will never work for embedded systems, since languages are bound to fit better or worse for any given problem.
2.6
Reactivity
Reactive systems are those that react continuously to their environment at the speed of the environment. Harel and Pnueli [11] and Berry [12] contrast them with interactive systems, which react with the environment at their own speed, and transformational systems, which simply take a body of input data and transform it into a body of output data. Reactive systems have real-time constraints, and are frequently safety-critical, to the point that failures could result in loss of human life. Unlike transformational systems, reactive systems typically do not terminate (unless they fail). Robust distributed networked reactive systems must be capable of adapting to changing conditions. Service demands, computing resources, and sensors may appear and disappear. Quality of service demands may change as conditions change. The system is therefore continuously being redesigned while it operates, and all the while it must not fail. A number of techniques for providing more robust support for reactive system design than what is provided by real-time operating systems have emerged. The synchronous languages, such as Esterel [7], Lustre [13], Signal [14], and Argos [15], are reactive, have been used for applications where validation is important, such as safety-critical control systems in aircraft and nuclear power plants. Lustre, for example, is used by Schneider Electric and Aerospatiale in France. Use of these languages is rapidly spreading in the automotive industry, and support for them is beginning to appear on commercial EDA (electronic design automation) software. Reactive systems must typically react simultaneously to multiple sources of stimulus. Thus, they are concurrent. The synchronous languages manage concurrency in a very different way than that found in real-time operating systems. Their mechanism makes much heavier use of static (compile-time) analysis of concurrency to guarantee behavior. However, compile-time analysis of concurrency has a serious drawback: it compromises modularity and precludes adaptive software architectures.
3.
Limitations of Prevailing Software Engineering Methods
Construction of complex embedded software would benefit from component technology. Ideally, these components are reusable, and embody valuable
EMBEDDED SOFTWARE
63
expertise in one or more aspects of the problem domain. The composition must be meaningful, and ideally, a composition of components yields a new component that can be used to form other compositions. To work, these components need to be abstractions of the complex, domain-specific software that they encapsulate. They must hide the details, and expose only the essential external interfaces, with well-defined semantics.
3.1
Procedures and Object Orientation
A primary abstraction mechanism of this sort in software is the procedure (or in object-oriented culture, a method). Procedures are terminating computations. They take arguments, perform a finite computation, and return results. The real world, however, does not start, execute, complete, and return. Object orientation couples procedural abstraction with data to get data abstraction. Objects, however, are passive, requiring external invocation of their methods. So-called "active objects" are more like an afterthought, requiring still a model of computation to have any useful semantics. The real world is active, more like processes than objects, but with a clear and clean semantics that is firmly rooted in the physical world. So while object-oriented design has proven extremely effective in building large software systems, it has little to offer to address the specific problems of the embedded system designer. A sophisticated component technology for embedded software will talk more about processes than procedures, but we must find a way to make these processes compositional, and to control their real-time behavior in predictable and understandable ways. It will talk about concurrency and the models of computation used to regulate interaction between components. And it will talk about time.
3.2
Hardware Design
Hardware design, of course, is more constrained than software by the physical world. It is instructive to examine the abstractions that have worked for hardware, such as synchronous design. The synchronous abstraction is widely used in hardware to build large, complex, and modular designs, and has recently been applied to software [6], particularly for designing embedded software. Hardware models are conventionally constructed using hardware description languages such as Verilog and VHDL; these languages realize a discrete-event model of computation that makes time a first-class concept, information shared by all components. Synchronous design is done through a stylized use of these languages. Discrete-event models are often used for modeling complex systems.
64
EDWARD A. LEE
particularly in the context of networking, but have not yet (to my knowledge) been deployed into embedded system design. Conceptually, the distinction between hardware and software, from the perspective of computation, has only to do with the degree of concurrency and the role of time. An application with a large amount of concurrency and a heavy temporal content might as well be thought of using hardware abstractions, regardless of how it is implemented. An application that is sequential and has no temporal behavior might as well be thought of using software abstractions, regardless of how it is implemented. The key problem becomes one of identifying the appropriate abstractions for representing the design.
3.3
Real-Time Operating Systems
Most embedded systems, as well as many emerging applications of desktop computers, involve real-time computations. Some of these have hard deadlines, typically involving streaming data and signal processing. Examples include communication subsystems, sensor and actuator interfaces, audio and speech processing subsystems, and video subsystems. Many of these require not just real-time throughput, but also low latency. In general-purpose computers, these tasks have been historically delegated to specialized hardware, such as SoundBlaster cards, video cards, and modems. In embedded systems, these tasks typically compete for resources. As embedded systems become networked, the situation gets much more complicated, because the combination of tasks competing for resources is not known at design time. Many such embedded systems incorporate a real-time operating system, which offers specialized scheduling services tuned to real-time needs, in addition to standard operating system services such as I/O. The schedules might be based on priorities, using for example the principles of rate-monotonic scheduling [10,16], or on deadlines. There remains much work to be done to improve the match between the assumptions of the scheduling principle (such as periodicity, in the case of rate-monotonic scheduling) and the realities of embedded systems. Because the match is not always good today, many real-time embedded systems contain hand-built, specialized microkernels for task scheduling. Such microkernels, however, are rarely sufficiently flexible to accommodate networked applications, and as the complexity of embedded applications grows, they will be increasingly difficult to design. The issues are not simple. Unfortunately, current practice often involves fine tuning priorities until a particular implementation seems to work. The result is fragile systems that fail when anything changes. A key problem in scheduling is that most techniques are not compositional. That is, even if assurances can be provided for an individual component, there are no systematic mechanisms for providing assurances to the aggregate of two
EMBEDDED SOFTWARE
65
components, except in trivial cases. A chronic problem with priority-based scheduling, known as priority inversion, is one manifestation of this problem. Priority inversion occurs when processes interact, for example, by using a monitor to obtain exclusive access to a shared resource. Suppose that a lowpriority process has access to the resource, and is preempted by a medium-priority process. Then a high-priority process preempts the medium-priority process and attempts to gain access to the resource. It is blocked by the low-priority process, but the low-priority process is blocked by the presence of an executable process with higher priority, the medium-priority process. By this mechanism, the highpriority process cannot execute until the medium-priority process completes and allows the low-priority process to relinquish the resource. Although there are ways to prevent priority inversion (priority inheritance and priority ceiling protocols, for example), the problem is symptomatic of a deeper failure. In a priority-based scheduling scheme, processes interact both through the scheduler and through the mutual exclusion mechanism (monitors) supported by the framework. These two interaction mechanisms together, however, have no coherent compositional semantics. It seems like a fruitful research goal to seek a better mechanism.
3.4
Real-Time Object-Oriented Models
Real-time practice has recently been extended to distributed component software in the form of real-time CORBA and related models [17] and real-time objectoriented modeling (ROOM) [18]. CORBA is fundamentally a distributed objectoriented approach based on remote procedure calls. Built upon this foundation of remote procedure calls are various services, including an event service that provides a publish-and-subscribe semantics. Real-time CORBA extends this further by associating priorities with event handling, and leveraging real-time scheduling for processing events in a timely manner. Real-time CORBA, however, is still based on prevailing software abstractions. Thus, for effective real-time performance, a programmer must specify various numbers, such as worst-case and typical execution times for procedures, cached and not. These numbers are hard to know precisely. Real-time scheduling is then driven by additional parameters such as periodicity, and then tweaked with semantically weak parameters called "importance" and "criticality." These parameters, taken together, amount to guesses, as their actual effect on system behavior is hard to predict except by experimentation.
4.
Actor-Oriented Design
Object-oriented design emphasizes inheritance and procedural interfaces. We need an approach that, like object-oriented design, constructs complex
66
EDWARD A. LEE
applications by assembling components, but emphasizes concurrency and communication abstractions, and admits time as a first-class concept. I suggest the term actor-oriented design for a refactored software architecture, where instead of objects, the components are parameterized actors with ports. Ports and parameters define the interface of an actor. A port represents an interaction with other actors, but unlike a method, does not have call-return semantics. Its precise semantics depends on the model of computation, but conceptually it represents signaling between components. There are many examples of actor-oriented frameworks, including Simulink (from The MathWorks), Lab VIEW (from National Instruments), Easy 5x (from Boeing), SPW (the Signal Processing Worksystem, from Cadence), and Cocentric System studio (from Synopsys). The approach has not been entirely ignored by the software engineering community, as evidenced by ROOM [18] and some architecture description languages (ADLs, such as Wright [19]). Hardware design languages, such as VHDL, Verilog, and SystemC, are all actor-oriented. In the academic community, active objects and actors [20,21], timed I/O automata [22], Polls and Metropolis [23], Giotto [24], and Ptolemy and Ptolemy II [25] all emphasize actor orientation. Agha uses the term "actors," which he defines to extend the concept of objects to concurrent computation [26a]. Agha's actors encapsulate a thread of control and have interfaces for interacting with other actors. The protocols used for this interface are called interaction patterns, and are part of the model of computation. My use of the term "actors" is broader, in that I do not require the actors to encapsulate a thread of control, but I share with Agha the notion of interaction patterns, which I call the "model of computation." Agha argues that no model of concurrency can or should allow all communication abstractions to be directly expressed. He describes message passing as akin to "gotos" in their lack of structure. Instead, actors should be composed using an interaction policy. These more specialized interaction policies will form models of computation.
4.1
Abstract Syntax
It is useful to separate syntactic issues from semantic issues. An abstract syntax defines how a design can be decomposed into interconnected components, without being concerned with how a design is represented on paper or in a computer file (that is the concern of the concrete syntax). An abstract syntax is also not concerned with the meaning of the interconnections of components, nor even what a component is. A design is a set of components and relationships among them, where the relationships conform to this abstract syntax. Here, we describe the abstract syntax using informal diagrams that illustrate these sets and relations
67
EMBEDDED SOFTWARE
by giving use cases, although formaUzing the abstract syntax is necessary for precision. Consider the diagram in Fig. 1. This shows three components (actors), each with one port, and an interconnection between these ports mediated by a relation. This illustrates a basic abstract syntax. The abstract syntax says nothing about the meaning of the interconnection, but rather just merely that it exists. To be useful, the abstract syntax is typically augmented with hierarchy, where an actor is itself an aggregate of actors. It can be further elaborated with such features as ports supporting multiple links and relations representing multiple connections. An elaborate abstract syntax of this type is described in [25].
4.2
Concrete Syntaxes
The abstract syntax may be associated with any number of concrete syntaxes. For instance, an XML schema might be used to provide a textual representation of a structure [26b]. A visual editor may provide a diagrammatic syntax, like that shown in Fig. 2. Actor-oriented design does not require visual syntaxes. However, visual depictions of systems have always held a strong human appeal, making them extremely effective in conveying information about a design. Many of the methods described in this chapter can use such depictions to completely and formally specify models. Visual syntaxes can be every bit as precise and complete as textual syntaxes, particularly when they are judiciously combined with textual syntaxes. Visual representations of models have a mixed history. In circuit design, schematic diagrams used to be routinely used to capture all of the essential information needed to implement some systems. Today, schematics are usually replaced by text in hardware description languages such as VHDL or Verilog. In other contexts, visual representations have largely failed, for example, flowcharts for
Actor ^ ^ Relation ^ f r. ^ ^ Link ^^^ Link ^ Port M ^ M I V I Parameters J W
Actor „ ^ Port Parameters
FIG. 1. Abstract syntax of actor-oriented designs.
68
EDWARD A. LEE
..JGl ill m
view
Edit Graph
utilities director library 1 ^ actor library Graphics
Help
^
ThiS modei illustrates composae types m Ptolemy 11, The Record Assembler actor composes a strmg with an integer mto a record token which is then passed through a channel that has random delay. The tokerts amve possibly in another order The Record Dssassembter actor separates the string from the sequence number. The strings are displayed as received (possible out of order), and resequenced by the Sequencer actor, which puts them back m order This example demonstrates how types propagate through record composition and decomposition
^
Master Ctock Strmg Sequence 1
>-
I
Record As&embler
t~~*t ^^^ f—\ m I
Sequence C o u n t ^ W i
1
Record Disassembler channel M( hannei Model • pjgpfay f^^
The channel ss modeled by a vanable delay, which here is random with a Rayleigh dtstribution
H
FIG. 2. An example of a visual concrete syntax. This is the visual editor for Ptolemy II [25] called Vergil, designed by Steve Neuendorffer.
capturing the behavior of software. Recently, a number of innovative visual formalisms, including visual dataflow, hierarchical concurrent finite state machines, and object models, have been garnering support. The UML visual language for object modeling, for example, has been receiving a great deal of practical use [3,27].
4.3
Semantics
A semantics gives meaning to components and their interconnection. It states, for example, that a component is a process, and a connection represents communication between processes. Alternatively, a component may be a state, and a connection may represent a transition between states. In the former case, the semantics may restrict how the communication may occur. These semantic models can be viewed as architectural patterns [28], although for the purposes of this chapter, I will call them models of computation. One of my objectives here is to codify a few of the known models of computation that are useful for embedded software design. Consider a family of models of computation where components are producers or consumers of data (or both). In this case, the ports acquire the property of being inputs, outputs, or both. Consider for example the diagram in Fig. 3.
EMBEDDED SOFTWARE
• ~~ N send(t) - ^ A P E1
69
receiver, put(t) /" ZZiT" ^^^^^^^-^--^f^ SetO ^ ©P2 E: token token tty
FIG. 3. Producer-consumer communication mechanism.
This diagram has two actors, one producer and one consumer. The diagram suggests a port that is an output by showing an outgoing arrow, and an input by showing an ingoing arrow. It also shows a simpUfied version of the Ptolemy II data transport mechanism [25]. The producer sends a token t (which encapsulates user data) via its port by calling a send() method on that port. This results in a call to the put() method of the receiver in the destination port. The destination actor retrieves the token by calling get() on the port. This mechanism, however, is polymorphic, in the sense that it does not specify what it means to call put() or get(). This depends on the model of computation. A model of computation may be very broad or very specific. The more constraints there are, the more specific it is. Ideally, this specificity comes with benefits. For example, Unix pipes do not support feedback structures, and therefore cannot deadlock. Common practice in concurrent programming is that the components are threads that share memory and exchange objects using semaphores and monitors. This is a very broad model of computation with few benefits. In particular, it is hard to talk about the properties of an aggregate of components because an aggregate of components is not a component in the framework. Moreover, it is difficult to analyze a design in such a model of computation for deadlock or temporal behavior. A model of computation is often deeply ingrained in the human culture of the designers that use it. It fades out of the domain of discourse. It can be argued that the Turing sequentiality of computation is so deeply ingrained in contemporary computer science culture that we no longer realize just how thoroughly we have banished time from computation. In a more domain-specific context, users of modeling languages such as Simulink rarely question the suitability of the semantics to their problem at hand. To such users, it does not "have semantics," it just "is." The key challenge in embedded software research is to invent or identify models of computation with properties that match the application domain well. One of the requirements is that time be central to the model.
4.4
Models of Computation
A model of computation can be thought of as the "laws of physics" that govern component interactions. It is the programmer's model, or the conceptual
70
EDWARD A. LEE
framework within which larger designs are constructed by composing components. Design of embedded software will require models of computation that support concurrency. In practice, concurrency seriously complicates system design. No universal model of computation has yet emerged for concurrent computation (although some proponents of one approach or another will dispute this). By contrast, for sequential computation. Von Neumann provided a wildly successful universal abstraction. In this abstraction, a program consists of a sequence of transformations of the system state. In distributed systems, it is difficult to maintain a global notion of "system state," an essential part of the Von Neumann model, since many small state transformations are occurring simultaneously, in arbitrary order. In networked embedded systems, communication bandwidth and latencies will vary over several orders of magnitude, even within the same system design. A model of computation that is well suited to small latencies (e.g., the synchronous hypothesis used in digital circuit design, where computation and communication take "zero" time) is usually poorly suited to large latencies, and vice versa. Thus, practical designs will almost certainly have to combine techniques. It is well understood that effective design of concurrent systems requires one or more levels of abstraction above the hardware support. A hardware system with a shared memory model and transparent cache consistency, for example, still requires at least one more level of abstraction in order to achieve determinate distributed computation. A hardware system based on high-speed packet-switched networks could introduce a shared-memory abstraction above this hardware support, or it could be used directly as the basis for a higher level of abstraction. Abstractions that can be used include the event-based model of Java Beans, semaphores based on Dijkstra's P/V systems [29], guarded communication [30], rendezvous, synchronous message passing, active messages [31], asynchronous message passing, streams (as in Kahn process networks [32]), dataflow (commonly used in signal and image processing), synchronous/reactive systems [6], Linda [33], and many others. These abstractions partially or completely define a model of computation. Applications are built on a model of computation, whether the designer is aware of this or not. Each possibility has strengths and weaknesses. Some guarantee determinacy, some can execute in bounded memory, and some are provably free from deadlock. Different styles of concurrency are often dictated by the application, and the choice of model of computation can subtly aifect the choice of algorithms. While dataflow is a good match for signal processing, for example, it is a poor match for transaction-based systems, control-intensive sequential decision making, and resource management. It is fairly common to support models of computation with language extensions or entirely new languages. Occam, for example, supports synchronous
EMBEDDED SOFTWARE
71
message passing based on guarded communication [30]. Esterel [7], Lustre [13], Signal [14], and Argos [15] support the synchronous/reactive model. These languages, however, have serious drawbacks. Acceptance is slow, platforms are limited, support software is limited, and legacy code must be translated or entirely rewritten. An alternative approach is to explicitly use models of computation for coordination of modular programs written in standard, more widely used languages. The system-level specification language SystemC for hardware systems, for example, uses this approach (see h t t p : / / s y s t e m c . org). In other words, one can decouple the choice of programming language from the choice of model of computation. This also enables mixing such standard languages in order to maximally leverage their strengths. Thus, for example, an embedded application could be described as an interconnection of modules, where modules are written in some combination of C, Java, and VHDL. Use of these languages permits exploiting their strengths. For example, VHDL provides FPGA targeting for reconfigurable hardware implementations. Java, in theory, provides portability, migratability, and a certain measure of security. C provides efficient execution. The interaction between modules could follow any of several principles, e.g., those of Kahn process networks [32]. This abstraction provides a robust interaction layer with loosely synchronized communication and support for mutable systems (in which subsystems come and go). It is not directly built into any of the underlying languages, but rather interacts with them as an application interface. The programmer uses them as a design pattern [8] rather than as a language feature. Larger applications may mix more than one model of computation. For example, the interaction of modules in a real-time, safety-critical subsystem might follow the synchronous/reactive model of computation, while the interaction of this subsystem with other subsystems follows a process networks model. Thus, domain-specific approaches can be combined.
5.
Examples of Models of Computation
There are many models of computation, each dealing with concurrency and time in different ways. In this section, I oudine some of the most useful models for embedded software. All of these will lend a semantics to the same abstract syntax shown in Fig. 1.
5.1
Dataflow
In dataflow models, actors are atomic (indivisible) computations that are triggered by the availability of input data. Connections between actors represent the
72
EDWARD A. LEE
flow of data from a producer actor to a consumer actor. Examples of commercial frameworks that use dataflow models are SPW (signal processing worksystem, from Cadence) and Lab VIEW (from National Instruments). Synchronous dataflow (SDF) is a particularly restricted special case with the extremely useful property that deadlock and boundedness are decidable [34-38]. Boolean dataflow (BDF) is a generalization that sometimes yields to deadlock and boundedness analysis, although fundamentally these questions remain undecidable [39]. Dynamic dataflow (DDF) uses only run-time analysis, and thus makes no attempt to statically answer questions about deadlock and boundedness [40-42]. A small but typical example of an embedded software application modeled using SDF is shown in Fig. 4. That example shows a sound synthesis algorithm that consists of four actors in a feedback loop. The algorithm synthesizes the sound of a plucked string instrument, such as a guitar, using the well-known Karplus-Strong algorithm.
5.2
Time Triggered
Some systems with timed events are driven by clocks, which are signals with events that are repeated indefinitely with a fixed period. A number of software frameworks and hardware architectures have evolved to support this highly regular style of computation. SDF Director
This model implements the Karplus-Strong algorithm for generating a piucked-string musical instrument sound.
0#lay
Lowpass Filter
AIIpass FJItar
M
' jtl^^^"
^G&m
^
- X 1
D
AudioPlayer
FIG. 4. A synchronous dataflow model implemented in the SDF domain (created by Stephen Neuendorflfer) of Ptolemy II [25]. This model uses the audio library created by Brian Vogel.
EMBEDDED SOFTWARE
73
The time-triggered architecture [43] is a hardware architecture supporting such models. The TTA takes advantage of this regularity by statically scheduling computations and communications among distributed components. In hardware design, cycle-driven simulators stimulate computations regularly according to the clock ticks. This strategy matches synchronous hardware design well, and yields highly efficient simulations for certain kinds of designs. In the Scenic system [44], for example, components are processes that run indefinitely, stall to wait for clock ticks, or stall to wait for some condition on the inputs (which are synchronous with clock ticks). Scenic also includes a clever mechanism for modeling preemption, an important feature of many embedded systems. Scenic has evolved into the SystemC specification language for system-level hardware design (see h t t p : / / s y s t e m c . org). The Giotto programming language [24] provides a time-triggered software abstraction which, unlike the TTA or cycle-driven simulation, is hardware independent. It is intended for embedded software systems where periodic events dominate. It combines with finite-state machines (see below) to yield modal models that can be quite expressive. An example of a helicopter controller in Giotto is described in [45]. Discrete-time models of computation are closely related. These are commonly used for digital signal processing, where there is an elaborate theory that handles the composition of subsystems. This model of computation can be generalized to support multiple sample rates. In either case, a global clock defines the discrete points at which signals have values (at the ticks).
5.3
Synchronous/Reactive
In the synchronous/reactive (SR) model of computation [6], connections between components represent data values that are aligned with global clock ticks, as with time-triggered approaches. However, unlike time-triggered and discretetime approaches, there is no assumption that all (or even most) signals have a value at each time tick. This model efficiently deals with concurrent models with irregular events. The components represent relations between input and output values at each tick, allowing for absences of value, and are usually partial functions with certain technical restrictions to ensure determinacy. Sophisticated compiler techniques yield extremely efficient execution that can reduce all concurrency to a sequential execution. Examples of languages that use the SR model of computation include Esterel [7], Signal [14], and Lustre [46]. An example of an application for which the synchronous reactive model is ideally suited is the management of a token-ring protocol for media access control, described in [9]. In this application, a token circulates in a round-robin fashion among users of a communication medium. When a user makes a request for
74
EDWARD A. LEE
access, if the user has the token, access is granted immediately. If not, then access may still be granted if the current holder of the token does not require access. The SR realization of this protocol yields predictable, deterministic management of access. This application benefits from the SR semantics because it includes instantaneous dialog and convergence to a fixed point (which determines who gets access when there is contention). SR models are excellent for applications with concurrent and complex control logic. Because of the tight synchronization, safety-critical real-time applications are a good match. However, also because of the tight synchronization, some applications are overspecified in the SR model, which thus limits the implementation alternatives and makes distributed systems difficult to model. Moreover, in most realizations, modularity is compromised by the need to seek a global fixed point at each clock tick.
5.4
Discrete Events
In discrete-event (DE) models of computation, the connections represent sets of events placed on a time line. An event consists of a value and time stamp. This model of computation is popular for specifying hardware and for simulating telecommunications systems, and has been realized in a large number of simulation environments, simulation languages, and hardware description languages, including VHDL and Verilog. Like SR, there is a globally consistent notion of time, but unlike SR time has a metric, in that the time between events has significance. DE models are often used in the design of communication networks. Figure 2 above gives a very simple DE model that is typical of this usage. That example constructs packets and routes them through a channel model. In this case, the channel model has the feature that it may reorder the packets. A sequencer is used to reconstruct the original packet order. DE models are also excellent descriptions of concurrent hardware, although increasingly the globally consistent notion of time is problematic. In particular, it overspecifies (or overmodels) systems where maintaining such a globally consistent notion is difficult, including large VLSI chips with high clock rates, and networked distributed systems. A key weakness is that it is relatively expensive to implement in software, as evidenced by the relatively slow simulators.
5.5
Process Networks
A common way of handling concurrent software is where components are processes or threads that communicate by asynchronous, buffered message passing. The sender of the message need not wait for the receiver to be ready to receive
EMBEDDED SOFTWARE
75
the message. There are several variants of this technique, but I focus on one that ensures determinate computation, namely Kahn process networks [32]. In a Kahn process network (PN) model of computation, the connections represent sequences of data values (tokens), and the components represent functions that map input sequences into output sequences. Certain technical restrictions on these functions are necessary to ensure determinacy, meaning that the sequences are fully specified. Dataflow models are a special case of process networks that construct processes as sequences of atomic actor firings [47]. PN models are excellent for signal processing [48]. They are loosely coupled, and hence relatively easy to parallelize or distribute. They can be implemented efficiently in both software and hardware, and hence leave implementation options open. A key weakness of PN models is that they are awkward for specifying complicated control logic. Control logic is specified by routing data values.
5.6
Rendezvous
In synchronous message passing, the components are processes, and processes communicate in atomic, instantaneous actions called rendezvous. If two processes are to communicate, and one reaches the point first at which it is ready to communicate, then it stalls until the other process is ready to communicate. "Atomic" means that the two processes are simultaneously involved in the exchange, and that the exchange is initiated and completed in a single uninterruptable step. Examples of rendezvous models include Hoare's communicating sequential processes (CSP) [30] and Milner's calculus of communicating systems (CCS) [49]. This model of computation has been realized in a number of concurrent programming languages, including Lotos and Occam. Rendezvous models are particularly well matched to appHcations where resource sharing is a key element, such as client-server database models and multitasking or multiplexing of hardware resources. A key weakness of rendezvous-based models is that maintaining determinacy can be difficult. Proponents of the approach, of course, cite the ability to model nondeterminacy as a key strength. Rendezvous models and PN both involve threads that communicate via message passing, synchronously in the former case and asynchronously in the latter. Neither model intrinsically includes a notion of time, which can make it difficult to interoperate with models that do include a notion of time. In fact, message events are partially ordered, rather than totally ordered as they would be were they placed on a time line. Both models of computation can be augmented with a notion of time to promote interoperability and to directly model temporal properties (see, for example, [50]). In the Pamela system [51], threads assume that time does not advance while they are active, but can advance when they stall on inputs, outputs, or explicitly indicate
76
EDWARD A. LEE
that time can advance. By this vehicle, additional constraints are imposed on the order of events, and determinate interoperability with timed models of computation becomes possible. This mechanism has the potential of supporting lowlatency feedback and configurable hardware.
5.7
Publish and Subscribe
In publish-and-subscribe models, connections between components are via named event streams. A component that is a consumer of such streams registers an interest in the stream. When a producer produces an event to such a stream, the consumer is notified that a new event is available. It then queries a server for the value of the event. Linda is a classic example of a fully elaborated publish-andsubscribe mechanism [52]. It has recendy been reimplemented in JavaSpaces, from Sun Microsystems. An example of a distributed embedded software application using JavaSpaces is shown in Fig. 5.
5.8
Continuous Time
Physical systems can often be modeled using coupled differential equations. These have a natural representation in the abstract syntax of Fig. 1, where the connections represent continuous-time signals (functions of the time continuum). The components represent relations between these signals. The job of an execution environment is to find a fixed-point, i.e., a set of functions of time that satisfy all the relations. Differential equations are excellent for modeling the physical systems with which embedded software interacts. Joint modeling of these physical systems and the software that interacts with them is essential to developing confidence in a design of embedded software. Such joint modeling is supported by such actororiented modeling frameworks as Simulink, Saber, VHDL-AMS, and Ptolemy II. A Ptolemy II continuous-time model is shown in Fig. 6.
5.9
Finite State Machines
All of the models of computation considered so far are concurrent. It is often useful to combine these concurrent models hierarchically with finite-state machines (FSMs) to get modal models. FSMs are different from any of the models we have considered so far in that they are strictly sequential. A component in this model is called a state or mode, and exactly one state is active at a time. The connections between states represent transitions, or transfer of control between states. Execution is a strictly ordered sequence of state transitions. Transition
77
EMBEDDED SOFTWARE
SDF Publisherl I" r""" """""V
TiltSensorO
r^j^~
»-
w E
^^B||||ip»-
J
p — -
Pyblisher2
1
1 SDF LegoDriver14 ouiiirv
J 4.
jj^^i 1 -^
*-
• . — pumiuMiimmm^
Subscribe r2
1 ' ^feii^i
X ScaleX
Ih—^omm
%
luwayp
X
^
r
^ r
•
^
^
^
1
^
jfcUMMy
"4 n
"w
^^
\mmmpL
SumL 4. 1
15[
FIG. 5. A distributed embedded application using JavaSpaces combined with SDF to realize a publish-and-subscribe model of computation. The upper left model reads sensor data from a tilt sensor and publishes the data on the network. The lower model subscribes to the sensor data and uses it to drive the Lego robot at the upper right. This example was built by Jie Liu and Xiaojun Liu.
systems are a more general version, in that a given component may represent more than one system state (and there may be an infinite number of components). FSM models are excellent for describing control logic in embedded systems, particularly safety-critical systems. FSM models are amenable to in-depth formal analysis, using for example model checking, and thus can be used to avoid surprising behavior. Moreover, FSMs are easily mapped to either hardware or software implementations. FSM models have a number of key weaknesses. First, at a very fundamental level, they are not as expressive as the other models of computation described here. They are not sufficiently rich to describe all partial recursive functions. However, this weakness is acceptable in light of the formal analysis that becomes possible. Many questions about designs are decidable for FSMs and undecidable
78
EDWARD A. LEE
Continuous TJm« (CT) Ojrectof
This model shows a nonlinear feedback system that exhibits chaotic behavior. It is modeled in continuous time. The CT director uses a sophisticated ordmary differential equation solver to execute the model. This particular model is known as a Lorenz attractor.
^mmm
•
J ^
T"""^""""°l
^ Ex|>res^on 1
Integral
A ^ ^ L"-*
IH
Expresslor ^ 2
1
\-
^•'
>--|
Ejqare^or 1 3 V. V.
|„
*•' 4"
•-H
Strange Attractor
^BBH
Integral
Ir Integrat
u^ diL
FIG. 6. A nonlinear feedback system modeled in the continuous-time (CT) domain in Ptolemy II. This model exhibits the chaotic behavior plotted at the right. This model and the CT domain were created by Jie Liu.
for Other models of computation. Another key weakness is that the number of states can get very large even in the face of only modest complexity. This makes the models unwieldy. The latter problem can often be solved by using FSMs in combination with concurrent models of computation. This was first noted by Harel, who introduced the Statecharts formalism. Statecharts combine synchronous/reactive modeling with FSMs [53a]. Statecharts have been adopted by UML for modeling the dynamics of software [3,27]. FSMs have also been combined with differential equations, yielding the so-called hybrid systems model of computation [53b]. FSMs can be hierarchically combined with a huge variety of concurrent models of computation. We call the resulting formahsm "^charts" (pronounced "starcharts") where the star represents a wildcard [54]. Consider the model shown in Fig. 7. In that figure, component B is hierarchically refined by another model consisting of three components, c, d, and e. These latter three components are states of a state machine, and the connections between them are state transitions. States c and e are shown refined to concurrent models
79
EMBEDDED SOFTWARE
A
H
1^
B
^
"n F UJ G U.
FIG. 7. Hierarchical composition of an FSM with concurrent models of computation.
themselves. The interpretation is that while the FSM is in state c, then component B is in fact defined by component H. While it is in state e, component B is defined by a composition of F and G. In the figure, square boxes depict components in a concurrent model of computation, while circles depict states in a state machine. Despite the different concrete syntax, the abstract syntax is the same: components with interconnections. If the concurrent model of computation is SR, then the combination has Statechart semantics. If it is continuous time, then the combination has hybrid systems semantics. If it is PN, then the combination is similar to the SDL language [55]. If it is DE, then the combination is similar to Polis [23]. A hybrid system example implemented in Ptolemy II is shown in Fig. 8.
6.
Choosing a Model of Computation
The rich variety of models of computation outlined above can be daunting to a designer faced with having to select them. Most designers today do not face this choice because they get exposed to only one or two. This is changing, however, as the level of abstraction and domain-specificity of design practice both rise. We expect that sophisticated and highly visual user interfaces will be needed to enable designers to cope with this heterogeneity.
80
EDWARD A. LEE
abs(Force) > SJidkiness Separate-pl = PI, Separate.p2 = PI: Ssparate.vl = V I ; Separate.v2 = V I
T
STi
Gain
I
FIG. 8. Hybrid system model in Ptolemy II, showing a hierarchical composition of a finite state machine (FSM) model and two continuous-time (CT) models. This example models a physical springmass system with two modes of operation. In the Separate mode, it has two masses on springs oscillating independently. In the Together mode, the two masses are struck together, and oscillate together with two springs. The model was created by Jie Liu and Xiaojun Liu.
An essential difference between concurrent models of computation is their modeling of time. Some are very explicit by taking time to be a real number that advances uniformly, and placing events on a time line or evolving continuous signals along the time line. Others are more abstract and take time to be discrete. Others are still more abstract and take time to be merely a constraint imposed by causality. This latter interpretation results in time that is partially ordered, and explains much of the expressiveness in process networks and rendezvousbased models of computation. Partially ordered time provides a mathematical framework for formally analyzing and comparing models of computation [56,57]. Many researchers have thought deeply about the role of time in computation. Benveniste and Le Guernic observe that in certain classes of systems, "the nature of time is by no means universal, but rather local to each subsystem, and consequently multiform" [14]. Lamport observes that a coordinated notion of time cannot be exacdy maintained in distributed systems, and shows that a partial ordering is sufficient [58]. He gives a mechanism in which messages in an asynchronous system carry time stamps and processes manipulate these time stamps. We
EMBEDDED SOFTWARE
81
can then talk about processes having information or knowledge at a consistent cut, rather than "simultaneously." Fidge gives a related mechanism in which processes that can fork and join increment a counter on each event [59]. A partial ordering relationship between these lists of times is determined by process creation, destruction, and communication. If the number of processes is fixed ahead of time, then Mattem gives a more efficient implementation by using "vector time" [60]. All of this work offers ideas for modeling time. How can we reconcile this multiplicity of views? A grand unified approach to modeling would seek a concurrent model of computation that serves all purposes. This could be accomplished by creating a melange, a mixture of all of the above. For example, one might permit each connection between components to use a distinct protocol, where some are timed and some not, and some are synchronous and some not, as done for example in ROOM [18] and SystemC 2.0 ( h t t p : / / s y s temc. org). This offers rich expressiveness, but such a mixture may prove extremely complex and difficult to understand, and synthesis and validation tools would be difficult to design. In my opinion, such richly expressive formalisms are best used as foundations for more specialized models of computation. This, in fact, is the intent in SystemC 2.0 [61]. Another alternative would be to choose one concurrent model of computation, say the rendezvous model, and show that all the others are subsumed as special cases. This is relatively easy to do, in theory. Most of these models of computation are sufficiently expressive to be able to subsume most of the others. However, this fails to acknowledge the strengths and weaknesses of each model of computation. Process networks, for instance, are very good at describing the data dependencies in a signal processing system, but not as good at describing the associated control logic and resource management. Finite-state machines are good at modeling at least simple control logic, but inadequate for modeling data dependencies and numeric computation. Rendezvous-based models are good for resource management, but they overspecify data dependencies. Thus, to design interesting systems, designers need to use heterogeneous models. Certain architecture description languages (ADLs), such as Wright [19] and Rapide [28], define a model of computation. The models are intended for describing the rich sorts of component interactions that commonly arise in software architecture. Indeed, such descriptions often yield good insights about design, but sometimes, the match is poor. Wright, for example, which is based on CSP, does not cleanly describe asynchronous message passing (it requires giving detailed descriptions of the mechanisms of message passing). I believe that what we really want are architecture design languages rather than architecture description languages. That is, their focus should not be on describing current practice, but rather on improving future practice. Wright, therefore, with its strong commitment
82
EDWARD A. LEE
to CSP, should not be concerned with whether it cleanly models asynchronous message passing. It should instead take the stand that asynchronous message passing is a bad idea for the designs it addresses.
7.
Heterogeneous Models
Figure 4 shows a hierarchical heterogeneous combination of models of computation. A concurrent model at the top level has a component that is refined into a finite-state machine. The states in the state machine are further refined into a concurrent model of computation. Ideally, each concurrent model of computation can be designed in such a way that it composes transparently with FSMs, and, in fact, with other concurrent models of computation. In particular, when building a realization of a model of computation, it would be best if it did not need to be jointly designed with the realizations that it can compose with hierarchically. This is a challenging problem. It is not always obvious what the meaning should be of some particular hierarchical combination. The semantics of various combinations of FSMs with various concurrency models are described in [54]. In Ptolemy II [25], the composition is accomplished via a notion called domain polymorphism. The term "domain polymorphism" requires some explanation. First, the term "domain" is used in the Ptolemy project to refer to an implementation of a model of computation. This implementation can be thought of as a "language," except that it does not (necessarily) have the traditional textual syntax of conventional programming languages. Instead, it abides by a common abstract syntax that underlies all Ptolemy models. The term "domain" is a fanciful one, coming from the speculative notion in astrophysics that there are regions of the universe where the laws of physics differ. Such regions are called "domains." The model of computation is analogous to the laws of physics. In Ptolemy II, components (called actors) in a concurrent model of computation implement an interface consisting of a suite of action methods. These methods define the execution of the component. A component that can be executed under the direction of any of a number of models of computation is called a domain polymorphic component. The component is not defined to operate with a particular model of computation, but instead has a well-defined behavior in several, and can be usefully used in several. It is domain polymorphic, meaning specifically that it has a well-defined behavior in more than one domain, and that the behavior is not necessarily the same in dilferent domains. For example, the AddSubtract actor (shown as a square with a -h and - ) appears in Fig. 8, where it adds or subtracts continuous-time signals, and in Fig. 5, where it adds or subtracts streams.
EMBEDDED SOFTWARE
83
In Ptolemy II, an application (which is called a "model") is constructed by composing actors (most of which are domain polymorphic), connecting them, and assigning a domain. The domain governs the interaction between components and the flow of control. It provides the execution semantics to the assembly of components. The key to hierarchically composing multiple models of computation is that an aggregation of components under the control of a domain should itself define a domain polymorphic component. Thus, the aggregate can be used as a component within a different model of computation. In Ptolemy II, this is how finite-state machine models are hierarchically composed with other models to get hybrid systems, Statechart-like models, and SDL-like models. Domain polymorphic components in Ptolemy II simply need to implement a Java interface called Executable. This interface defines three phases of execution, an initialization phase, which is executed once, an iteration phase, which can be executed multiple times, and a termination phase, which is executed once. The iteration itself is divided into three phases also. The first phase, called prefire, can examine the status of the inputs and can abort the iteration or continue it. The prefire phase can also initiate some computation, if appropriate. The second phase, called fire, can also perform some computation, if appropriate, and can produce outputs. The third phase, called postfire, can commit any state changes for the component that might be appropriate. To get hierarchical mixtures of domains, a domain must itself implement the Executable interface to execute an aggregate of components. Thus, it must define an initialization, iteration, and termination phase, and within the iteration phase, it must define the same three phases of execution. The three-phase iteration has proven suitable for a huge variety of models of computation, including synchronous dataflow (SDF) [37], discrete events (DE) [62], discrete time (DT) [63], finite-state machines (FSM) [54], continuous-time (CT) [64], synchronous/reactive (SR), and Giotto (a time-triggered domain) [24]. All of these domains can be combined hierarchically. Some domains in Ptolemy II have fixed-point semantics, meaning that in each iteration, the domain may repeatedly fire the components until a fixed point is found. Two such domains are continuous time (CT) [64] and synchronous/ reactive (SR) [65,66]. The fact that a state update is committed only in the postfire phase of an iteration makes it easy to use domain-polymorphic components in such a domain. Ptolemy II also has domains for which this pattern does not work quite as well. In particular, in the process networks (PN) domain [67] and communicating sequential processes (CSP) domain, each component executes in its own thread. These domains have no difficulty executing domain polymorphic components. They simply wrap in a thread a (potentially) infinite sequence of iterations.
84
EDWARD A. LEE
However, aggregates in such domains are harder to encapsulate as domain polymorphic components, because it is hard to define an iteration for the aggregate. Since each component in the aggregate has its own thread of execution, it can be tricky to define the boundary points between iterations. This is an open issue that the Ptolemy project continues to address, and to which there are several candidate solutions that are applicable for particular problems.
8.
Component Interfaces
The approach described in the previous section is fairly ad hoc. The Ptolemy project has constructed domains to implement various models of computation, most of which have entire research communities centered on them. It has then experimented with combinations of models of computation, and through trial and error, has identified a reasonable design for a domain polymorphic component interface definition. Can this ad hoc approach be made more systematic? I believe that type system concepts can be extended to make this ad hoc approach more systematic. Type systems in modern programming languages, however, do not go far enough. Several researchers have proposed extending the type system to handle such issues as array bounds overruns, which are traditionally left to the run-time system [68]. However, many issues are still not dealt with. For example, the fact that prefire is executed before ^r^ in a domain polymorphic component is not expressed in the type system. At its root, a type system constrains what a component can say about its interface, and how compatibility is ensured when components are composed. Mathematically, type system methods depend on a partial order of types, typically defined by a subtyping relation (for user-defined types such as classes) or in more ad hoc ways (for primitive types such as double or int). They can be built from the robust mathematics of partial orders, leveraging, for example, fixedpoint theorems to ensure convergence of type checking, type resolution, and type inference algorithms. With this very broad interpretation of type systems, all we need is that the properties of an interface be given as elements of a partial order, preferably a complete partial order (CPO) or a lattice [18]. I suggest first that dynamic properties of an interface, such as the conventions in domain polymorphic component design, can be described using nondeterministic automata, and that the pertinent partial ordering relation is the simulation relation between automata. Preliminary work in this direction is reported in [69], which uses a particular automaton model called interface automata [29]. The result is called a behavioral-type system. Behavioral-level types can be used without modifying the underlying languages, but rather by overlaying on standard languages design patterns that make
EMBEDDED SOFTWARE
85
these types explicit. Domain polymorphic components are simply those whose behavioral-level types are polymorphic. Note that there is considerable precedent for such augmentations of the type system. For example, Lucassen and Gifford introduce state into functions using the type system to declare whether functions are free of side effects [70]. MartinLof introduces dependent types, in which types are indexed by terms [71]. Xi uses dependent types to augment the type system to include array sizes, and uses type resolution to annotate programs that do not need dynamic array bounds checking [68]. The technique uses singleton types instead of general terms [72] to help avoid undecidability. While much of the fundamental work has been developed using functional languages (especially ML [73]), there is no reason that I can see that it cannot be applied to more widely accepted languages.
8.1
On-line-type Systems
Static support for type systems gives the compiler responsibility for the robustness of software [74]. This is not adequate when the software architecture is dynamic. The software needs to take responsibility for its own robustness [75]. This means that algorithms that support the type system need to be adapted to be practically executable at run time. ML is an early and well-known realization of a "modem type system" [1,76,77]. It was the first language to use type inference in an integrated way [78], where the types of variables are not declared, but are rather inferred from how they are used. The compile-time algorithms here are elegant, but it is not clear to me whether run-time adaptations are practical. Many modem languages, including Java and C+H-, use declared types rather than type inference, but their extensive use of polymorphism still implies a need for fairly sophisticated type checking and type resolution. Type resolution allows for automatic (lossless) type conversions and for optimized mn-time code, where the overhead of late binding can be avoided. Type inference and type checking can be reformulated as the problem of finding the fixed point of a monotonic function on a lattice, an approach due to Dana Scott [79]. The lattice describes a partial order of types, where the ordering relationship is the subtype relation. For example. Double is a subtype of Number in Java. A typical implementation reformulates the fixed point problem as the solution of a system of equations [49] or of inequalities [80]. Reasonably efficient algorithms have been identified for solving such systems of inequalities [81], although these algorithms are still primarily viewed as part of a compiler, and not part of a mn-time system. Iteration to a fixed point, at first glance, seems too costly for on-line real-time computation. However, there are several languages based on such iteration that
86
EDWARD A. LEE
are used primarily in a real-time context. Esterel is one of these [7]. Esterel compilers synthesize run-time algorithms that converge to a fixed point at each clock of a synchronous system [14]. Such synthesis requires detailed static information about the structure of the application, but methods have been demonstrated that use less static information [65]. Although these techniques have not been proposed primarily in the context of a type system, I believe they can be adapted.
8.2
Reflecting Program Dynamics
Object-oriented programming promises software modularization, but has not completely delivered. The type system captures only static, structural aspects of software. It says litde about the state trajectory of a program (its dynamics) and about its concurrency. Nonetheless, it has proved extremely useful, and through the use of reflection, is able to support distributed systems and mobile code. Reflection, as applied in software, can be viewed as having an on-line model of the software within the software itself. In Java, for example, this is applied in a simple way. The static structure of objects is visible through the Class class and the classes in the reflection package, which includes Method, Constructor, and various others. These classes allow Java code to dynamically query objects for their methods, determine on-the-fly the arguments of the methods, and construct calls to those methods. Reflection is an integral part of Java Beans, mobile code, and CORBA support. It provides a run-time environment with the facilities for stitching together components with relatively intolerant interfaces. However, static structure is not enough. The interfaces between components involve more than method templates, including such properties as communication protocols. To get adaptive software in the context of real-time applications, it will also be important to reflect the program state. Thus, we need reflection on the program dynamics. In embedded software, this could be used, for example, to systematically realize fault detection, isolation, and recovery (FDIR). That is, if the declared dynamic properties of a component are violated at run time, the run-time-type checking can detect it. For example, suppose a component declares as part of its interface definition that it must execute at least once every 10 ms. Then a run-time-type checker will detect a violation of this requirement. The first question becomes at what granularity to do this. Reflection intrinsically refers to a particular abstracted representation of a program. For example, in the case of static structure, Java's reflection package does not include finer granularity than methods. Process-level reflection could include two critical facets, communication protocols and process state. The former would capture in a type system such properties as whether the process uses rendezvous, streams, or events to communicate with
EMBEDDED SOFTWARE
87
Other processes. By contrast, Java Beans defines this property universally to all applications using Java Beans. That is, the event model is the only interaction mechanism available. If a component needs rendezvous, it must implement that on top of events, and the type system provides no mechanism for the component to assert that it needs rendezvous. For this reason, Java Beans seem unlikely to be very useful in applications that need stronger synchronization between processes, and thus it is unlikely to be used much beyond user interface design. Reflecting the process state could be done with an automaton that simulates the program. (We use the term "simulates" in the technical sense of automata theory.) That is, a component or its run-time environment can access the "state" of a process (much as an object accesses its own static structure in Java), but that state is not the detailed state of the process, but rather the state of a carefully chosen automaton that simulates the application. Designing that automaton is then similar (conceptually) to designing the static structure of an object-oriented program, but represents dynamics instead of static structure. Just as we have object-oriented languages to help us develop object-oriented programs, we would need state-oriented languages to help us develop the reflection automaton. These could be based on Statecharts, but would be closer in spirit to UML's state diagrams in that it would not be intended to capture all aspects of behavior. This is analogous to the object model of a program, which does not capture all aspects of the program structure (associations between objects are only weakly described in UML's static structure diagrams). Analogous to object-oriented languages, which are primarily syntactic overlays on imperative languages, a state-oriented language would be a syntactic overlay on an objectoriented language. The syntax could be graphical, as is now becoming popular with object models (especially UML). Well-chosen reflection automata would add value in a number of ways. First, an application may be asked, via the network, or based on sensor data, to make some change in its functionality. How can it tell whether that change is safe? The change may be safe when it is in certain states, and not safe in other states. It would query its reflection automaton, or the reflection automaton of some gatekeeper object, to determine how to react. This could be particularly important in real-time applications. Second, reflection automata could provide a basis for verification via such techniques as model checking. This complements what object-oriented languages offer. Their object model indicates safety of a change with respect to data layout, but they provide no mechanism for determining safety based on the state of the program. When a reflection automaton is combined with concurrency, we get something akin to Statechart's concurrent, hierarchical FSMs, but with a twist. In Statecharts, the concurrency model is fixed. Here, any concurrency model can be used. We
88
EDWARD A. LEE
call this generalization "*charts," pronounced "starcharts," where the star represents a wildcard suggesting the flexibility in concurrency models [54]. Some variations of Statecharts support concurrency using models that are diff'erent from those in the original Statecharts [15,82]. As with Statecharts, concurrent composition of reflection automata provides the benefit of compact representation of a product automaton that potentially has a very large number of states. In this sense, aggregates of components remain components where the reflection automaton of the aggregate is the product automaton of the components, but the product automaton never needs to be explicitly represented. Ideally, reflection automata would also inherit cleanly. Interface theories are evolving that promise to explain exactly how to do this [29]. In addition to application components being reflective, it will probably be beneficial for components in the run-time environment to be reflective. The run-time environment is whatever portion of the system outlives all application components. It provides such services as process scheduling, storage management, and specialization of components for efficient execution. Because it outlives all application components, it provides a convenient place for reflecting aspects of the application that transcend a single component or an aggregate of closely related components.
9.
Frameworks Supporting Models of Computation
In this context, a framework is a set of constraints on components and their interaction, and a set of benefits that derive from those constraints. This is broader than, but consistent with the definition of frameworks in object-oriented design [83]. By this definition, there are a huge number of frameworks, some of which are purely conceptual, cultural, or even philosophical, and some of which are embodied in software. Operating systems are frameworks where the components are programs or processes. Programming languages are frameworks where the components are language primitives and aggregates of these primitives, and the possible interactions are defined by the grammar. Distributed component middleware such as CORBA [17] and DCOM are frameworks. Synchronous digital hardware design principles are a framework. Java Beans form a framework that is particularly tuned to user interface construction. A particular class library and policies for its use is a framework [83]. For any particular application domain, some frameworks are better than others. Operating systems with no real-time facilities have limited utility in embedded systems, for example. In order to obtain certain benefits, frameworks impose constraints. As a rule, stronger benefits come at the expense of stronger constraints. Thus, frameworks may become rather specialized as they seek these benefits.
EMBEDDED SOFTWARE
89
The drawback with speciaHzed frameworks is that they are unlikely to solve all the framework problems for any complex system. To avoid giving up the benefits of specialized frameworks, designers of these complex systems will have to mix frameworks heterogeneously. Of course, a framework within which to heterogeneously mix frameworks is needed. The design of such a framework is the purpose of the Ptolemy project [25]. Each domain, which implements a model of computation, offers the designer a specialized framework, but domains can be mixed hierarchically using the concept of domain polymorphism. A few other research projects have also heterogeneously combined models of computation. The Gravity system and its visual editor Orbit, like Ptolemy, provide a framework for heterogeneous models [84]. A model in a domain is called a facet, and heterogeneous models are multifacetted designs [85]. Jourdan et al. have proposed a combination of Argos, a hierarchical finite-state machine language, with Lustre [13], which has a more dataflow flavor, albeit still within a synchronous/reactive concurrency framework [86]. Another interesting integration of diverse semantic models is done in Statemate [87], which combines activity charts with statecharts. This sort of integration has more recently become part of UML. The activity charts have some of the flavor of a process network.
10.
Conclusions
Embedded software requires a view of computation that is significantly different from the prevailing abstractions in computation. Because such software engages the physical world, it has to embrace time and other nonfunctional properties. Suitable abstractions compose components according to a model of computation. Models of computation with stronger formal properties tend to be more speciaHzed. This specialization limits their applicability, but this limitation can be ameliorated by hierarchically combining heterogeneous models of computation. System-level types capture key features of components and their interactions through a model of computation, and promise to provide robust and understandable composition technologies. ACKNOWLEDGMENTS
This chapter distills the work of many people who have been involved in the Ptolemy Project at Berkeley. Most notably, the individuals who have directly contributed ideas are Shuvra S. Bhattacharyya, John Davis II, Johan Eker, Chamberlain Fong, Christopher Hylands, Joem Janneck, Jie Liu, Xiaojun Liu, Stephen Neuendorifer, John Reekie, Farhana Sheikh, Kees Vissers, Brian K. Vogel, Paul Whitaker, and Yuhong Xiong. The Ptolemy Project is supported by the Defense Advanced Research Projects Agency (DARPA), the MARCO/DARPA Gigascale Silicon Research Center (GSRC), the State of
90
EDWARD A. LEE
California MICRO program, and the following companies: Agilent Technologies, Cadence Design Systems, Hitachi, and Philips. REFERENCES
[1] Turing, A. M. (1936). "On computable numbers with an application to the Entscheidungsproblem." Proceedings of the London Mathematical Society, 42, 230-265. [2] Manna, Z., and Pnueli, A. (1991). The Temporal Logic of Reactive and Concurrent Systems. Springer-Verlag, Berlin. [3] Douglass, B. R (1998). Real-Time UML. Addison-Wesley, Reading, MA. [4] Dijkstra, E. (1968). "Cooperating sequential processes." Programming Languages (E F. Genuys, Ed.). Academic Press. New York. [5] Lea, D. (1997). Concurrent Programming in JavaTM: Design Principles and Patterns. Addison-Wesley, Reading MA. [6] Benveniste, A., and Berry, G. (1991). "The synchronous approach to reactive and real-time systems." Proceedings of the IEEE, 79, 1270-1282. [7] Berry, G., and Gonthier, G. (1992). "The Esterel synchronous programming language: Design, semantics, implementation." Science of Computer Programming, 19, 87-152. [8] Gamma, E., Helm, R., Johnson, R., and Vlissides, J. (1994). Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading, MA. [9] Edwards, S. A., and Lee, E. A. (2001). "The semantics and execution of a synchronous block-diagram language," Technical Memorandum UCB/ERL, University of California—Berkeley. Available at h t t p : //ptolemy. e e c s . b e r k e l e y . edu/ publications. [10] Liu, C , and Layland, J. (1973). "Scheduling algorithms for multiprogramming in a hard-real-time environment." Journal of the ACM, 20, 46-61. [11] Harel, D., and Pnueli, A. (1985). "On the development of reactive systems." Logic and Models for Verification and Specification of Concurrent Systems. SpringerVerlag, Berlin. [12] Berry, G. (1989). "Real time programming: Special purpose or general purpose languages." Information Processing (G. Ritter, Ed.), Vol. 89, pp. 11-17. Elsevier Science, Amsterdam. [13] Halbwachs, N., Caspi, P., Raymond, P., and Pilaud, D. (1991). "The synchronous data flow programming language LUSTRE." Proc. IEEE, 79, 1305-1319. [14] Benveniste, A., and Le Guernic, P. (1990). "Hybrid dynamical systems theory and the SIGNAL language." IEEE Transactions on Automatic Control, 35, 525-546. [15] Maraninchi, F. (1991). "The Argos Language: Graphical representation of automata and description of reactive systems." Proceedings IEEE Workshop on Visual Languages, Kobe, Japan, Oct. [16] Klein, M. H., Ralya, T., Pollak, B., Obenza, R., and Harbour, M. G. (1993). A Practitioner's Handbook for Real-Time Analysis: Guide to Rate Monotonic Analysis for Real-Time Systems. Kluwer Academic, Norwell, MA.
EMBEDDED SOFTWARE
91
[17] Ben-Natan, R. (1995). CORBA: A Guide to Common Object Request Broker Architecture. McGraw-Hill, New York. [18] Selic, B., Gullekson, G., and Ward, P. (1994). Real-Time Object-Oriented Modeling. Wiley, New York. [19] Allen, R., and Garlan, D. (1994). "Formalizing architectural connection." Proceedings of the 16th International Conference on Software Engineering {ICSE 94), pp. 71-80. IEEE Computer Society Press, Los Alamitos, CA. [20] Agha, G. A. (1990). "Concurrent object-oriented programming." Communications of the ACM, 33, \25-\4l. [21] Agha, G. A. (1986). Actors: A Model of Concurrent Computation in Distributed Systems. MIT Press, Cambridge, MA. [22] Lynch, N. A. (1996). Distributed Algorithms. Morgan Kaufmann, San Mateo, CA. [23] Chiodo, M., Giusto, P., Hsieh, H., Jurecska, A., Lavagno, L., and SangiovanniVincentelU, A. (1994). "A formal methodology for hardware/software co-design of embedded systems." IEEE Micro, 14, 26-36. [24] Henzinger, T. A., Horowitz, B., and Kirsch, C. M. (2001). "Giotto: A time-triggered language for embedded programming." Proceedings of EMSOFT 2001, Tahoe City, CA, Lecture Notes on Computer Science, 2211, pp. 166-184. Springer-Verlag, Berlin. [25] Davis, II, J., Hylands, C , Kienhuis, B., Lee, E. A., Liu, J., Liu, X., MuUadi, L., Neuendorifer, S., Tsay, J., Vogel, B., and Xiong, Y. (2001). "Heterogeneous concurrent modeling and design in Java," Technical Memorandum UCB/ERL MOl/12. Department of Electrical Engineering and Computer Science, University of California—Berkeley. Available at h t t p : / / p t o l e m y . e e c s . b e r k e l e y . e d u / publications. [26a] Agha, G. A. (1997). "Abstracting interaction patterns: A programming paradigm for open distributed systems." Formal Methods for Open Object-Based Distributed Systems, IFIP Transactions (E. Najm and J.-B. Stefani, Eds.) Chapman and Hall, London. [26b] Lee, E. A., and Neuendorifer, S. (2000). "MoML—A modeling markup language in XML, Version 0.4," Technical Memorandum UCB/ERL MOO/12. University of California—Berkeley. Available at h t t p : / / p t o l e m y . e e c s . b e r k e l e y . e d u / publications. [27] Eriksson, H.-E., and Penker, M. (1998). UML Toolkit. Wiley, New York. [28] Luckham, D. C , and Vera, J. (1995). "An event-based architecture definition language." IEEE Transactions on Software Engineering, 21, 717-734. [29] de Alfaro, L., and Henzinger, T. A. (2001). "Interface theories for component-based design." Proceedings of EMSOFT 2001, Tahoe City, CA, Lecture Notes on Computer Science 2211, pp. 148-165. Springer-Verlag, Berlin. [30] Hoare, C. A. R. (1978). "Communicating sequential processes." Communications of the ACM, 21, 666-611.
92
EDWARD A. LEE
[31] von Eicken, T., Culler, D. E., Goldstein, S. C, and Schauser, K. E. (1992). "Active messages: A mechanism for integrated communications and computation." Proceedings of the 19th International Symposium on Computer Architecture, Gold Coast, Australia. Also available as Technical Report TR UCB/CSD 92/675, Computer Science Division, University of California—Berkeley. [32] Kahn, G. (1974). 'The semantics of a simple language for parallel programming." Proceedings of the IFIP Congress 74. North-Holland, Amsterdam. [33] Carriero, N., and Gelernter, D. (1989). "Linda in context." Communications of the ACM, 32, 444-458. [34] Bhattacharyya, S. S., Murthy, R K., and Lee, E. A. (1996). Software Synthesis from Dataflow Graphs. Kluwer Academic, Norwell, MA. [35] Karp, R. M., and Miller, R. E. (1966). "Properties of a model for parallel computations: Determinacy, termination, queueing." SIAM Journal, 14, 1390-1411. [36] Lauwereins, R., Wauters, P., Ade, M., and Peperstraete, J. A. (1994). "Geometric parallelism and cyclo-static dataflow in GRAPE-Il." Proceedings 5th International Workshop on Rapid System Prototyping, Grenoble, France. [37] Lee, E. A., and Messerschmitt, D. G. (1987). "Synchronous data flow." Proceedings of the IEEE, IS, 1235-1245. [38] Lee, E. A., and Messerschmitt, D. G. (1987). "Static scheduling of synchronous data flow programs for digital signal processing." IEEE Transactions on Computers, 36, 24-35. [39] Buck, J. T. (1993). "Scheduling dynamic dataflow graphs with bounded memory using the token flow model," Tech. Report UCB/ERL 93/69, Ph.D. Dissertation. Department of Electrical Engineering and Computer Science, University of California—Berkeley. Available at h t t p : / / p t o l e i n y . e e c s . b e r k e l e y . e d u / publications. [40] Jagannathan, R. (1992). "Parallel execution of GLU programs." Presented at 2nd International Workshop on Dataflow Computing, Hamilton Island, Queensland, Australia. [41] Kaplan, D. J., et al. (1987). "Processing Graph Method Specification Version 1.0," unpublished memorandum. Naval Research Laboratory, Washington DC. [42] Parks, T. M. (1995). "Bounded scheduling of process networks." Technical Report UCB/ERL-95-105, Ph.D. Dissertation. Department of Electrical Engineering and Computer Science. University of California—Berkeley. Available at h t t p : / / p t o lemy.eecs.berkeley.edu/publications. [43] Kopetz, H., Holzmann, M., and Elmenreich, W. (2000). "A universal smart transducer interface: TTP/A." 3rd IEEE International Symposium on Object-Oriented Real-Time Distributed Computing {ISORC'2000). [44] Liao, S., Tjiang, S., and Gupta, R. (1997). "An efficient implementation of reactivity for modeling hardware in the scenic design environment." Proceedings of the Design Automation Conference {DAC 97), Anaheim, CA. [45] Koo, T. J., Liebman, J., Ma, C , and Sastry, S. S. (2001). "Hierarchical approach for design of multi-vehicle multi-modal embedded software." Proceedings of EMSOFT
EMBEDDED SOFTWARE
93
2001, Tahoe City, CA, Lecture Notes on Computer Science 2211, pp. 344-360. Springer-Verlag, Beriin. [46] Caspi, P., Pilaud, D., Halbwachs, N., and Plaice, J. A. (1987). "LUSTRE: A declarative language for programming synchronous systems." Conference Record of the 14th Annual ACM Symposium on Principles of Programming Languages, Munich, Germany. [47] Lee, E. A., and Parks, T. M. (1995). "Dataflow process networks." Proceedings of the IEEE,S3,113-S0\. [48] Lieverse, P., Van Der Wolf, P., Deprettere, E., and Vissers, K. (2001). "A methodology for architecture exploration of heterogeneous signal processing systems." Journal of VLSI Signal Processing, 29, 197-207. [49] Milner, R. (1978). "A theory of type polymorphism in programming." Journal of Computer and System Sciences, 17, 348-375. [50] Reed, G. M., and Roscoe, A. W. (1988). "A timed model for communicating sequential processes." Theoretical Computer Science 58, 249-261. [51] van Gemund, A. J. C. (1993). "Performance prediction of parallel processing systems: The PAMELA methodology." Proceedings 7th International Conference on Supercomputing, Tokyo. [52] Ahuja, S., Carreiro, N., and Gelemter, D. (1986). "Linda and friends." Computer, 19, 26-34. [53a] Harel, D. (1987). "Statecharts: A visual formalism for complex systems." Science of Computer Programming, 8, 231-274. [53b] Henzinger, T. A. (1996). "The theory of hybrid automata." Proceedings of the 11th Annual Symposium on Logic in Computer Science, pp. 278-292. IEEE Computer Society Press, Los Alamitos, CA. Invited tutorial. [54] Girault, A., Lee, B., and Lee, E. A. (1999). "Hierarchical finite state machines with multiple concurrency models." IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, 18, 742-760. [55] Saracco, S., Smith, J. R. W., and Reed, R. (1989). Telecommunications Systems Engineering Using SDL, North-Holland-Elsevier, Amsterdam. [56] Lee, E. A., and Sangiovanni-Vincentelli, A. (1998). "A framework for comparing models of computation." IEEE Transaction on Computer-Aided Design, 17, 12171229. [57] Trotter, W. T. (1992). Combinatorics and Partially Ordered Sets. Johns Hopkins Univ. Press, Baltimore, MD. [58] Lamport, L. (1978). "Time, clocks, and the ordering of events in a distributed system." Communications of the ACM, 21, 558-565. [59] Fidge, C. J. (1991). "Logical time in distributed systems." Computer, 24, 28-33. [60] Mattem, F. (1989). "Virtual time and global states of distributed systems." Parallel and Distributed Algorithms (M. Cosnard and P. Quinton, Eds.), pp. 215-226. NorthHolland, Amsterdam.
94
EDWARD A. LEE
[61] Swan, S. (2001). "An introduction to system level modeling in SystemC 2.0," draft report. Cadence Design Systems. [62] Lee, E. A. (1999). "Modeling concurrent real-time processes using discrete events." Annals of Software Engineering, Special Volume on Real-Time Software Engineering, 7, 25-45. [63] Fong, C. (2001). "Discrete-time dataflow models for visual simulation in Ptolemy II," Memorandum UCB/ERL MO 1/9. Electronics Research Laboratory, University of California—Berkeley. Available at h t t p : //ptolemy. eecs . berkeley. edu/ publications. [64] Liu, J. (1998). "Continuous time and mixed-signal simulation in Ptolemy II," UCB/ERL Memorandum M98/74. Department of Electrical Engineering and Computer Science, University of California—Berkeley. Available at h t t p : / / p t o lemy.eecs.berkeley.edu/publications. [65] Edwards, S. A. (1997). "The specification and execution of heterogeneous synchronous reactive systems," Technical Report UCB/ERL M97/31, Ph.D. thesis. University of California—Berkeley. Available at h t t p : / / p t o l e m y . e e c s . berkeley.edu/publications. [66] Whitaker, P. (2001). "The simulation of synchronous reactive systems in Ptolemy II," Master's Report, Memorandum UCB/ERL MO 1/20. Electronics Research Laboratory, University of California—Berkeley. Available at h t t p : / / p t o l e m y . eecs.berkeley.edu/publications. [67] Goel, M. (1998). "Process networks in Ptolemy II," UCB/ERL Memorandum M98/69, University of California—Berkeley. Available at h t t p : / / p t o lemy.eecs.berkeley.edu/publications. [68] Xi, H., and Pfenning, F. (1998). "Eliminating array bound checking through dependent types." Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation {PLDI '98), Montreal, pp. 249-257. [69] Lee, E. A., and Xiong, Y. (2001). "System-level types for component-based design." Proceedings ofEMSOFT2001, Tahoe City, CA, Lecture Notes on Computer Science 2211, pp. 237-253. Springer-Verlag, Berlin. [70] Lucassen, J. M., and Gifford, D. K. (1988). "Polymorphic effect systems." Proceedings 15th ACM Symposium on Principles of Programming Languages, pp. 47-57. [71] Martin-Lof, P. (1980). "Constructive mathematics and computer programming." Logic, Methodology, and Philosophy of Science VL pp. 153-175. North-Holland, Amsterdam. [72] Hayashi, S. (1991). "Singleton, union, and intersection types for program extraction." Proceedings of the International Conference on Theoretical Aspects of Computer Science (A. R. Meyer, Ed.), pp. 701-730. [73] Ullman, J. D. (1994). Elements of ML Programming. Prentice-Hall, Englewood Cliffs, NJ. [74] Cardelli, L., and Wegner, P. (1985). "On understanding types, data abstraction, and polymorphism." ACM Computing Surveys, 17, 471-522.
EMBEDDED SOFTWARE
95
[75] Laddaga, R. (1998). "Active software." Position paper for the St. Thomas Workshop on Software Behavior Description. [76] Gordon, M. J., Milner, R., Morris, L., Newey, M., and Wadsworth, C. R (1978). "A metalanguage for interactive proof in LCF." Conference Record of the 5th Annual ACM Symposium, on Principles of Programming Languages, pp. 119-130. Assoc. Comput. Mach., New York. [77] Wikstrom, A. (1988). Standard ML. Prentice-Hall, Englewood Cliffs, NJ. [78] Hudak, P. (1989). "Conception, evolution, and application of functional programming languages." ACM Computing Surveys, 21, 359^11. [79] Scott, D. (1970). "Outline of a mathematical theory of computation." Proceedings of the 4th Annual Princeton Conference on Information Sciences and Systems, pp. 169176. [80] Xiong, Y., and Lee, E. A. (2000). "An extensible type system for component-based design." 6th International Conference on Tools and Algorithms for the Construction and Analysis of Systems, Berlin, Lecture Notes on Computer Science, 1785, pp. 20-37. Springer-Verlag, Berlin. [81] Rehof, J., and Mogensen, T. (1996). "Tractable constraints in finite semilattices." Third International Static Analysis Symposium, Lecture Notes in Computer Science 1145, pp. 285-301, Springer-Verlag, Berlin. [82] von der Beeck, M. (1994). "A comparison of statecharts variants." Proceedings of Formal Techniques in Real Time and Fault Tolerant Systems, Lecture Notes on Computer Science 863, pp. 128-148. Springer-Verlag, BerUn. [83] Johnson, R. E. (1997). "Frameworks = (Components -I- Patterns)." Communications of the ACM, 40,39-42. [84] Abu-Ghazaleh, N., Alexander, P., Dieckman, D., Murali, R., and Penix, J. (1998). "Orbit—A framework for high assurance system design and analysis," TR 211/01/98/ECECS. University of Cincinnati. [85] Alexander, P. (1998). "Multi-facetted design: The key to systems engineering." Proceedings of Forum on Design Languages (FDL-98). [86] Jourdan, M., Lagnier, F., Maraninchi, F., and Raymond, P. (1994). "A multiparadigm language for reactive systems." Proceedings of the 1994 International Conference on Computer Languages, Toulouse, France. [87] Harel, D., Lachover, H., Naamad, A., Pnueli, A., Politi, M., Sherman, R., ShtullTrauring, A., and Trakhtenbrot, M. (1990). "STATEMATE: A working environment for the development of complex reactive systems." IEEE Transactions on Software Engineering, 16, 403-414.
This Page Intentionally Left Blank
Empirical Studies of Quality Models in Object-Oriented Systems LIONEL C.BRIAND Software Quality Engineering Laboratory Systems and Computer Engineering Carleton University 1125 Colonel By Drive Ottawa, K1S 5B6 Canada
[email protected] JURGENWUST Fraunhofer lESE Sauerwiesen 6 67661 Kaiserslautern Germany
Abstract Measuring structural design properties of a software system, such as coupling, cohesion, or complexity, is a promising approach toward early quality assessments. To use such measurement effectively, quality models that quantitatively describe how these internal structural properties relate to relevant external system qualities such as reliability or maintainability are needed. This chapter's objective is to summarize, in a structured and detailed fashion, the empirical results reported so far with modeling external system quality based on structural design properties in object-oriented systems. We perform a critical review of existing work in order to identify lessons learned regarding the way these studies are performed and reported. Constructive guidelines for facilitating the work of future studies are also provided, thus facilitating the development of an empirical body of knowledge.
1. Introduction 2. Overview of Existing Studies 2.1 Classification of Studies 2.2 Measurement ADVANCES IN COMPUTERS, VOL. 56 ISBN 0-12-012156-5
98 99 99 101 97
Copyright 2002 Elsevier Science Ltd Allrightsof reproduction in any form reserved.
98
LIONEL C. BRIAND AND JURGEN WUST
2.3 Survey of Studies 2.4 Discussion 3. Data Analysis Methodology 3.1 Descriptive Statistics 3.2 Principal Component Analysis 3.3 Univariate Regression Analysis 3.4 Prediction Model Construction 3.5 Prediction Model Evaluation 4. Summary of Results 4.1 Correlational Studies 4.2 Controlled Experiments 5. Conclusions 5.1 Interrelationship between Design Measures 5.2 Indicators of Fault-Proneness 5.3 Indicators of Effort 5.4 Predictive Power of Models 5.5 Cross-System Application 5.6 Cost-Benefit Model 5.7 Advanced Data Analysis Techniques 5.8 Exploitation of Results 5.9 Future Research Directions Appendix A Appendix B: Glossary References
1.
102 110 112 113 114 116 117 126 131 131 149 150 151 151 152 152 152 153 154 154 156 157 161 162
Introduction
As object-oriented programming languages and development methodologies moved forward, a significant research effort was also dedicated to defining specific quality measures and building quality models based on those measures. Quality measures of object-oriented code or design artifacts usually involve analyzing the structure of these artifacts with respect to the interdependencies of classes and components as well as their internal elements (e.g., inner classes, data members, methods). The underlying assumpdon is that such measures can be used as objective measures to predict various external quality aspects of the code or design artifacts, e.g., maintainability and reliability. Such prediction models can then be used to help decision-making during development. For example, we may want to predict the fault-proneness of components in order to focus validation and verification effort, thus finding more defects for the same amount of effort. Furthermore, as predictive measures of fault-proneness, we may want to consider the coupling, or level of dependency, between classes.
QUALITY MODELS IN OBJECT-ORIENTED SYSTEMS
99
A large number of quality measures have been defined in the literature. Most of them are based on plausible assumptions but one key question is to determine whether they are actually useful, significant indicators of any relevant, external quality attribute [la]. We also need to investigate how they can be applied in practice, whether they lead to cost-effective models in a specific application context. Although numerous empirical studies have been performed and reported in order to address the above-mentioned questions, it is difficult to synthesize the current body of knowledge and identify future research directions. One of the main reasons is the large variety of measures investigated and the lack of consistency and rigor in the reporting of results. This chapter's objective is to summarize, in a structured and detailed fashion, the results that have been reported so far. Overall, although not all the results are easy to interpret, there is enough consistency across studies to identify a number of strong conclusions. We also perform a critical review of existing work in order to identify lessons learned regarding the way these studies are performed and reported. Constructive guidelines for facilitating the work of future studies are also provided, thus facilitating the development of an empirical body of knowledge. Section 2 summarizes existing studies and their main characteristics. Section 3 describes the most important principles and techniques regarding the analysis of software quality data and structural measurement. A recommended analysis procedure is also provided. Section 4 summarizes, in great detail, the results of the studies discussed in Section 2. These results are discussed and conclusions are provided in Section 5.
2.
Overview of Existing Studies
This section presents a first overview of the existing studies relating 0 0 design measurement and system quality, and highlights their commonalities and differences. A comparison of their results is performed in Section 4.
2.1 Classification of Studies Despite a large number of papers regarding the quality measurement of objectoriented systems, the number of articles that empirically investigate the relationship between design properties and various external quality attributes is relatively small. These studies fall into two categories: 1. Correlational studies. These are studies which by means of univariate or multivariate regression analysis try to demonstrate a statistical relationship
100
LIONEL C. BRIAND AND JURGEN WUST
between one or more measures of a system's structural properties (as independent variables) and an external system quality (as a dependent variable). 2. Controlled experiments. These are studies that control the structural properties of a set of systems (independent variables, mostly related to the use of the 0 0 inheritance mechanism), and measure the performance of subjects undertaking software development tasks in order to demonstrate a causal relationship between the two. So far such studies have mostly been performed with students and have focused on the impact of inheritance on maintenance tasks. Correlational studies are by far more numerous as they are usually the only option in industrial settings. Outside these two categories, published empirical work typically falls into two further categories: 3. Application of a set of design measures to one or more systems; with a discussion of the obtained distributions of the measures within one system, or a comparison of distributions across two or more systems, e.g., [lb-4]. For instance, [4] develop two versions of a brewery control system to identical specifications, one following a data-driven approach [5], the other a responsibility-driven approach [6]. They apply the set of design measures by Chidamber and Kemerer [7] to the two resulting systems. They find the system resulting from the responsibility-driven approach to display more desirable structural properties. They conclude the responsibility-driven to be more effective for the production of maintainable, extensible and reusable software. Conclusions in such studies of course are only supported when a relationship of the design measures used with the afore-mentioned system qualities is established. Considered in isolation, such studies are not suitable for demonstrating the usefulness of the structural measures, or drawing conclusions from their measurement. 4. Apply a set of design measures to one or more systems and investigate the relationships between these design measures, by investigating pairwise correlations and performing factor analysis (e.g., [1,8,9]). Besides empirical studies, the literature is concerned with the following topics: 5. Definition of new sets of measures (e.g., [3,7,10-17]). 6. Definition of measurement frameworks for one or more structural properties, which provide guidelines on how these properties can, in principle, be measured [13,18-20]. 7. Criticism/theoretical analysis of existing measures and measurement frameworks; in particular, there is an interest in defining, for measures of various structural properties, necessary mathematical properties these
QUALITY MODELS IN OBJECT-ORIENTED SYSTEMS
101
measures must possess in order for them to be valid for the properties involved [21-24]. Our discussions in this article will focus on categories (1) and (2), with a strong emphasis on the former as these studies are by far the most numerous.
2.2
Measurement
In this section, we provide some examples of measures for object-oriented designs, to give the reader new to the field an impression of what measures of 0 0 structural properties usually are about. We summarize here the measures by Chidamber and Kemerer ([3], in the following referred to as C&K). As we will see, these are the measures having received the widest attention in empirical studies and will be frequendy mentioned in subsequent sections. Chidamber and Kemerer define a suite of six measures (CBO, RFC, LCOM, DIT, NOC, WMC), to quantify the coupling, cohesion, inheritance relationships, and complexity of a class in an 0 0 system: • CBO (Coupling between objects)—A count of the number of noninheritance related couples to other classes. An object of a class is coupled to another, if methods of one class use methods or attributes of the other. • RFC (Response for class)—RFC = |RS| where RS is the response set for the class. The response set can be expressed as {M} (J^^^. [Rt], where [Ri] is the set of methods called by method /, and {M} is the set of all methods in the class. The response set of a class is a set of methods that can potentially be executed in response to a message received by an object of that class. • LCOM (Lack of cohesion in methods)—Consider a Class Ci with methods Ml, M2, . . . , M„. Let {/,} = set of instance variables used by method M/. There are n such sets {/i}, . . . , {/„}. Let P = {(//, Ij) \ // n Ij = 0} and Q = {(liJj) I // n Ij + 0 } . If all n sets {/i}, . . . , {/„} are 0, then let P = 0.
={'
LCOM _ ,
IPI-IQI, ^ 0,
//|P|>|Q| ^ . otherwise.
• DIT (Depth in inheritance tree)—The depth of a class in the inheritance tree is the maximum length from the node to the root of the tree. • NOC (Number of children)—The number of classes derived from a given class.
102
LIONEL C. BRIAND AND JURGEN WUST
• WMC (Weighted method complexity)—Consider a class Ci, with methods Ml, M2, . . . , Mn. Let ci, C2, . . . , Cn be the complexity of the methods. Then n
WMC= ^ c , . The complexities c, were intentionally left undefined. Two versions of WMC were suggested and are frequently used: •