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 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 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 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 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 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 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 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 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 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 . the large 22 1 16.1 Introduction 22 1 16 .2 Packages 22 3 16.3 Using packages 22 4 16.4 Creating packages 22 6 16.5 Scoping in large programs 22 6 16.6 Interfaces 22 7 16.7 Interfaces and interoperability. reading 28 2 20 Groups 28 3 20 .1 Introduction 28 3 20 .2 The individual and the error 28 3 20 .3 Structured walkthroughs 28 4 20 .4 Inspections 28 6 20 .5 Pair programming 28 6 20 .6 Discussion 28 7 Summary. inheritance 21 2 15.7 Generics 21 2 15.8 Dynamic data structures and pointers 21 3 15.9 Garbage collection 21 5 Summary 21 7 Exercises 21 7 Answers to self-test questions 21 8 Further reading 22 0 16 Programming