Tải bản đầy đủ (.pdf) (447 trang)

software engineering for students 4th edition

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (11.53 MB, 447 trang )

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
www.it-ebooks.info
Software Engineering
for Students
BELL_A01.QXD 2/2/05 3:20 PM Page i
www.it-ebooks.info
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
www.it-ebooks.info
Software Engineering
for Students
A Programming Approach
Fourth Edition
DOUGLAS BELL
BELL_A01.QXD 2/2/05 3:20 PM Page iii
www.it-ebooks.info
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

www.it-ebooks.info
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
www.it-ebooks.info
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
www.it-ebooks.info
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
www.it-ebooks.info
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
www.it-ebooks.info
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
www.it-ebooks.info
9 Data flow design 111
9.1 Introduction 111
9.2 Identifying data flows 113
9.3 Creation of a structure chart 115
9.4 Discussion 117
Summary 118
Exercises 119
Answers to self-test questions 120
Further reading 120
10 Data structure design 121
10.1 Introduction 121
10.2 A simple example 122
10.3 Processing input files 126
10.4 Multiple input and output streams 127
10.5 Structure clashes 130
10.6 Discussion 134
Summary 136
Exercises 136
Answers to self-test questions 138
Further reading 138
11 Object-oriented design 139
11.1 Introduction 139
11.2 Design 140
11.3 Looking for reuse 144
11.4 Using the library 145
11.5 Class–responsibility–collaborator cards 145
11.6 Iteration 146

11.7 Discussion 147
Summary 147
Exercises 148
Answers to self-test questions 149
Further reading 149
12 Design patterns 151
12.1 Introduction 151
12.2 Inheritance 152
12.3 Delegation 153
x Detailed contents
BELL_A01.QXD 2/2/05 3:20 PM Page x
www.it-ebooks.info
Detailed contents xi
12.4 Singleton 154
12.5 Factory method 155
12.6 Façade 156
12.7 Immutable 157
12.8 Model, view controller (observer, observable) 157
12.9 Mediator 158
12.10 Pipe and Filter 158
12.11 Proxy 159
12.12 Layers 159
12.13 Blob – an anti-pattern 161
12.14 Discussion 161
Summary 162
Exercises 163
Answers to self-test questions 163
Further reading 164
13 Refactoring 165
13.1 Introduction 165

13.2 Encapsulate data 166
13.3 Move method 167
13.4 Move data 167
13.5 Extract class 167
13.6 Inline class 167
13.7 Identify composition or inheritance 168
13.8 Use polymorphism 170
13.9 Discussion 171
Summary 171
Exercises 172
Answers to self-test questions 172
14 The basics 175
14.1 Introduction 175
14.2 Classifying programming languages and features 176
14.3 Design principles 176
14.4 Language syntax 178
14.5 Control structures 179
14.6 Selection 180
Part C

Programming languages 173
BELL_A01.QXD 2/2/05 3:20 PM Page xi
www.it-ebooks.info
14.7 Repetition 183
14.8 Methods 186
14.9 Parameter-passing mechanisms 188
14.10 Primitive data types 190
14.11 Data typing 190
14.12 Strong versus weak typing 191
14.13 User-defined data types (enumerations) 193

14.14 Arrays 194
14.15 Records (structures) 195
Summary 196
Exercises 197
Answers to self-test questions 198
Further reading 199
15 Object-oriented programming 200
15.1 Introduction 200
15.2 Encapsulation 200
15.3 Library classes 206
15.4 Inheritance 207
15.5 Polymorphism 209
15.6 Single versus multiple inheritance 212
15.7 Generics 212
15.8 Dynamic data structures and pointers 213
15.9 Garbage collection 215
Summary 217
Exercises 217
Answers to self-test questions 218
Further reading 220
16 Programming in the large 221
16.1 Introduction 221
16.2 Packages 223
16.3 Using packages 224
16.4 Creating packages 226
16.5 Scoping in large programs 226
16.6 Interfaces 227
16.7 Interfaces and interoperability 229
16.8 Multiple interfaces 230
16.9 Separate compilation 232

xii Detailed contents
BELL_A01.QXD 2/2/05 3:20 PM Page xii
www.it-ebooks.info
Detailed contents xiii
Summary 233
Exercises 233
Answers to self-test questions 234
Further reading 235
17 Software robustness 237
17.1 Introduction 237
17.2 Fault detection by software 239
17.3 Fault detection by hardware 242
17.4 Dealing with damage 244
17.5 Exceptions and exception handlers 245
17.6 Recovery blocks 249
17.7 n-version programming 252
17.8 Assertions 253
17.9 Discussion 254
Summary 255
Exercises 255
Answers to self-test questions 257
Further reading 258
18 Scripting 259
18.1 Introduction 259
18.2 Unix 259
18.3 Discussion 262
Summary 263
Exercises 263
Answers to self-test questions 263
Further reading 263

19 Testing 267
19.1 Introduction 267
19.2 The nature of errors 268
19.3 The problem of testing 269
19.4 Black box (functional) testing 269
19.5 White box (structural) testing 272
19.6 Other testing methods 274
Part D

Verification 265
BELL_A01.QXD 2/2/05 3:20 PM Page xiii
www.it-ebooks.info
19.7 Unit testing 276
19.8 System (integration) testing 277
19.9 Discussion 278
Summary 278
Exercises 279
Answers to self-test questions 281
Further reading 282
20 Groups 283
20.1 Introduction 283
20.2 The individual and the error 283
20.3 Structured walkthroughs 284
20.4 Inspections 286
20.5 Pair programming 286
20.6 Discussion 287
Summary 287
Exercises 288
Further reading 288
21 The waterfall model 291

21.1 Introduction 291
21.2 Principles of the model 291
21.3 Feedback between stages 293
21.4 Discussion 294
Summary 295
Exercises 295
Answers to self-test questions 296
22 The spiral model 297
22.1 Introduction 297
22.2 The spiral model 297
22.3 Case study 300
22.4 Discussion 301
Summary 301
Exercises 301
Answer to self-test question 302
Further reading 302
Part E

Process models 289
xiv Detailed contents
BELL_A01.QXD 2/2/05 3:20 PM Page xiv
www.it-ebooks.info
Detailed contents xv
23 Prototyping 303
23.1 Introduction 303
23.2 Definition 303
23.3 Throwaway or evolutionary? 304
23.4 Throwaway prototyping 305
23.5 Evolutionary prototyping 307
23.6 Rapid prototyping techniques 308

23.7 Discussion 310
Summary 312
Exercises 312
Answers to self-test questions 313
24 Incremental development 314
24.1 Introduction 314
24.2 Big-bang implementation 315
24.3 Test beds 315
24.4 Top-down implementation 316
24.5 Bottom-up implementation 317
24.6 Middle-out implementation 318
24.7 Use case driven implementation 319
24.8 Discussion 319
Summary 320
Exercises 320
Answers to self-test questions 321
Further reading 321
25 Open source software development 322
25.1 Introduction 322
25.2 The principles of open source development 322
25.3 The schism within open source development 323
25.4 Techniques of open source development 324
25.5 Case Study: the GNU/Linux operating system 325
25.6 Discussion 326
Summary 327
Exercises 328
Answers to self-test questions 328
Further reading 328
BELL_A01.QXD 2/2/05 3:20 PM Page xv
www.it-ebooks.info

26 Agile methods and extreme programming 330
26.1 Introduction 330
26.2 The agile manifesto 330
26.3 Extreme programming 332
Summary 335
Exercises 336
Answers to self-test questions 336
Further reading 336
27 The unified process 337
27.1 Introduction 337
27.2 Overview 337
27.3 Phases of the UP 338
27.4 Techniques 339
27.5 Iteration 341
27.6 Case study 341
27.7 Discussion 343
Summary 343
Exercises 344
Further reading 344
28 Teams 347
28.1 Introduction 347
28.2 The principles of teams 347
28.3 The functional team 351
28.4 The project team 351
28.5 The chief programmer team 351
28.6 The object-oriented team 353
28.7 Discussion 354
Summary 355
Exercises 355
Answer To self-test question 355

Further reading 356
29 Software metrics and quality assurance 357
29.1 Introduction 357
29.2 Basic metrics 358
29.3 Complexity metrics 358
Part F

Project management 345
xvi Detailed contents
BELL_A01.QXD 2/2/05 3:20 PM Page xvi
www.it-ebooks.info
Detailed contents xvii
29.4 Faults and reliability – estimating bugs 361
29.5 Software quality 362
29.6 Quality assurance 364
29.7 Process improvement 365
29.8 The Capability Maturity Model 366
Summary 367
Exercises 367
Answers to self-test questions 368
Further Reading 368
30 Project management 370
30.1 Introduction 370
30.2 Project inception 371
30.3 Cost estimation 372
30.4 Selecting tools and methods 375
30.5 The project plan 376
30.6 In the heat of the project 377
30.7 Managing people 378
Summary 380

Exercises 380
Answers to self-test questions 381
Further reading 381
31 Assessing methods 385
31.1 Introduction 385
31.2 How to assess methods 386
31.3 Case study – assessing verification techniques 387
31.4 The current state of methods 388
31.5 A single development method? 389
31.6 Introducing new methods 390
Summary 390
Exercises 390
Further reading 391
32 Conclusion 392
32.1 Introduction 392
32.2 Software tools 392
32.3 The world of programming languages 393
Part G

Review 383
BELL_A01.QXD 2/2/05 3:20 PM Page xvii
www.it-ebooks.info
32.4 Software reuse 394
32.5 The real world of software engineering 395
32.6 Control versus skill 397
32.7 Future methods and tools 398
32.8 History 400
32.9 The future of software engineering 400
Summary 401
Exercises 402

Further reading 402
xviii Detailed contents
Appendices 405
A Case studies 407
A.1 The ATM 407
A.2 The word processor 408
A.3 Computer game 408
A.4 The library 409
A.5 Patient monitoring system 410
B Glossary 411
C UML Summary 412
C.1 Use case diagrams 412
C.2 Class diagrams 413
C.3 Package diagrams 414
C.4 Activity diagrams 414
Further reading 416
Bibliography 417
Index 419
BELL_A01.QXD 2/2/05 3:20 PM Page xviii
www.it-ebooks.info
Preface
Software engineering is about the creation of large pieces of software that consist of
thousands of lines of code and involve many person months of human effort.
One of the attractions of software engineering is that there is no one single best
method for doing it, but instead a whole variety of different approaches. Consequently
the software engineer needs a knowledge of many different techniques and tools. This
diversity is one of the delights of software engineering, and this book celebrates this by
presenting the range of current techniques and tools.
We shall see that some software engineering methods are well-defined while others
are ill-defined. And the processes of software development are always under debate.

Software engineering is about imagination and creativity – the process of creating some-
thing apparently tangible from nothing. Software engineering methods have not yet
been completely analyzed and systematized. Thus there is still great scope for using
imagination and creativity. The exercise of skill and flair is one of the joys of software
engineering.
Ideally you, the reader, will have savored the joy of devising an elegant solution to a pro-
gramming problem. You will also have experienced the intense frustration of trying to find
an elusive bug – and the satisfaction of subsequently tracking it down and eliminating it.
This book is for people who have experienced the pleasures of writing programs and
who want to see how things change in the scale up to large programs and software systems.
This book provides an introduction to software engineering for students in under-
graduate programs in Computer Science, Computer Studies, Information Technology,
Who is this book for?
Challenge and creativity
What is software engineering?
xix
BELL_A01.QXD 2/2/05 3:20 PM Page xix
www.it-ebooks.info
Software Engineering and related fields at the college or university level. The book is
also aimed at practising software developers in industry and commerce who wish to
keep abreast of current ideas in software engineering.
The prerequisites for understanding this book are:
■ some familiarity with a modern programming language
■ some experience with developing a moderately sized program of a few hundred lines.
This book explains the different principles, techniques and tools that are used in soft-
ware development. These are the mainstream methods that are currently used through-
out the industrialized world.
This book doesn’t present easy answers about the value of these techniques. Indeed,
it asks the reader to make an assessment of the techniques. This is what the software
engineer has to do – now and in the future – choose the appropriate techniques for the

project in hand from the multiplicity of techniques that are on offer.
UML (Unified Modeling Language) is used as appropriate within the text as a graphi-
cal design notation. Some other graphical notations – flowcharts, structure charts and
data flow diagrams are also used.
Java is used as an illustrative programming language and sometimes also pseudo code
(program design language).
Yes, but each chapter deals with a separate topic. This is to enable each chapter to focus
exclusively and thoroughly on a single idea.
Because the chapters are independent, you do not need to read them in any particular
sequence – you can dip into the book at random. But you might choose to read
Chapters 1 and 2 first because they set the scene. You might choose to spend one week
on each chapter.
How to read this book
So many chapters
Notations
xx Preface
What do I need to know?
What is covered in this book?
BELL_A01.QXD 2/2/05 3:20 PM Page xx
www.it-ebooks.info
Preface xxi
The chapters are grouped into sections on:
■ preliminaries
■ design
■ programming languages
■ verification
■ process models
■ project management
■ review.
Several of these sections present a variety of alternative techniques, for example, a vari-

ety of design approaches.
A number of case studies are used throughout the book to illustrate the use of the var-
ious techniques. They constitute a range of typical software systems and are presented
in Appendix A. Many chapters use one of the case studies. The case studies are also used
as part of the exercises at the end of each chapter.
You could also use the case studies as projects carried out in parallel to the study of
this book.
These are placed throughout the text so that you can check your understanding of top-
ics. They promote active learning. The answers are at the end of each chapter.
With the notable exception of four chapters on languages, we do not have a separate
chapter on software tools. Instead we ask the reader in the exercises to suggest suitable
tools for use with each technique.
This book is about the theories behind software engineering and gives an explanation
of current techniques. But many people would argue you really need to experience the
reality of software development to fully appreciate the ideas. Probably, therefore, you
Is this all I need to know?
Software tools
Self-test questions
Case studies
The organization of this book
BELL_A01.QXD 2/2/05 3:20 PM Page xxi
www.it-ebooks.info
are engaged on a project of some size while you study this book. Good luck with your
practical project. (The case studies in Appendix A may serve as projects.)
Visit the website associated with the book to see additional material and any updates at
www.pearsoned.co.uk/bell.
Special thanks to my closest collaborator on this book, Alice Bell, particularly for writing
Chapter 25. Many thanks to current and past colleagues, including (in alphabetical order)
Babak Akhgar, Chris Bates, Andy Bissett, Pete Collingwood, Gordon Doole, Chuck
Elliot, Jan Graba, Chris Hall, Babak Khazaei, Mehdi Mir, Ian Morrey, Mehmet Ozcan,

Mike Parr, John Pugh, Chris Roast, Dharmendra Shadija, Jawed Siddiqi. All misconcep-
tions are, of course, the author’s.
Acknowledgments
Website
xxii Preface
BELL_A01.QXD 2/2/05 3:20 PM Page xxii
www.it-ebooks.info
PART
A
PRELIMINARIES
BELL_CPARTA.QXD 1/30/05 4:29 PM Page 1
www.it-ebooks.info
BELL_CPARTA.QXD 1/30/05 4:29 PM Page 2
www.it-ebooks.info

×