for Students Software Engineering for Students Douglas Bell A Programming Approach Software Engineering for Students A Programming Approach Software Engineering for Students A Programming Approach This fully revised version of Douglas Bell’s Software Engineering: A Programming Approach continues to use the successful formula of the previous editions. The author’s approach is to present the main principles, techniques and tools used in software engineering, one by one, chapter by chapter. He provides the reader with the knowledge to select the appropriate techniques for the project in hand. He builds on the reader’s experience of coding small-scale applications, and examines everything they will need to begin programming large-scale software systems. This book is a unique introduction to software engineering for all students of computer science and its related disciplines. It is also ideal for practitioners wishing to remain current with new developments in the area. Features ● Pragmatic, non-mathematical approach ● Self-test questions within each chapter help the reader to fully understand the concepts ● Numerous exercises are provided at the end of each chapter ● Consistent use of the UML as a design notation ● Case studies used throughout ● An accompanying website with even more teaching and learning resources Douglas Bell is a lecturer at Sheffield Hallam University in the UK. He has authored and co-authored a number of texts, including the best-selling Java for Students. “Bell covers the main areas of software engineering with accuracy and authority, and without getting bogged down in superfluous detail. My students actually like this book; it's very readable.” Martin Bush, South Bank University Douglas Bell Douglas Bell Software Engineering www.pearson-books.com fourth edition fourth edition fourth edition an imprint of Software Engineering for Students BELL_A01.QXD 2/2/05 3:20 PM Page i We work with leading authors to develop the strongest educational materials in computing, bringing cutting-edge thinking and best learning practice to a global market. Under a range of well-known imprints, including Addison-Wesley, we craft high quality print and electronic publications which help readers to understand and apply their content, whether studying or at work. To find out more about the complete range of our publishing, please visit us on the World Wide Web at: www.pearsoned.co.uk BELL_A01.QXD 2/2/05 3:20 PM Page ii Software Engineering for Students A Programming Approach Fourth Edition DOUGLAS BELL BELL_A01.QXD 2/2/05 3:20 PM Page iii Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England and Associated Companies throughout the world Visit us on the World Wide Web at: www.pearsoned.co.uk First published under the Prentice Hall imprint 1987 Second edition 1992 Third edition 2000 Fourth edition 2005 © Prentice Hall International 1987, 1992 © Pearson Education Limited 2000, 2005 The right of Douglas Bell to be identified as author of this work has been asserted by him in accordance with the Copyright, Designs and Patents Act 1988. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or trans- mitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without either the prior written permission of the publisher or a licence permitting restricted copying in the United Kingdom issued by the Copyright Licensing Agency Ltd, 90 Tottenham Court Road, London W1T 4LP. The programs in this book have been included for their instructional value. They have been tested with care but are not guaranteed for any particular purpose. The publisher does not offer any warranties or representations nor does it accept any liabilities with respect to the programs. All trademarks used herein are the property of their respective owners. The use of any trademark in this text does not vest in the author or publisher any trademark ownership rights in such trademarks, nor does the use of such trademarks imply any affiliation with or endorsement of this book by such owners. ISBN 0 321 26127 5 British Library Cataloguing-in-Publication Data A catalogue record for this book is available from the British Library Library of Congress Cataloging-in-Publication Data Bell, Doug, 1944- Software engineering for student/Douglas Bell. 4th ed. p. cm. Rev. ed. of: Software engineering. 2000. ISBN 0-321-26127-5 1. Software engineering. 2. Computer programming. I. Bell, Doug, 1944- Software engineering. II. Title. QA76.758.B45 2005 005.1 dc22 2004062346 10987654321 09 08 07 06 05 Typeset in 9.75/12pt Galliard by 71 Printed in Great Britain by Henry Ling Ltd, at the Dorset Press, Dorchester, Dorset The publisher’s policy is to use paper manufactured from sustainable forests. BELL_A01.QXD 2/2/05 3:20 PM Page iv Contents Part A ● Preliminaries 1 1. Software – problems and prospects 3 2. The tasks of software development 22 3. The feasibility study 30 4. Requirements engineering 36 Part B ● Design 51 5. User interface design 53 6. Modularity 67 7. Structured programming 87 8. Functional decomposition 102 9. Data flow design 111 10. Data structure design 121 11. Object-oriented design 139 12. Design patterns 151 13. Refactoring 165 Part C ● Programming languages 173 14. The basics 175 15. Object-oriented programming 200 16. Programming in the large 221 17. Software robustness 237 18. Scripting 259 Preface xix v BELL_A01.QXD 2/2/05 3:20 PM Page v vi Contents 19. Testing 267 20. Groups 283 Part D ● Verification 265 Part E ● Process models 289 21. The waterfall model 291 22. The spiral model 297 23. Prototyping 303 24. Incremental development 314 25. Open source software development 322 26. Agile methods and extreme programming 330 27. The unified process 337 Part F ● Project management 345 28. Teams 347 29. Software metrics and quality assurance 357 30. Project management 370 Part G ● Review 383 31. Assessing methods 385 32. Conclusion 392 Appendices 405 A. Case studies 407 B. Glossary 411 C. UML summary 412 Bibliography 417 Index 419 BELL_A01.QXD 2/2/05 3:20 PM Page vi Detailed contents Preface xix 1 Software – problems and prospects 3 1.1 Introduction 3 1.2 Meeting users’ needs 4 1.3 The cost of software production 5 1.4 Meeting deadlines 10 1.5 Software performance 10 1.6 Portability 11 1.7 Maintenance 11 1.8 Reliability 13 1.9 Human–computer interaction 16 1.10 A software crisis? 16 1.11 A remedy – software engineering? 17 Summary 18 Exercises 19 Answers to self-test questions 20 Further reading 20 2 The tasks of software development 22 2.1 Introduction 22 2.2 The tasks 23 2.3 Process models 26 2.4 Methodology 27 2.5 Hacking 28 Summary 28 Exercises 28 Answer to self-test question 29 Part A ● Preliminaries 1 vii BELL_A01.QXD 2/2/05 3:20 PM Page vii 3 The feasibility study 30 3.1 Introduction 30 3.2 Technical feasibility 31 3.3 Cost-benefit analysis 31 3.4 Other criteria 32 3.5 Case study 32 3.6 Discussion 34 Summary 34 Exercises 34 Answers to self-test questions 35 Further reading 35 4 Requirements engineering 36 4.1 Introduction 36 4.2 The concept of a requirement 37 4.3 The qualities of a specification 38 4.4 How to elicit requirements 40 4.5 The requirements specification 41 4.6 The structure of a specification 42 4.7 Use cases 45 4.8 Use case diagrams 46 Summary 47 Exercises 47 Answers to self-test questions 48 Further reading 49 5 User interface design 53 5.1 Introduction 53 5.2 An inter-disciplinary field 54 5.3 Styles of human–computer interface 54 5.4 Different perspectives on user interface design 56 5.5 Design principles and guidelines 57 5.6 Interface design 60 5.7 Case study 62 5.8 Help systems 63 Summary 64 Exercises 64 Part B ● Design 51 viii Detailed contents BELL_A01.QXD 2/2/05 3:20 PM Page viii Detailed contents ix Answers to self-test questions 65 Further reading 65 6 Modularity 67 6.1 Introduction 67 6.2 Why modularity? 68 6.3 Component types 70 6.4 Component size and complexity 70 6.5 Global data is harmful 73 6.6 Information hiding 74 6.7 Coupling and cohesion 76 6.8 Coupling 77 6.9 Cohesion 79 6.10 Object-oriented programming 82 6.11 Discussion 84 Summary 84 Exercises 85 Answers to self-test questions 85 Further reading 86 7 Structured programming 87 7.1 Introduction 87 7.2 Arguments against goto 89 7.3 Arguments in favor of goto 92 7.4 Selecting control structures 94 7.5 What is structured programming? 96 Summary 98 Exercises 99 Answer to self-test question 100 Further reading 101 8 Functional decomposition 102 8.1 Introduction 102 8.2 Case study 103 8.3 Discussion 107 Summary 109 Exercises 109 Answer to self-test question 110 Further reading 110 BELL_A01.QXD 2/2/05 3:20 PM Page ix . 10 1. 6 Portability 11 1. 7 Maintenance 11 1. 8 Reliability 13 1. 9 Human–computer interaction 16 1. 10 A software crisis? 16 1. 11 A remedy – software engineering? 17 Summary 18 Exercises 19 Answers. design 11 1 10 . Data structure design 12 1 11 . Object-oriented design 13 9 12 . Design patterns 15 1 13 . Refactoring 16 5 Part C ● Programming languages 17 3 14 . The basics 17 5 15 . Object-oriented programming. for Students Software Engineering for Students Douglas Bell A Programming Approach Software Engineering for Students A Programming Approach Software Engineering for Students A Programming Approach This