SDP
SDP
Engineering
An Agile Unified Methodology
This page intentionally left blank
Object-Oriented Software
Engineering
An Agile Unified Methodology
David C. Kung
The University of Texas at Arlington
OBJECT-ORIENTED SOFTWARE ENGINEERING: AN AGILE UNIFIED METHODOLOGY
Published by McGraw-Hill, a business unit of The McGraw-Hill Companies, Inc., 1221 Avenue of the
Americas, New York, NY 10020. Copyright © 2014 by The McGraw-Hill Companies, Inc. All rights
reserved. Printed in the United States of America. No part of this publication may be reproduced or
distributed in any form or by any means, or stored in a database or retrieval system, without the prior
written consent of The McGraw-Hill Companies, Inc., including, but not limited to, in any network or
other electronic storage or transmission, or broadcast for distance learning.
Some ancillaries, including electronic and print components, may not be available to customers outside
the United States.
1 2 3 4 5 6 7 8 9 0 DOC/DOC 1 0 9 8 7 6 5 4 3
ISBN 978-0-07-3376257
MHID 0-07-3376256
All credits appearing on page or at the end of the book are considered to be an extension of the copyright
page.
The Internet addresses listed in the text were accurate at the time of publication. The inclusion of a
website does not indicate an endorsement by the authors or McGraw-Hill, and McGraw-Hill does not
guarantee the accuracy of the information presented at these sites.
www.mhhe.com
Dedication
•
To My Father
Contents
Chapter 2 Chapter 3
• •
Software Process and Methodology 16 System Engineering 53
2.1 Challenges of System Development 17 3.1 What Is a System? 54
2.2 Software Process 18 3.2 What Is System Engineering? 55
vi
Contents vii
II
5.4 Steps for Domain Modeling 117
• Part • 5.4.1 Collecting Application Domain
Information 118
Analysis and Architectural 5.4.2 Brainstorming 119
Design 79 5.4.3 Classifying Brainstorming Results 120
5.4.4 Visualizing the Domain Model 124
Chapter 4 5.4.5 Domain Model Review Checklist 129
• 5.5 Putting It Together 130
Software Requirements Elicitation 80 5.6 Guidelines for Domain Modeling 133
4.1 What Is Requirements Elicitation? 81 5.7 Applying Agile Principles 134
4.2 Importance of Requirements Elicitation 82 5.8 Tool Support for Domain Modeling 135
4.3 Challenges of Requirements Elicitation 83 Summary 136
4.4 Types of Requirement 85 Further Reading 136
4.5 Steps for Requirements Elicitation 86 Chapter Review Questions 138
4.5.1 Collecting Information 87 Exercises 138
4.5.2 Constructing Analysis Models 91
4.5.3 Deriving Requirements and
Constraints 92 Chapter 6
4.5.4 Requirements Specification Standards 97 •
4.5.5 Conducting Feasibility Study 97 Architectural Design 139
4.5.6 Reviewing Requirements Specification 99 6.1 What Is Architectural Design? 140
4.6 Applying Agile Principles 100 6.2 The Importance of Architectural
4.7 Requirements Management and Tools 101 Design 140
viii Contents
6.3 Architectural Design Process 141 7.5 Guidelines for Use Case Derivation 192
6.3.1 Determine Architectural Design 7.6 Applying Agile Principles 195
Objectives 142 7.7 Tool Support for Use Case Modeling 196
6.3.2 Determine System Type 143
6.3.3 Applying Architectural Styles 147 Summary 198
6.3.4 Perform Custom Architectural Design 157 Further Reading 198
6.3.5 Specify Subsystem Functions and Chapter Review Questions 199
Interfaces 157 Exercises 199
6.3.6 Review the Architectural Design 158
6.4 Architectural Style and Package Diagram 158 Chapter 8
6.5 Applying Software Design Principles 160 •
6.5.1 What Are Software Design Actor-System Interaction Modeling 200
Principles? 161
8.1 What Is Actor-System Interaction
6.5.2 Design for Change 161 Modeling? 201
6.5.3 Separation of Concerns 162
8.2 Importance of Actor-System
6.5.4 Information Hiding 163 Interaction Modeling 202
6.5.5 High Cohesion 164
8.3 Steps for Actor-System Interaction
6.5.6 Low Coupling 165 Modeling 202
6.5.7 Keep It Simple and Stupid 166 8.3.1 Initializing a Two-Column Table 202
6.6 Guidelines for Architectural Design 166 8.3.2 Specifying Actor-System Interaction
6.7 Architectural Design and Design Patterns 167 Steps 203
6.8 Applying Agile Principles 167 8.3.3 Reviewing Actor-System Interaction
Summary 168 Specifications 204
Further Reading 168 8.4 Specifying Alternative Flows 204
Chapter Review Questions 169 8.5 Using User Interface Prototypes 204
Exercises 169 8.6 Do Not Show Exception Handling 208
8.7 Use Case Precondition and Postcondition 209
• Part III • 8.8 Including Other Use Cases 210
8.9 Continuing with Other Use Cases 210
Modeling and Design of Interactive 8.10 Commonly Seen Problems 211
Systems 171 8.11 Applying Agile Principles 213
9.2.4 Sequence Diagram for Analysis and 10.6.2 Applying the Expert Pattern 267
Design 222 10.6.3 Expert Pattern Involving More Than One
9.2.5 Using the Notations Correctly 224 Object 269
9.3 Steps for Object Interaction Modeling 225 10.6.4 When Does One Apply the Expert
9.3.1 Collecting Information About Business Pattern? 269
Processes 226 10.6.5 Guidelines for Using Expert 270
9.3.2 Identifying Nontrivial Steps 227 10.7 The Creator Pattern 270
9.3.3 Writing Scenarios for Nontrivial 10.7.1 What Is a Creator? 270
Steps 228 10.7.2 Applying the Creator Pattern 271
9.3.4 Constructing Scenario Tables 230 10.7.3 Benefits of the Creator Pattern 272
9.3.5 Scenarios: How to Write Them 232 10.7.4 When Does One Apply the Creator
9.3.6 Deriving Sequence Diagrams from Scenario Pattern? 273
Tables 236
Summary 273
9.3.7 Object Interaction Modeling Review
Further Reading 274
Checklist 245
Chapter Review Questions 274
9.4 Applying Agile Principles 246
Exercises 275
9.5 Tool Support for Object Interaction
Modeling 248
Summary 249
Chapter 11 •
Further Reading 249 Deriving a Design Class Diagram 276
Chapter Review Questions 249
11.1 What Is a Design Class Diagram? 278
Exercises 249
11.2 Usefulness of a Design Class Diagram 278
Chapter 10 •
11.3 Steps for Deriving a Design Class
Diagram 279
11.3.1 Identifying Classes 279
Applying Responsibility-Assignment 11.3.2 Identifying Methods 281
Patterns 251 11.3.3 Identifying Attributes 281
10.1 What Are Design Patterns? 252 11.3.4 Relationships between Classes 285
10.2 Why Design Patterns? 253 11.3.5 Identifying Relationships 285
10.3 Situation-Specific and 11.3.6 Design Class Diagram Review
Responsibility-Assignment Patterns 253 Checklist 288
10.4 Pattern Specification 254 11.4 Organize Classes with Package Diagram 288
10.5 The Controller Pattern 254 11.5 Applying Agile Principles 291
10.5.1 A Motivating Example 255 11.6 Tool Support for Design Class Diagram 292
10.5.2 What Is a Controller? 258
Summary 292
10.5.3 Applying the Controller Pattern 258
Further Reading 292
10.5.4 Types of Controller 261
Chapter Review Questions 292
10.5.5 Keeping Track of Use Case State 261
10.5.6 Bloated Controller 263 Exercises 292
10.5.7 Comparing Different Designs 264
10.5.8 When Does One Apply the Controller Chapter 12
Pattern? 265
•
10.5.9 Guidelines for Using Controller 265 User Interface Design 293
10.6 The Expert Pattern 267 12.1 What Is User Interface Design? 294
10.6.1 The Information Expert 267 12.2 Why Is User Interface Design Important? 295
x Contents
12.3 Graphical User Interface Widgets 296 13.4.3 Constructing State Transition
12.3.1 Container Widgets 297 Tables 327
12.3.2 Input, Output, and Information 13.4.4 Usefulness of the State Transition
Presentation Widgets 298 Table 329
12.3.3 Guidelines for Using GUI Widgets 298 13.4.5 Converting State Transition Table to
12.4 User Interface Design Process 300 Analysis State Diagram 330
12.4.1 Case Study: User Interface Design for a 13.4.6 Converting Analysis State Diagram to
Diagram Editor 301 Design State Diagram 333
12.4.2 Identifying Major System Displays 302 13.4.7 State Modeling Review Checklists 334
12.4.3 Producing a Draft Layout Design 304 13.5 The State Pattern 334
12.4.4 Specifying Interaction Behavior 306 13.5.1 Conventional Approaches 334
12.4.5 Constructing a Prototype 307 13.5.2 What Is State Pattern? 335
12.4.6 Evaluating the User Interface Design 13.5.3 Applying State Pattern 337
with Users 308 13.6 Real-Time Systems Modeling
12.4.7 User Interface Design Review and Design 339
Checklist 310 13.6.1 The Transformational Schema 339
12.5 Designing User Support Capabilities 310 13.6.2 Timed State Machine 342
12.6 Guidelines for User Interface Design 311 13.6.3 Interrupt Handling 343
12.7 Applying Agile Principles 313 13.7 Applying Agile Principles 344
12.8 Tool Support for User Interface 13.8 Tool Support for Object State Modeling 345
Design 314 Summary 345
Summary 315 Further Reading 346
Further Reading 315 Chapter Review Questions 346
Chapter Review Questions 315 Exercises 346
Exercises 315
Chapter 14 •
• Part IV • Activity Modeling for Transformational
Modeling and Design of Other Types Systems 349
of Systems 317 14.1 What Is Activity Modeling? 350
14.2 Why Activity Modeling? 351
Chapter 13 14.3 Activity Modeling: Technical
Background 351
•
14.3.1 Flowchart 352
Object State Modeling for Event-Driven
14.3.2 Petri Net 352
Systems 318
14.3.3 Data Flow Diagram 353
13.1 What Is Object State Modeling? 319 14.4 UML Activity Diagram 355
13.2 Why Object State Modeling? 319 14.5 Steps for Activity Modeling 356
13.3 Basic Definitions 320 14.5.1 Identifying Activities and
13.4 Steps for Object State Modeling 321 Workflows 357
13.4.1 Collecting and Classifying State 14.5.2 Producing a Preliminary Activity
Behavior Information 322 Diagram 360
13.4.2 Constructing a Domain Model to Show 14.5.3 Introducing Branching, Forking, and
the Context 325 Joining 362
Contents xi
Chapter 17 •
18.3.3 Implementing Association
Relationships 460
18.4 Assigning Implementation Work to
Applying Patterns to Design a Persistence Team Members 461
Framework 426
18.5 Pair Programming 462
17.1 Problems with Direct Database Access 427 18.6 Test-Driven Development 463
17.2 Hiding Persistence Storage with 18.6.1 Test-Driven Development
Bridge 428 Workflow 463
17.3 Encapsulating Database Requests as 18.6.2 Merits of Test-Driven
Commands 431 Development 465
17.4 Hiding Network Access with Remote 18.6.3 Potential Problems 466
Proxy 435 18.7 Applying Agile Principles 466
17.5 Sharing Common Code with Template 18.8 Tool Support for Implementation 467
Method 439
17.6 Retrieving Different Objects with Summary 467
Factory Method 442 Further Reading 467
17.7 Reducing Number of Classes with Chapter Review Questions 468
Prototype 444 Exercises 468
17.8 Applying Agile Principles 447
Summary 447 Chapter 19 •
Further Reading 448
Chapter Review Questions 448
Software Quality Assurance 469
Exercises 448 19.1 Benefits of Software Quality
Assurance 469
19.2 Software Quality Attributes 470
• Part VI • 19.3 Quality Measurements and Metrics 472
19.3.1 Usefulness of Quality Measurements
Implementation and and Metrics 473
Quality Assurance 449 19.3.2 Conventional Quality Metrics 474
19.3.3 Reusing Conventional Metrics
Chapter 18 for Object-Oriented Software 480
19.3.4 Object-Oriented Quality Metrics 480
•
19.4 Software Verification and Validation
Implementation Considerations 450
Techniques 483
18.1 Coding Standards 450 19.4.1 Inspection 484
18.1.1 What Are Coding Standards? 451 19.4.2 Walkthrough 485
18.1.2 Why Coding Standards? 455 19.4.3 Peer Review 486
18.1.3 Code Review Checklist 455 19.5 Verification and Validation in the Life
18.1.4 Guidelines for Practicing Coding Cycle 487
Standards 456
19.6 Software Quality Assurance
18.2 Organizing the Implementation Artifacts 457 Functions 490
18.3 Generating Code from Design 459 19.6.1 Definition of Processes and
18.3.1 Implementing Classes and Standards 490
Interfaces 459 19.6.2 Quality Management 494
18.3.2 From Sequence Diagram to Method 19.6.3 Process Improvement 495
Code Skeleton 460
Contents xiii
19.7 Applying Agile Principles 497 20.8.4 Web Application Testing with
19.8 Tool Support for SQA 498 HttpUnit 527
20.9 Testing for Nonfunctional
Summary 498
Requirements 527
Further Reading 499 20.9.1 Performance and Stress Testings 527
Chapter Review Questions 499 20.9.2 Testing for Security 528
Exercises 499 20.9.3 Testing User Interface 529
20.10 Software Testing in the Life Cycle 529
Chapter 20 20.11 Regression Testing 532
• 20.12 When to Stop Testing? 533
Software Testing 501 20.13 Applying Agile Principles 534
20.1 What Is Software Testing? 502 20.14 Tool Support for Testing 534
20.2 Why Software Testing? 503 Summary 535
20.3 Conventional Black-Box Testing 504 Further Reading 535
20.3.1 Functional Testing: An Example 504 Chapter Review Questions 535
20.3.2 Equivalence Partitioning 505 Exercises 535
20.3.3 Boundary Value Analysis 507
20.3.4 Cause-Effect Analysis 509
20.4 Conventional White-Box Testing 510
• Part VII •
20.4.1 Basis Path Testing 510 Maintenance and
20.4.2 Cyclomatic Complexity 511 Configuration Management 537
20.4.3 Flow Graph Test Coverage
Criteria 512
20.4.4 Testing Loops 512 Chapter 21
•
20.4.5 Data Flow Testing 514
20.4.6 Coverage Criteria for Data Flow Software Maintenance 538
Testing 515 21.1 What Is Software Maintenance? 539
20.4.7 Interprocedural Data Flow 21.2 Factors That Mandate Change 539
Testing 515 21.3 Lehman’s Laws of System Evolution 540
20.5 Test Coverage 516 21.4 Types of Software Maintenance 541
20.6 A Generic Software Testing Process 517 21.5 Software Maintenance Process and
20.7 Object-Oriented Software Testing 518 Activities 542
20.7.1 Use Case--Based Testing 518 21.5.1 Maintenance Process Models 542
20.7.2 Object State Testing with 21.5.2 Program Understanding 543
ClassBench 520 21.5.3 Change Identification and
20.7.3 Testing Class Hierarchy 523 Analysis 544
20.7.4 Testing Exception-Handling 21.5.4 Configuration Change Control 547
Capabilities 524 21.5.5 Change Implementation, Testing, and
20.8 Testing Web Applications 525 Delivery 547
20.8.1 Object-Oriented Model for Web 21.6 Reverse-Engineering 547
Application Testing 525 21.6.1 Reverse-Engineering Workflow 548
20.8.2 Static Analysis Using the 21.6.2 Usefulness of Reverse-Engineering 548
Object-Oriented Model 526 21.6.3 Reverse-Engineering: A Case
20.8.3 Test Case Generation Using the Study 549
Object-Oriented Model 527
xiv Contents
24.7 Software Security in the Life Cycle 614 C Software Tools 647
24.7.1 Security in the Planning Phase 615 C.1 NetBeans 647
24.7.2 Security in the Iterative Phase 623 C.2 Using JUnit 648
24.8 Applying Agile Principles 627 C.3 Running JUnit in NetBeans 652
24.9 Tool Support for Software Security 628 C.4 The Emma Coverage Tool 652
Summary 629 C.5 The Cobertura Coverage Tool 653
Further Reading 629 C.6 Web Application Testing with HttpUnit 655
Chapter Review Questions 630 C.6.1 Configure an IDE to Use HttpUnit 655
Exercises 630 C.6.2 Implementing Test Cases in
HttpUnit 655
• Appendices • C.7 Using CVS and Subversion in NetBeans 656
A Personal Software Process: Estimation, C.7.1 Creating a CVS Remote
Planning, and Quality Assurance 631 Repository 656
A.1 Effort Estimation in PSP 631 C.7.2 Setting Up Subversion in NetBeans 658
C.7.3 Checking Out Files from a
A.2 Software Quality Assurance in PSP 632
Repository 659
A.3 Design and Quality 633
C.7.4 Editing Sources and Viewing
B Java Technologies 634 Changes 661
C.7.5 Viewing File Status 662
B.1 Getting Started with Database
Connectivity 634 C.7.6 Comparing File Revisions 662
B.1.1 What Is Database Connectivity? 634 C.7.7 Merging Changes from Repository 662
B.1.2 Setting Up Data Sources 634 C.7.8 Resolving Conflicts 663
B.1.3 Accessing Databases from a C.7.9 Updating Local Copies 663
Program 635 C.7.10 Committing Local Files to a
Repository 663
B.2 Getting Started with Swing 636
C.7.11 Importing Files into a Repository 664
B.2.1 Creating Main Window with JFrame 637
B.2.2 Using Layout Managers to Arrange D Project Descriptions 665
Components 638
D.1 Car Rental System 665
B.2.3 Processing Button Events with Action
D.2 National Trade Show Service System 666
Listener 640
B.2.4 Implementing Drawing Capabilities 640 D.3 Study Abroad Management System 667
B.3 Getting Started with Java Server D.4 UML Class Diagram Editor 669
Pages 642 D.5 Radio Communication Simulator 670
B.3.1 What Are Java Server Pages? 642 D.6 Object State Testing Environment 672
B.3.2 JSP Workflow 642
B.3.3 Installing a Web Server with a JSP References 675
Container 643
B.3.4 Using Java Server Pages 643 Index 682
Preface
BACKGROUND
•
Computers are widely used in all sectors of our society, performing a variety of
functions with the application software running on them. As a result, the market for
software engineers is booming. The March 2006 issue of Money magazine ranked
software engineer as number 1 of the 50 best jobs in the United States. According
to the Bureau of Labor Statistics (BLS) 2010–2020 projections, the total number of
jobs in application development software engineer and systems analyst positions is
expected to increase from 520,800 to 664,500 (27.6%) and from 544,400 to 664,800
(22.10%), respectively. To be able to perform the work required of an application de-
velopment software engineer or systems analyst, an education in software engineering
is highly desired. However, according to the data released by BLS (“Earned Awards
and Degrees, by Field of Study, 2005–2006”), only 160 bachelor and 600 master’s
degrees in software engineering, and 10,289 bachelor and 4,512 master’s degrees in
computer science were awarded in 2006. Thus, there is a significant gap between the
demand and supply, especially for graduates with a software engineering degree.
Many people do not know the scope and usefulness of software engineering as a
practice, and the discipline is often misunderstood. Many media outlets seem to de-
fine software engineering as writing Java programs. Some students think that software
engineering includes everything related to software. Others think that software engi-
neering is drawing UML diagrams, as the following story illustrates. Several years
ago, after the first class of an object-oriented software engineering (OOSE) course,
a student said to me, “Professor, you know that this will be an easy course for me
because we’ve drawn lots of UML diagrams before.” At the end of the semester, the
student came to me again and said, “Professor, I want to tell you that we worked very
hard, but we learned a lot about OO design. It is not just drawing UML diagrams
as I thought.” So what is software engineering? As a discipline, it encompasses re-
search, education, and application of engineering processes, methodologies, quality
assurance, and project management to significantly increase software productivity
and software quality while reducing software cost and time to market. OOSE is a
branch of software engineering that is characterized by its view of the world as con-
sisting of objects relating to and interacting with each other. The advent of the C++
programming language in the 1980s marked the beginning of the OOSE era. Since
then, software production began its unprecedented worldwide growth and was further
accelerated by the creation and worldwide adoption of the unified modeling language
(UML) and the unified process (UP). Strictly speaking, a software process describes
the phases and what should be done in each phase. It does not define (in detail) how
to perform the activities in each phase. A modeling language, such as UML, defines
xvi
Preface xvii
the notations, syntax, and semantics for communicating and documenting analysis
and design ideas. UML and UP are good and necessary but not sufficient. This is
because how to produce the analysis and design ideas required to draw meaningful
UML diagrams is missing.
MOTIVATION
•
To fill the gaps discussed in the last paragraph, we need a methodology or a “cook-
book.” Unlike a process, a methodology is a detailed description of the steps and
procedures or how to carry out the activities to the extent that a beginner can follow
to produce and deploy the desired software system. Without a methodology, a be-
ginning software engineer would have to spend a few years of on-the-job training to
learn OO design, implementation, and testing skills.
This book is also motivated by emerging interests in agile processes, design
patterns, and test-driven development (TDD). Agile processes emphasize teamwork,
design for change, rapid deployment of small increments of the software system, and
joint development with the customer and users. Design patterns are effective design
solutions to common design problems. Design patterns promote software reuse and
improve team communication. TDD advocates testable software, and requires test
scripts to be produced before the implementation so that the latter can be tested
immediately and frequently.
As an analogy, consider the development of an amusement park. The overall pro-
cess includes the following phases: planning, public approval, analysis and design,
financing, construction drawings, construction, procurement of equipment, installa-
tion of equipment, preopening, and grand opening. However, knowing the overall
process is not enough. The development team must know how to perform the activi-
ties of the phases. For example, the planning activities include development of initial
concept, feasibility study, and master plan generation. The theme park team must
know how to perform these activities. The analysis and design activities include “re-
quirements acquisition” from stakeholders, site investigation, design of park layout,
design of theming for different areas of the park, creating models to study the layout
design and theming, and producing the master design. Again, the theme park team
must know how to perform these activities to produce the master design. Unlike a
process that describes the phases of activities, a methodology details the steps and
procedures or how to perform the activities.
The development of an amusement park is a multiyear project and costs billions
of dollars. The investor wants the park to generate revenue as early as possible, but
with the above process, the investor has to wait until the entire park is completed.
Once the master design is finalized, it cannot be modified easily due to the restrictions
imposed by the conventional process. If the park does not meet the expectations of
the stakeholders, then changes are costly once the park is completed.
Agile processes are aimed to solve these problems. With an agile process, a list
of preliminary theme park requirements is acquired quickly and allowed to evolve
during the development process. The amusement and entertainment facilities are then
derived from the requirements and carefully grouped into clusters of facilities. A plan
xviii Preface
to develop and deploy the clusters in relatively short periods of time is produced,
that is, rapid deployment of small increments. Thus, instead of a finalized master
design, the development process designs and deploys one cluster at a time. As the
clusters of facilities are deployed and operational, feedback is sought and changes to
the requirements, the development plan, budget, and schedule are worked out with the
stakeholders—that is, joint development. In addition, the application of architectural
design patterns improves quality and ability of the park to adapt to changing needs—
that is, design for change. Teamwork is emphasized because effective collaboration
and coordination between the teams and team members ensure that the facilities will
be developed and deployed timely and seamlessly. The agile process has a number
of merits. The investor can reap the benefits much earlier because the facilities are
operational as early as desired and feasible. Since a small number of the facilities
are developed and deployed at a time, errors can be corrected and changes can be
made more easily.
In summary, this text is centered around an agile unified methodology that in-
tegrates UML, design patterns, OO software testing, and TDD, among others. The
methodology presented in this book is called a “unified methodology” because it uses
UML as the modeling language and it follows an agile unified process. It does not
mean to unify any other methods or to be used as a “unified” methodology for all
projects.
AUDIENCES
•
This book is for students majoring in computer science or software engineering as
well as for software development professionals. In particular, it is intended to be used
as the primary material for upper-division undergraduate and introductory graduate
courses and professional training courses in the IT industry. This book’s material
evolved over the last decade from courses taught at several universities and companies,
both domestically and internationally, as well as from applications of the material to
industry-sponsored projects and projects conducted by software engineers in various
companies. These projects allowed me to observe closely how students and software
engineers applied UP, UML, design patterns, and TDD, and the difficulties they faced.
Their feedback led to continual improvement of the material.
ORGANIZATION
•
The book has 24 chapters, divided into eight parts:
Part I. Introduction and System Engineering. This part consists of the first
three chapters. It provides an overview of the software life-cycle activities. In
particular, it covers software process models, the notion of a methodology, the
difference between a process and a methodology, and system engineering.
Part II. Analysis and Architectural Design. This part presents the planning
phase activities. It includes requirements elicitation, domain modeling, and ar-
chitectural design.
Preface xix
Part III. Modeling and Design of Interactive Systems. This part deals with
the modeling and design of interactive systems. It consists of six chapters. These
chapters present how to identify use cases from the requirements, how to model
and design actor-system interaction and object interaction behavior, how to apply
responsibility assignment patterns, how to derive a design class diagram to serve
as the design blueprint, and how to design the user interface.
Part IV. Modeling and Design of Other Types of Systems. This part consists
of three chapters; each presents the modeling and design of one type of sys-
tem. In particular, Chapter 13 presents the modeling and design of event-driven
systems. Chapter 14 presents the modeling and design of transformational sys-
tems. Chapter 15 presents the modeling and design of business rule-based
systems.
Part V. Applying Situation-Specific Patterns. This part consists of two chap-
ters and presents how to apply situation-specific patterns. A case study, that is,
the design of a state diagram editor, is used to help understand the process.
Part VI. Implementation and Quality Assurance. This part consists of three
chapters. They present implementation considerations, software quality assur-
ance concepts and activities, and software testing.
Part VII. Maintenance and Configuration Management. This part includes
two chapters and covers software maintenance and software configuration man-
agement.
Part VIII. Project Management and Software Security. The last part of the
book consists of the last two chapters. One of the chapters presents software
project management. The other chapter covers software security, that is, life-
cycle activities concerning the modeling and design of secure software
systems.
The material can satisfy the needs of several software engineering courses. For
example,
1. Part I through Part III and selected topics from Part VI to Part VIII are a good
combination for an Object-Oriented Software Engineering (OOSE) course or an
Introduction to Software Engineering course. This could be a junior- or senior-
level undergraduate course as well as an introductory graduate-level course.
2. Part II, Part V, and selected sections from the other chapters could form a Software
Design Patterns course. It is recommended that the OOSE course described above
be a prerequisite for this course. However, many international students may not
have taken the OOSE course. In this case, a review of the methodology presented
in Part II and Part III is recommended. The review of the methodology provides
the framework for applying patterns. The review may take two to four weeks.
3. Part VI and Part VII could be taught in various ways. They could form one
course—Quality Assurance, Testing, and Maintenance. They could be taught as
two courses—Software Quality Assurance, and Software Testing and Mainte-
nance. Alternatively, these chapters could be taught as three courses—Software
Quality Assurance, Software Testing, and Software Maintenance.
xx Preface
4. Chapters 13–15, 19, and 20 plus selected patterns from the other chapters may
form a course on modeling, design, verification, and validation of complex
systems.
5. Part I, Parts VI to VIII, and selected chapters from the other parts may form a
Software Project Management course.
6. Finally, Part I, Parts II, and Chapter 24 plus selected patterns and topics from
the other chapters may comprise a course on Introduction to Software Secu-
rity. The instructor may supply additional materials to make this course more
comprehensive.
Various teaching supplements can be found at http://www.mhhe.com/kung. These
include PowerPoint teaching slides, pop quiz and test generation software, databases
of test questions, sample course descriptions and syllabi, lab work manuals, and
software tools. Instructors who have not taught the courses may find these teaching
tools helpful in reducing preparation time and effort.
ACKNOWLEDGMENTS
•
I would like to thank my numerous students who constantly stimulate me with their
questions, feedback, enthusiasm, and effort to apply the methodology to real-world
projects. My students also read and used the textbook and teaching materials. They
have provided me with valuable feedback and improvement suggestions. Some of
them participated in the design and implementation of tools supporting the method-
ology presented in this book. Some were involved in experiments assessing the effec-
tiveness of the methodology. Many continue to practice the methodology in industry
after graduation and share with me their valuable experiences. I want to thank my
daughter, Jacquelyn Kung, for editing a few chapters of the draft manuscript. Thanks
are due to Raghu Srinivasan, the Global Publisher of McGraw-Hill Engineering &
Computer Science Department, for his valuable improvement suggestions and guid-
ance throughout the publication process. I also want to thank the reviewers for their
comments and suggestions. These comments and suggestions have significantly im-
proved the organization, presentation, and many other aspects of the book. During
the lengthy writing process, my wife, Cindy Kung, and many of my colleagues in the
academic institutions and industry in which I have collaborated, provided me constant
encouragement and invaluable support. Thanks are due to them as well.
part I
Introduction and System
Engineering
Chapter 1 Introduction 2
Chapter 2 Software Process and Methodology 16
Chapter 3 System Engineering 53
1
1
Introduction
2
Chapter 1 Introduction 3
the need for an engineering approach to software production. Since then, software
engineering has become a discipline and remarkable progress has been made. The
efforts that have taken place in the field have led to the following definition.
That is, the overall objectives of software engineering are significantly increasing
software productivity (P) and quality (Q) while reducing software production and op-
erating costs (C) and time to market (T). These objectives are abbreviated as PQCT.
Research, education, and application of software engineering processes and methods
are the means to accomplish these goals. These processes and methods are classified
into three sets of activities: development, quality assurance, and project manage-
ment activities. The development activities transform an initial system concept into
an operational system. The quality assurance activities ensure that the development
activities are carried out correctly and that the artifacts produced by the activities
are correct. These ensure that the desired software system is produced and delivered.
Project management activities plan for the project, schedule and allocate resources
to the development and quality assurance activities, and ensure that the system is
developed and delivered on time and within budget.
40 software engineers to work for one year. When two or more software engineers
work together to develop a software system, serious conceptualization, communica-
tion, and coordination problems arise.
Conceptualization is the process of observing and classifying real-world phe-
nomena to form a mental model to help understand the application for which the
system is built. Conceptualization is a challenge for teamwork because the software
engineers may perceive the world differently due to differences in their education,
cultural backgrounds, career experiences, assumptions, and other factors. The an-
cient story about four blind men and an elephant illustrates this problem. The four
blind men wanted to know what an elephant looked like. They obtained permission
to touch the elephant. One blind man touched one leg of the elephant and said that
an elephant was like a tree trunk. The other three touched the elephant’s stomach,
tail, and ear, respectively. They said that an elephant was like a wall, a rope, and
a fan. We as software developers are like the four blind men trying to perceive or
understand an application. If the developers perceive the application differently, then
how can they design and implement software components to work with each other?
Software engineering provides a solution. That is, the modeling techniques presented
in this book help the software engineers establish a common understanding of the
application domain and the business processes of the application.
When a team of software engineers work together, they need to exchange their
understanding and design ideas. However, the natural language is too informal and
often leads to misunderstanding. Software engineering provides the Unified Mod-
eling Language (UML) for software engineers to communicate their ideas. Finally,
when teams of software engineers work together, how can they collaborate and co-
ordinate their efforts? For example, how do they divide the work and assign the
pieces to the teams and team members? How do they integrate the components de-
signed and implemented by different teams and team members? Again, software
engineering provides a solution. That is, the agile unified methodology presented in
this book lets the software engineers collaborate in a way that everybody understands
and follows.
[embedded or software/
hardware system]
System Requirements
Definition, System Design, &
Allocation
allocated system
[software-only requirements
system] Software Requirements
Analysis
software requirements
specification
Software Design
software design document
Coding & Unit Testing
executable components
Integration &
Integration Testing
integrated software
Acceptance Testing
field operational system
Maintenance
for a radio communication system (RCS). The system is similar to a cellular network
except that it has only one high-power base station that serves an area much larger
than a cell in a cellular network. The system requirements specify the capabilities for
the whole system. The following are four of the many system requirements identified.
R1. The RCS shall allow mobile subscribers to initiate calls to other mobile
subscribers and land-line telephones.
R2. The RCS shall allow mobile subscribers to answer calls from other
subscribers.
R3. The RCS shall provide call accounting to capture and record mobile calls
and bill to the subscriber accounts.
R4. The RCS shall allow authorized account administrators to manage sub-
scriber accounts.
System design determines the major subsystems of the total system and specifies
the relationships between the subsystems. These are depicted in a system architectural
design diagram. Figure 1.3 shows an architectural design for the RCS using a block
diagram. It depicts three subsystems: mobile unit, base station, and account manage-
ment. A mobile unit consists of a mobile hardware subsystem and a mobile software
Chapter 1 Introduction 7
Events
Mobile High-Power Controller
Software Instructions Transceivers Hardware
account administrator can do to manage the accounts. Thus, the requirement is refined
as follows:
R4.1. The RCS shall allow an authorized account administrator to create a sub-
scriber account.
R4.2. The RCS shall allow an authorized account administrator to activate a
subscriber account.
R4.3. The RCS shall allow an authorized account administrator to deactivate a
subscriber account.
R4.4. The RCS shall allow an authorized account administrator to close a sub-
scriber account.
R4.5. The RCS shall allow an authorized account administrator to delete a sub-
scriber account that is already closed.
The account administrator needs to login to perform these operations and logout
to prevent others to access the accounts. These are examples of software requirements
that are identified during the software requirements analysis phase.
Software Design
Software design determines the software architecture, or the overall structure, of
the software system. It specifies the subsystems, their relationships, the subsystems’
functions, interfaces, and how the subsystems interact with each other. Design of the
user interface is another important activity of software design. That is, it depicts the
look and feel of the windows and dialogs, and describes how the system interacts
with the users. Software design also specifies the information processing algorithms.
As an example for the architectural design for the RCS, Figure 1.4 shows the
N-tier architecture for the account management system. The architecture organizes the
classes or objects into separate layers. Each layer has clearly defined responsibilities
and requests the services of the next layer. For example, the user/device interface layer
provides services to the account administrator and the software controller. It uses the
services of the controller layer. The layered architecture simplifies the implementation
of the business processes. For instance, when the account administrator wants to create
an account, the user interface forwards the request to the create account controller
User/Device Controller
Interface Layer Layer Database Layer Network Layer
Requests Requests
Responsible for Responsible for Responsible for Responsible for Responsible for
interacting with the executing the executing functions storing/retrieving network
users/devices business processes of individual objects from a communication
business objects database functions
in the controller layer. The controller creates the Account object, and saves it to the
database through the database layer. This shows that the functions of each layer are
relatively easy to implement and use. Another advantage of the N-tier architecture is
that change to a layer has little impact on other layers, provided that the layer-to-layer
interfaces remain unchanged.
Software requirements
specification (SRS)
We must ensure that the Software Requirements We must check and make
development activities Analysis sure that the SRS, design,
are carried out correctly. and code are correct.
Software Design
conform to the quality standards. For example, if the RCS project uses the water-
fall process, then verification ensures that the phases of the waterfall are carried out
correctly. It also checks that the RCS system requirements specification, system de-
sign, allocation, software requirements specification, software design, and the other
artifacts are produced and meet the required quality standards. Validation checks the
correctness of the software artifacts produced by the development activities. For ex-
ample, validation for the RCS checks the system and software requirements to ensure
that they specify the real business needs. It also checks that the system as well as
the software design satisfies the requirements and constraints, and the implemented
software system solves the intended business problems.
Validation activities are classified into static validation and dynamic validation
activities. Static validation checks the correctness of the software artifacts without
executing the software. It is applicable to artifacts that are not executable, such as
requirements specification and software design documents. This is similar to exam-
ining the specifications of a car to determine whether it satisfies the needs of the car
buyer. Dynamic validation executes the software to ensure that it works and produces
the correct result. Software testing is a dynamic validation technique. It executes the
software using test cases and checks that the test result matches the expected result.
It is similar to test-driving a car to ensure that it indeed meets the functional and
performance requirements.
Unit testing for the account management system generates test cases to check that
each of the classes in the interface, controller, business objects, database, and network
layers correctly implements the functionality of the class. Integration testing generates
test cases to test and ensure that these classes work with each other. Acceptance testing
derives test cases from the requirements of the account management system to ensure
that the system satisfies the requirements.
plan also includes a quality assurance plan. The quality assurance plan specifies
the quality standards, the SQA activities, and a schedule of such activities. Also
included in the project plan is a risk management plan, described below.
• Risk management. Many events could jeopardize a project. For example, a man-
agement person or a key technical staff leaves the project, or the project is far
behind schedule. These are called risk items. Risk management attempts to re-
duce the impact of such events through risk management planning. The risk
management plan identifies the risk items, prioritizes them according to their
likelihood and damage to the project, and specifies risk resolution measures to
counter the risks when any of them occur.
• Project administration. Project administration is an ongoing function of project
management. It performs the management activities as specified in the project
plan. It is concerned with the continuous monitoring of project progress and
executing the actions necessary to adapt the project to the new situation. It also
includes daily management of project activities such as coordinating the project
teams or team members, scheduling and conducting meetings, and solving day-
to-day problems.
• Software configuration management. During the development process, numer-
ous software artifacts are produced. These include requirements specification,
software design, code, test cases, user’s manual, and the like. These compose the
software, or part of it, under different stages of the development process. For ex-
ample, the requirements specification is the software in its nonexecutable form.
The design specification is a refinement of the requirements specification. The
code is a refinement of the design. These documents depend on each other. For
example, software design depends on the requirements. If the requirements are
changed, the design has to change. This in turn may require change to the code that
implements the design. Therefore, software engineering needs a mechanism to
coordinate so that changes are made consistently. This is software configuration
management (SCM).
3. OO software development methodologies that detail the steps or how to carry out
the activities of a software process.
4. OO development tools and environments to support the development processes
and methodologies. There are commercial products as well as public domain
software. For example, the NetBeans integrated development environment (IDE)
is a free, open source software. It comes with a bundle of plugins that support
activities of the entire software development life cycle.
Modeling Techniques (OMT), Use Case Engineering, and other methods. Agile meth-
ods include Scrum, Dynamic System Development Method (DSDM), Feature Driven
Development (FDD), Crystal Clear, Extreme Programming (XP), Lean Development
Method, and others.
and principles. Consider, for example, the design of a software system that needs
to access a database. Computer science disciplines might emphasize efficient data
storage and retrieval and favor a design in which the business objects access the
database directly. Such a design is said to create a tight coupling between the business
objects and the database. Software engineering would not consider this as a good
design unless performance is a serious concern. If the database, or the database
management system (DBMS) is changed, then the business objects have to change.
This may be difficult and costly. If the database is at a remote location, then the
business objects must know how to communicate with the remote database. These
result in complex business objects, which are difficult to test and maintain.
Despite the differences, software engineering and computer science are closely
related. Computer science to software engineering is like physics to electrical and
electronics engineering, or chemistry to chemical engineering. That is, computer sci-
ence is a theoretical and technological foundation of software engineering. Software
engineering is the application of computer science. However, software engineering
has its own research topics. These include research in software processes and method-
ologies, software verification, validation, and testing techniques, among many others.
Software engineering research is aimed at significantly improving software PQCT
and the trade-off between them.
Software engineering is a broad area. A software engineer should know the dif-
ferent areas of computer science including database systems, operating systems, data
structures and algorithms, programming languages, and compiler construction, to
mention a few. Embedded systems development requires the software engineer to
have a basic understanding of electronic circuits and how to interface with hardware
devices. Finally, it takes time for a software engineer to gain domain knowledge
and design experience to become a good software architect. These challenges and
the ability to design and implement large complex systems to meet practical needs
make software engineering an exciting area. The ever-expanding computer applica-
tion creates great opportunities for the software engineer and software engineering
researcher.
SUMMARY
•
Software engineering is defined as a discipline that and software engineering. That is, computer science is
investigates and applies engineering processes and a foundation of software engineering. While computer
methodologies to improve software PQCT. The need science is mainly concerned with optimization and
for software engineering is discussed and software efficiency, software engineering is concerned with
life-cycle activities are described. OO software en- software PQCT. Knowing these helps a developer
gineering is a specialization of software engineer- understand software engineering and the rationale
ing. It views the world and systems as consisting of behind the processes, methodologies, modeling lan-
objects relating to and interacting with each other. guages, design patterns, and many others. All these
The chapter ends with a discussion of the differ- are designed to improve software PQCT.
ences and relationships between computer science
Chapter 1 Introduction 15
FURTHER READING
•
Many books provide comprehensive coverages of the dis- publishes UML specifications and related articles. Many
cipline of software engineering. Some examples are [123, books on agile development are available. These include
125, 139]. OOSE books include [40, 133], among many oth- [21, 50, 52, 119, 124, 140]. The agile alliance website
ers. An excellent introduction to OO analysis and design is (http://www.agilealliance.org/) is an excellent resource. It
presented in [104]. Numerous books that describe UML and publishes numerous good articles and discussions on the
UP have been published, notably [36, 63, 91]. The Object topic.
Management Group (OMG) website (http://www.omg.org)
EXERCISES
•
1.1 Search the literature and find four other definitions of 1.5 There are interdependencies between software pro-
software engineering in addition to the one given in ductivity, quality, cost, and time to market. For ex-
this chapter. Discuss the similarities and differences ample, more time and effort spent in coding could
between these definitions. increase productivity. This may result in less time
1.2 Describe in a brief article the functions of soft- and effort in software quality assurance because the
ware development process, software quality assur- total time and effort are constants. Poor quality could
ance, software project management, and software cost productivity due to rework. Identify three pairs
configuration management. Discuss how these work of such interdependencies of your choice. Discuss
together during the software development life cycle. their short-term and long-term impacts on the soft-
Discuss how they improve software PQCT. ware development organization. How should soft-
1.3 Should optimization be a focus of software engineer- ware engineering solve the “dilemmas” induced by
ing? Briefly explain, and justify your answer with a the interdependencies?
practical example. 1.6 What are the differences and relationships between
1.4 Identify three computer science courses of your OO software engineering and conventional software
choice. Show the usefulness of these courses in the engineering? Discuss whether object-oriented soft-
software life-cycle activities. ware engineering will replace conventional software
engineering.
2
Software Process
and Methodology
Writing programs that consist of a few thousand lines of code might be an unprece-
dented experience and a challenge for many undergraduate and graduate students.
However, in the software industry, software development for systems that consist of
millions of lines of code is a common practice. The difference between academic pro-
gramming projects and real-world software development projects is not limited to the
number of lines of code. Systems development in the real world has to overcome many
other challenges. To overcome these challenges, a disciplined approach to systems
development is required. This is commonly called a software process. The waterfall
process presented in Chapter 1 is such a process or process model. Many software
development organizations adopt the waterfall process partly due to its simplicity.
However, experiences show that the waterfall process is associated with a number of
problems. To overcome these problems, many other software process models have
been proposed. The software industry then discovered that software development
requires not only a process but also a methodology. While a process specifies the
activities to be performed to develop a software system, a methodology defines the
steps and how to perform the steps to carry out the activities of a process. In other
words, a methodology is an implementation of a process.
In summary, this chapter presents the following:
• Challenges of system development in the real world.
• Merits and limitations of the waterfall process.
• Other well-known software process models.
• Software methodology and the differences between process and methodology.
16
Chapter 2 Software Process and Methodology 17
Besides project challenges, there are product challenges. Some examples are:
requirements had to change every week during the first three months due to
change requests from the customer.
• System Challenge 2. How do we design the processes and the products to cope
with changes that are often inevitable and the exact changes are impossible to
predict?
• System Reality 3. The system will evolve for many many years, creating a
maintenance challenge. For example, changes are not documented or poorly
documented, changes to the system may introduce bugs as well as deteriorate
the structure of the system. All these make the system more and more difficult
to understand, test, and maintain.
• System Challenge 3. How do we design the system so that changes can be made
relatively easily and without much impact to the rest of the system?
• System Reality 4. The system may consist of hardware and software components,
use third party components and multiple implementation languages, and run on
multiple platforms and machines located at different places.
• System Challenge 4. How do we design the system to hide the hardware, plat-
form, and implementation peculiarities so that changes to these will not affect
the rest of the system?
The list is not complete. There are many more challenges in the real world that
are not included. However, the list is enough to show that a scientific approach is not
adequate to tackle the challenges. We need an engineering approach. Two important
components are software process and software methodology.
For example, the waterfall process, presented in Chapter 1, exhibits a strict se-
quence of development activities. The requirements phase produces the requirements
specification, the design phase produces the design, and so on. Frequently, the entrance
and exit criteria specify the software artifacts that must be available and produced,
respectively.
Chapter 2 Software Process and Methodology 19
personal preference of the evaluator. In comparison, many software systems are sub-
ject to lifelong testing. For example, a computerized sell-off on May 6, 2010, sent
the Dow Jones Industrials to a loss of nearly 1,000 points or 10% of its value at one
time. Procter & Gamble, a stable blue chip stock, dropped almost 37% to a seven-year
low. These were caused by a simple typographical error that should have been pre-
vented. The software system has been in use for decades before the incident occurred.
This and many other software-related incidents explain why software systems need
lifelong testings. While the solution to a tame problem could be adapted to solve a
similar problem, every application software development project is unique. This is
why application software is developed or custom made, not manufactured.
Software development is not a scientific process—in other words, many decisions
are not made scientifically but politically and economically. For example, a good-
enough algorithm is chosen instead of an optimal one because it is more economical
to implement, use, and maintain the good-enough algorithm. Sometimes, the choice
to use a specific programming language or DBMS is a political decision. In one
project that the author was contracted to develop, the client requested not to use a
certain product because the client had a bad experience with its vendor. Finally and
importantly, software failures could result in millions of dollars of property damages
and loss of human lives. Therefore, software developers have no right to be wrong.
Tame problems do not share this property—if the result is incorrect, then the software
developer can simply try again.
Cumulative cost
Determine
• Objectives
• Alternatives
• Constraints
• Evaluate
Risk alternatives
analysis • Identify and
resolve risks
Risk
analysis
Risk
analysis
Operational
prototype
Prototype 3
Risk Prototype 2
analy-
sis Prototype 1
Commitment
Review
Partition • Requirements Simulation, models, benchmarks
plan Concept of
• Life-cycle plan Require-
operation
ments
Software
Detailed
design
• Development plan design
Requirements
validation
Code
• Integration &
Design Unit test
test plan
V&V
• Plan next Integration
phases & test • Develop and
verify next
Acceptance
level product
test
Implementation
Progression
through steps
3. Develop and verify next level system (the southeast corner). This step proceeds
like the waterfall model, as shown in Figure 2.2.
4. Plan next phases (the southwest corner). For either a new initiative or a contin-
uing project, this step defines the requirements, the life-cycle activities, and the
integration and test plan for the next phase.
Core
workflows Inception Elaboration Construction Transition Inception Elaboration Construction Transition
Requirements
Analysis
Design ...
Implementation
Test
Iterations Iterations
Cycle 1 ... Cycle k
Release 1 Release k
requirements analysis, design, implementation, and testing. The gray areas in Fig-
ure 2.3 are rough indications of the extent of the workflow activities that are carried
out during the phases. The focuses of the four phases are described below.
Inception. The first one or two iterations constitute the inception phase. This
phase produces a simplified use case model, a tentative software architecture,
and a project plan. In simple terms, a use case models a business process of
the application for which the system is being developed. Verb-noun phrases are
used to describe use cases. For example, Deposit Money, Withdraw Money, and
Check Balance are use cases for an automatic teller machine (ATM). The use
case model contains the most critical use cases of the software system.
Elaboration. The elaboration phase consists of the next several iterations. During
this phase, most use cases are specified, and UML diagrams representing the
architectural design are produced. The most critical use cases of the software
system are designed and implemented.
Construction. During the construction phase, the remaining use cases are itera-
tively developed and integrated into the system. The system can be incrementally
installed in the target environment.
Transition. During the transition phase, activities are performed to deploy the
software system. These include user training, beta testing, defect correction, and
functional enhancement.
The UP focuses on identifying use cases and uses them to plan the iterations
to develop and deploy the system. In this sense, the UP is characterized as use case
Chapter 2 Software Process and Methodology 25
driven. The UP determines the architecture or the overall structure of the system early
in the life cycle, and uses it to guide the development of the software system. For this
reason, the UP is said to be architecture-centric. The other two features of the UP
are that it is iterative and incremental because the system is developed and deployed
iteratively and incrementally.
PSP Script
In PSP, all processes are described using process scripts or scripts for short. Each script
specifies the purpose, the entry criteria, the steps or activities of the process, and the
26 Part I Introduction and System Engineering
exit criteria. For example, the baseline process PSP0 consists of six phases: planning,
design, code, compile, test, and postmortem. This process can be described by the
script shown in Figure 2.4. It consists of three steps: (1) planning, (2) development,
which encompasses design, code, compile, and test, and (3) postmortem. The entry cri-
teria of a script specify the software artifacts that must be available before the process
can begin. The steps list the activities and descriptions of the activities. The exit criteria
specify the software artifacts that must be produced when the process is completed.
The postmortem step in Figure 2.4 is a unique feature of the PSP. It requires the
software engineer to complete a Project Plan Summary form with the actual time,
defect, and size data. This form is described in PSP Forms below. The software
engineer completes the form at the end of each programming exercise. The form
allows the software engineer to observe his personal software practices, identify areas
to improve, and acquire data to use in estimation.
The PSP adopts a recursive view of the development process. That is, a process
consists of a series of activities and an activity can be described by a lower-level
process. For example, the planning step in Figure 2.4 is a process, which can be
described by another script. The script may consist of a requirements step, a resource
estimation step, and a scheduling step. Similarly, the development step in Figure 2.4
can be described by a script consisting of design, code, compile, and test steps.
PSP Forms
PSP uses forms to facilitate documentation. Each form specifies the ordinary informa-
tion such as student name, date, program name, program number, instructor, and the
Chapter 2 Software Process and Methodology 27
Project Phase Start Date and Time Interrupt Time Stop Date and Time Delta Time Comments
Project Date Number Type Inject Remove Fix Time Fix Ref.
1 1/19 1 20 Code Comp. 1
Description Missing semicolon.
Project Date Number Type Inject Remove Fix Time Fix Ref.
2 20 Code Comp. 1
Description Missing semicolon.
defect, the student enters the program number, the date on which the defect was found,
the defect identification number, the type of the defect, the phase in which the defect
was introduced and removed respectively, the time spent to find and fix the defect, the
defect number that during its fix, introduces the current defect, and a brief description
of the defect including the error and why it was introduced.
The Project Plan Summary Form The Project Plan Summary form mentioned in the
last section is shown in Figure 2.8. It consists of four sections. At the top of the form
is the descriptive information, which specifies the student name, date, program name,
program number, instructor, and the programming language used. The Time in Phase
(in minutes) section specifies the Plan time for the process, and the Actual time, the
To Date time, and the To Date % time for each of the phases. For example, if a student
spent 30 minutes in the design phase for the first program, and 25 minutes in the
design phase for the second program, then the Actual and To Date times for the first
program are 30 minutes. The Actual and To Date times for the second program are
25 minutes and 55 minutes, respectively. If the total To Date time for the first program
is 117 minutes, then the To Date % time for the first program is 25.6% (i.e., 30 divided
by 117). The Defects Injected section has the same columns and rows as the Time
in Phase section and records the number of defects by phase. The Defects Removed
section is similar to the Defects Injected section and records the number of defects
removed by phase.
The PSP also includes methods to help the software engineer in estimation and
planning. In addition, PSP presents quality assurance procedures to help the software
engineer improve software quality. These are presented in Appendix A.
Cycle 1 Lauch
Cycle 2 Lauch
Cycle 3 Lauch
Strategy 1
Plan 1 Strategy 2
Requirements 1 Plan 2 Strategy 3
Design 1 Requirements 2 Plan 3
Implementation 1 Design 2 Requirements 3
Test 1 Implementation 2 Design 3
Postmortem 1 Test 2 Implementation 3
Postmortem 2 Test 3
Postmortem 3
Finished Product
Final Evaluation
cycle performs a series of activities. A TSP project begins with a TSP launch process
to build the team and produce a project plan. The launch process is guided by a trained
and qualified TSP coach. The process identifies the customer’s needs, assigns roles
to team members, produces an initial system concept, a development strategy, and
a plan to develop the system. The TSP team also produces a quality plan and a risk
management plan. The plans are presented to the management, which may approve
or request changes. The last step of each cycle is the postmortem. At the postmortem
meeting, the team reviews the launch process, identifies and records improvement
suggestions, and assigns follow-up items to team members.
The TSP activities of each cycle are specified in a script. Figure 2.10 illustrates
a script that is tailored to use the methodology presented in this textbook. That is, the
methodology implements the TSP process. The script shown in Figure 2.10 is designed
to fit one semester of teamwork, including learning. It has been tested several times.
However, the script can be modified, or tuned to fit different situations. For example,
it could run in a shorter period. In this case, there will be only one or two cycles. It
could drop some topics, such as applying situation-specific patterns could be moved
to another course. Another alternative is running the script to produce only the design
but not the implementation.
Agile Manifesto
According to the Agile Manifesto,1 agile development values four aspects of soft-
ware development practices, which are different from their conventional, plan-driven
counterparts. These are listed and explained below.
• Agile development values individuals and interactions over processes and tools.
• Agile development values working software over comprehensive documentation.
• Agile development values customer collaboration over contract negotiation.
• Agile development values responding to change over following a plan.
1. Agility values individuals and interactions over processes and tools.
Conventional, plan-driven practices believe that a good software process is es-
sential for the success of a software project. One conventional wisdom is that
1 See www.agilemanifesto.org.
Chapter 2 Software Process and Methodology 31
• Test driven develop and inspect cycle 2, accomplish 100% branch coverage.
IMP2
• Review unit test cases and code.
10 • Build, integrate, and test cycle 2, demonstrate cycle 2 software to the customer and users, solicit and
TEST2 record feedback.
• Produce user documentation for cycle 2.
• Conduct a postmortem and write the cycle 2 final report.
PM2 • Produce role and team evaluations for cycle 2.
11 LAU3 • Reform teams and roles for cycle 3.
STRAT3, • Produce the strategy and plan for cycle 3, assess risks.
PLAN3, REQ3 • Update and review requirements, domain model, use cases, traceability matrix, and allocation matrix.
• Apply situation specific or Gang of Four patterns, update cycle 1 and cycle 2 design diagrams.
• Produce and inspect cycle 3 expanded use cases and use case based test cases.
12 DES3
• Produce and review cycle 3 sequence diagrams (situation-specific patterns are applied).
• Read applying situation-specific patterns chapter.
IMP3 • Test driven develop and inspect cycle 3, accomplish 100% branch coverage.
• Review unit test cases and code.
13 • Build, integrate, and test cycle 3, demonstrate finished product to the customer and users, solicit
TEST3 and record feedback.
• Produce and review user’s manual for the finished product.
• Conduct a postmortem and write the cycle 3 final report.
• Produce role and team evaluations for cycle 3.
14 PM3
• Review the product produced and the processes used, identify lessons learned and propose process
improvements.
• Completed product or product element and user documentation.
Exit Criteria • Completed and updated project notebook.
• Documented team evaluations and cycle reports.
“the software quality is as good as the software process.” Although the conven-
tional wisdom still has its merits, experiences indicate that the abilities of the
team members as well as teamwork are more important. After all, it is the team
members who carry out the software process. If the team members do not know
how to design, or they do not communicate with each other effectively, then the
result won’t be good. Conventional practices place significant weight on the use
of tools. For this reason, many companies invest heavily in development tools and
environments. Some tools are good and solve the intended problems. But these
can only be accomplished by the right people, who know how. A UML diagram
editor won’t help if the software engineer does not know how to perform OO
design. Although the editor produces nice-looking UML diagrams, these are not
necessarily good designs.
Unlike conventional practices, agile methods value individuals and team-
work. This is because software is a conceptual product and the development
activities are highly intellectual. If the team members have to work together to
jointly build the software product, then the abilities of the team members to in-
teract and contribute to the joint effort is essential to the success of the project.
Software processes and tools certainly matter, but individuals and interactions
are essential.
Chapter 2 Software Process and Methodology 33
decisions, it may not possess the knowledge and background to make decisions
for the customer. For example, a requirement to support more than one DBMS
may not specify which DBMSs are to be supported. Technically, the team may
know which DBMSs are the best and should be supported. But the customer may
consider other factors to be more important. These include the ability of its infor-
mation technology (IT) staff to maintain the types of DBMSs, costs to introduce
such systems, and compatibility with existing systems. If the development team
makes such decisions for the customer, then the resulting system may not meet
the customer’s business needs.
Customer collaboration is essential for the success of a project. It improves
communication and mutual understanding between the team and the customer.
Improvement in communication helps in identifying real requirements and reduc-
ing the likelihood of requirements misconception. Mutual understanding implies
risk sharing; and hence, it reduces the probability of project failure. For many
projects, the exact outcome of the system, a design decision, or an algorithm is
difficult or impossible to predict. In these cases, customer collaboration is ex-
tremely important. Mutual understanding means that the development team has
a good understanding of the customer’s business domain, operations, challenges,
and priorities. This enables the team to design and implement the system to meet
the customer’s business needs.
Mutual understanding also means that the customer understands the limita-
tion of technology, which provides the means to implement business solutions;
technology alone will not solve business problems. The customer needs to under-
stand the limitation of the development team, as the following experience of the
author illustrates. A customer had insisted that a medium-size software product
be produced in one month, regardless that the author had indicated this was not
possible. In addition to the lack of time, the lack of qualified developers was
another challenge. After six months, the team still could not deliver; the project
failed. In this story, the customer wanted the system in one month, but no team
could meet this demand because the system had to implement a completely new
set of innovative business ideas. Customer collaboration might save the project.
For example, the two parties could try to understand each other’s priorities and
limitations, and develop a realistic agile development plan to incrementally roll
out the innovative features.
4. Agility values responding to change over following a plan.
Conventional practices emphasize “change control” because change is costly.
Once an artifact, such as a requirements specification, is finalized, then subse-
quent changes must go through a rigorous change control process. The process
hinders the team to respond to change requests. Agile methods value responding
to change over following a plan because change is the way of life. In today’s
rapidly changing world, every business has to respond quickly to change in busi-
ness conditions in order to survive or grow. Thus, change to software is inevitable.
Advances in Internet technologies enable as well as require businesses to update
their web applications quickly and frequently. The inflexibility of the conven-
tional, plan-driven practice cannot satisfy the needs of such applications. Agile
methods thus emerge.
Chapter 2 Software Process and Methodology 35
Agile Principles
The agile values express the emphases of agile processes. To guide agile development,
the agile community also develops a set of guiding principles called agile development
principles or agile principles for short. These principles are as follows:
change and trade off requirements because story cards and storyboards are easy
to share and manipulate.
5. Develop small, incremental releases and iterate.
Agile projects develop and deploy the system in bite-size increments to deliver
the use cases, user stories, or features iteratively. This arrangement has several
advantages: project progress is visible, the users only need to learn a few new fea-
tures at a time, it is easier for the users to provide feedback, and small increments
reduce risks of project failure.
6. Focus on frequent delivery of software products.
Before agile development, there are iterative approaches such as the spiral process
and the unified process. Agile processes differ from their predecessors in frequent
delivery of the software system in small increments. Different agile methods
suggest different iteration lengths, which range from daily to three months. For
example, Dynamic Systems Development Method (DSDM) suggests two to six
weeks while Extreme Programming (XP) uses one to four weeks. An iteration in
Scrum is called a sprint and is usually set to 30 days. The iteration duration of the
methodology presented in this book can range from two weeks to three months.
7. Complete each feature before moving on to the next.
This principle means that each feature must be 100% implemented and thor-
oughly tested before moving onto the next. The challenge here is that how do
we know that the feature is thoroughly tested? Test-driven development (TDD)
and test coverage criteria provide a solution. TDD requires that tests for each
feature must be written before implementation. Test coverage criteria define the
coverage requirements that the tests must satisfy. For example, the 100% branch
coverage criterion is used by many companies. It requires that each branch of
each conditional statement of the source code must be tested at least once.
8. Apply the 80-20 rule.
This is also referred to as the “good enough is enough” rule. The rule is based
on the belief that 80% of the work or result is produced by 20% of the system
functionality. Therefore, priority should be given to the 20% of the requirements
that will produce the 80% of work or result. This principle advises the devel-
opment team to direct the customer and users to identify and prioritize such
requirements. The rule also reminds team members of the diminishing return
associated with the final extra miles. This applies to features that are nice to
have, and performance optimization that is not really needed, and so forth. For
example, an optimal algorithm may not be worth the extra implementation effort
if a simpler algorithm is fast enough for the data to be processed.
9. Testing is integrated throughout the project life cycle; test early and often.
This principle and principles 5–7 complement each other. That is, testing is an
integral part of frequent delivery of completely implemented small increments
of the system. This principle is supported by test tools such as JUnit, a Java class
unit testing and regression testing tool. Using such a tool, a programmer needs
to specify how to invoke the feature to be tested and how to evaluate the test
result. The tool will generate the tests, run the tests, and check the test result, all
automatically. The tests can be run as often as desired.
Chapter 2 Software Process and Methodology 37
Definition 2.2 A software methodology defines the steps or how to carry out the
activities of a software process.
A process in general specifies only the activities and how they relate to each other.
It does not specify how to carry out the activities. It leaves the freedom to the software
development organization to choose a methodology, or develop one that is suitable
for the organization. The definition means that a methodology is an implementation
of a process. Software development needs a process and a methodology.
Process Methodology
• Defines a framework of phased activities • Amounts to a concrete implementation of a process
• Specifies phases of WHAT • Describes steps of HOW
• Usually does not dictate representations of artifacts • Defines representations of artifacts
• Hence, it is paradigm-independent • Hence, it is paradigm-dependent
• A phase can be realized by different methodologies • Each step describes specific procedures, techniques,
and guidelines
Examples: Examples:
• Waterfall process • Structured analysis/structured design methodology
• Spiral process (SA/SD)
• Prototyping process • Object Modeling Technique (OMT)
• Unified Process • Agile methods such as Scrum, Dynamic Systems
• Personal software process Development Method (DSDM), Feature Driven
• Team software process Development (FDD), Extreme Programming (XP),
• Agile processes and Crystal Orange
diagrams are created to model objects. In this sense, methodologies are paradigm
dependent. A software methodology can be viewed as a concrete implementation of
a software process. This implies that a software process may have more than one
software methodology as its implementation.
5. A good methodology forms the basis for process automation because many of
the methodological steps can be mechanically carried out, making software au-
tomation much easier.
6. A methodology that is easy to learn and use enables beginners to produce quality
software. As the beginner becomes familiar with the methodology, he can skip
some of the steps in agile development.
1. Feasibility study. During this phase, the applicability of DSDM and the technical
feasibility of the project are determined. The end products include a feasibility
report, an outline project plan, and optionally a prototype that is built to assess
the feasibility of the project. The prototype may evolve into the final system.
2. Business study. During this phase, the requirements are identified and prioritized,
a preliminary system architecture is sketched. The end products include a business
area definition, a system architecture definition, and an outline prototyping plan.
3. Functional model iteration. During this phase, a functional prototype is iter-
atively and incrementally constructed. The end products include a functional
model containing the prototyping code and the analysis models, a list of priori-
tized functions, functional prototype review documents, a list of nonfunctional
requirements, and risk analysis for further development. The prototype review
documents specify the user’s feedback to be addressed in subsequent increments.
The functional prototype will evolve into the final system.
4. Design and build iteration. During this phase, the system is designed and built
to fulfill the functional and nonfunctional requirements, and tested by the users.
Feedback from the users is documented and addressed in future development.
AUM* DSDM SCRUM FDD XP
Key Features
FIGURE 2.12 Summary of some agile methods
• A cookbook for teamwork • A framework that works • Include Srum Master, Product • Feature-driven and • Anyone can change any
using UML with Rational Unified Owner, and Team Roles model-driven code anywhere at any time
• For beginners and seasoned Process and XP • 15-minute daily status meeting • Configuration management, • Integration and build
developers • Base on 80–20 principle to improve communication review and inspection, and many times a day whenever
• Suitable for agile or plan- • Suitable for agile or plan- • Team retrospect to improve regular builds a task is completed
driven, large or small team driven projects process • Suitable for agile or plan- • Work ≤ 40 hours a week
projects driven projects
Life-Cycle Activities
Preplanning Feasibility Study Release Planning Meeting Develop Overall Model Exploration
1. Acquire and prioritize 1. Assess suitability of DSDM 1. Identify and prioritize 1. System walkthrough 1. Collect information about
requirements for project requirements (product backlog) 2. Develop small group models the application
2. Derive use cases 2. Identify risks 2. Identify top-priority 3. Derive overall model 2. Conduct feasibility study
3. Assign use cases to requirements that can be 4. Produce model description
increments delivered within an increment
Business Study Planning
4. Architectural design called a sprint
1. Produce prioritized 3. Identify sprint development Build Feature List 1. Determine the stories for
During Each iteration: requirements activities 1. Identify business activities the next release
1. Accommodating change 2. Architectural design to be automated 2. Plan for the next release
2. Domain modeling 3. Risk resolution 2. Identify features of business
Sprint Iteration:
3. System-actor interaction activities
Functional Model Iteration 1. Sprint planning meeting to Iterations to First Release
modeling 1. Identify prototype determine what and how to 1. Define/modify architecture
4. Behavior modeling functionality build next 2. Select and implement
Plan by Feature
5. Design class diagram 2. Build, review, and approve 2. Daily Scrum meeting for team stories for each iteration
6. Test-driven development/pair 1. Schedule development of
prototype members to report status business activities 3. Perform functional tests
programming by customer
7. Integration testing Design and Build Iteration 2. Assign business activities to
8. Deployment chief programmers
1. Build system Sprint Review Meeting
2. Conduct beta test 3. Assign classes to team
1. Increment demo Productionizing
members
2. Team retrospection 1. Evaluate and improve
Implementation Design by Feature system performance
1. Deploy system Deployment 1. Produce sequence diagrams 2. Certify and test system for
2. Assess impact to business to show the interaction of production use
objects using features
2. Encapsulate features to
Maintenance
form classes to be
1. Improve the current release
implemented
2. Repeat process with each
Build by Feature new release
Implement the classes
Death
Deployment 1. Produce system
documentation if project
is done, or
2. Replace system if
41
Feasibility
study
Business study
Review prototype
Identify Create
design Design & design
prototype build iteration prototype
Agree schedule
5. Implementation. During this phase, the system is installed in the target environ-
ment and user training is conducted. The end products include a user’s manual
and a project review report, which summarizes the outcome of the project and
what to do in the future.
2.7.2 Scrum
Scrum is a framework that allows organizations to employ and improve their software
development practices. It consists of the Scrum teams, the roles within a team, the time
boxes, the artifacts, and the Scrum rules. Scrum is an iterative, incremental approach
that aims to optimize predictability and control risk. As displayed in Figure 2.14, there
Daily Scrum
Meeting
2–4 Weeks
Potentially
Shippable
Product
Product Backlog Sprint Backlog Increment
is a release planning meeting. It determines the product backlog and the priorities of
the requirements as well as planning for the iterations, called sprints. During the sprint
iteration phase, the team performs the development activities to develop and deploy
increments of the product. Each sprint begins with a sprint planning meeting, at which
the team and the product owner determine which items of the product backlog are to
be delivered next and how to develop them. Each sprint lasts 30 days, but a shorter
or longer time period is allowed. One distinctive feature of the Scrum method is its
15-minute daily Scrum meeting. It allows the team members to exchange progress
status to improve mutual understanding. Another distinctive feature of the Scrum
method is the team retrospection at the end of each Scrum sprint. This meeting allows
the team to improve its practices.
1. Develop overall model. During this phase, a domain expert provides a walk-
through of the overall system, which may include a decomposition into subsys-
tems and components. Additional walkthroughs of the subsystems or compo-
nents may be provided by experts in their domains. Based on the walkthroughs,
small groups of developers produce object models for the respective domains.
The development teams then work together to produce an overall model for the
system.
2. Build a feature list. During this phase, the team produces a feature list representing
the business functions to be delivered by the system. The features of the list may
be refined by lower-level features or functions. The list is reviewed with the users
and sponsors.
3. Plan by feature. During this phase, the team produces an overall plan to guide
the incremental development and deployment of the features, according to their
priorities and dependencies. The features are assigned to the chief programmers.
The chief programmer is the main decision maker of the team. This team orga-
nization is referred to as the chief programmer team organization. The classes
specified in the overall model are assigned to the developers, called class owners.
A project schedule including the milestones is generated.
4. Design by feature, build by feature, and deployment. These three phases are iter-
ative, during which the increments are designed, implemented, reviewed, tested,
and deployed. Multiple teams may work on different sets of features simultane-
ously. Each increment lasts a few days to a few weeks.
The roles and their responsibilities of an FDD project are similar to the com-
mon job titles. These include project manager, chief architect, development manager,
chief programmer, class owner, domain expert, release manager, toolsmith, system
administrator, tester, and technical writer.
44 Part I Introduction and System Engineering
1. Exploration. During this phase, the development team and the customer jointly
develop the user stories for the system to the extent that the customer is convinced
that there are sufficient materials to make a good release. A user story specifies
a feature that a specific user wants from the system. For example, “as a patron, I
want to check out documents from the library system.” The development team also
explores available technologies and conducts a feasibility study for the project.
This phase should take no more than two weeks.
2. Planning. During this phase, the development team and the customer work to-
gether to identify the stories for the next release, including the smallest, most
valuable set of stories for the customer. The stories should require about six
months of effort to implement. A plan is produced for the next release. This
phase should take no more than a couple of days.
3. Iterations to first release. During this phase, the overall system architecture is
defined. The customer chooses the stories, the team implements them, and the
customer tests the functionality. These activities are performed iteratively until
the software is good for production use. Each iteration lasts from one to four
weeks.
4. Productionizing. During this phase, issues such as performance and reliability
that are not acceptable for production use are addressed and removed. The system
is tested and certified for production use. The system is installed in the production
environment.
5. Maintenance. According to Beck [21], this phase is really the normal state of
an XP project. During this phase, the system undergoes continual change and
enhancements, such as major refactoring, adoption of new technology, and func-
tional enhancements with new stories from the customer. The process is repeated
for each new release of the system.
6. Death. The system evolves during the maintenance phase until the system com-
pletely satisfies the customer’s business needs and hence no more customer stories
are added. When this happens, the project is done and enters the death phase, dur-
ing which the team produces the system documentation for training, repair, and
reference. The project also enters the death state if it cannot live to the customer’s
expectation.
dominates the other.” Agile methods work well for small to medium-size projects that
face frequent changes in requirements. Plan-driven approaches remain the de facto
choice for large, complex systems and equipment manufacturers where predictability
is important. Therefore, both approaches are needed. According to Boehm and Turner
[35], plan-driven and agile methods “have shortcomings that, if left unaddressed, can
lead to project failure. The challenge is to balance the two approaches to take advantage
of their strengths and compensate for their weaknesses.” That is, we need methods
that can adapt to the cultures and circumstances of different software development
projects and organizations. Such methods include Crystal Orange [50], DSDM [140],
FDD [119], Lean Development [124], lightweight unified process (LUP) [104], and
the methodology presented in this book.
Iteration
workflow activities
Design Design
Implementation Implementation
Testing Testing
Deployment Deployment
Planning
phase Iterations
Use case-iteration
Business goals Customer allocation matrix
& needs feedback Accommodating
Current situation
Requirements Change
Acquiring
Requirements Iteration use cases
Domain Modeling
Requirements
Domain model Domain model
Deriving Use Cases
Actor-System Interaction
from Requirements Modeling &
Abstract & high-level use User Interface Design
cases, use case diagrams Expanded use cases
& UI design
Allocating Use Cases
& Subsystems Behavior Modeling &
Responsibility Assignment
to Iterations
Behavior models
Use case-iteration
allocation matrix Deriving Design Class
Producing an Diagram
Architecture Design Design class diagram
Software
architecture Test-Driven Development,
Integration, & Deployment
(a) Planning Phase (b) Iterative Phase – activities during each iteration
and assign them to the iterations. Changes to the requirements, if any, are addressed
during the requirements phase of each of the following iterations. Requirements
change may lead to changes to the list of use cases and the delivery schedule of the
use cases.
Figure 2.16 shows the steps of the agile unified methodology (AUM), along with
their input, output, and relationships. The methodology consists of two main phases:
(a) the planning phase, and (b) the iterative phase. During the planning phase, the
development team meets with the customer representatives and users to identify the
requirements and derive use cases from the requirements. The development team
also produces an architectural design and a plan to develop and deploy the use cases
during the iterative phase. Use case diagrams are produced during the planning phase
to show the use cases, and subsystems and components that contain the use cases.
Consider, for example, a library information system (LIS). The system may have a
few dozen requirements. In illustration, three of them, labeled R1, R2, and R3, are
R1. The LIS must allow patrons to checkout documents.
R2. The LIS must allow patrons to return documents.
R3. The LIS must allow patrons to search for documents using a variety of search
criteria.
Chapter 2 Software Process and Methodology 47
use case
Checkout Document
Patron subsystem
boundary
Return Document
Actor-use case
association
From these requirements, three use cases are derived—Checkout Document, Re-
turn Document and Search for Document, respectively. The LIS has many other
requirements and use cases besides these. A mechanism to partition a large set of
use cases is needed. Use case diagrams are useful for organizing the use cases into
subsystems so that each subsystem can be dealt with separately. A use case diagram
displays the use cases of a system or subsystem, and relationships between the use
cases and system users called actors. As Figure 2.17 exhibits, the “circulation sub-
system” of the LIS has three use cases. Similarly, other use case diagrams could
display the use cases of the “cataloging subsystem” and “purchasing subsystem,”
respectively. These subsystems may be assigned to different development teams to
design and implement.
During the iterative phase, the use cases are developed and deployed to the target
environment iteratively according to the schedule produced in the planning phase. In
particular, each iteration performs the following steps for the use cases assigned to
the iteration.
User
A domain concept
ID: String
represented by a
password: String Loan class
phone: String
address: String date: Date
Inheritance Document
due: Date
relationship Domain concepts
indicating that a callNum: String
describing properties
Patron is a User title: String of a domain concept
Patron Document author: String
Patron publisher: String
Checkout * pubDate: Date
limit: Integer
Association relationship
showing that Patrons
Librarian checkout documents Book Periodical
role: String copies: Integer duration: Integer
through communication with the customer representatives, users, and domain ex-
perts. The domain concepts are classified into classes, attributes of the classes and
relationships among the classes. The result is called a domain model, visualized by
using a UML class diagram. A sample domain model for a library system is shown
in Figure 2.18.
Object
<<call number>> d := getDocument
Patron d := getDocument
(callNo: String):
(callNo: String): Object lifeline
<<document detail>> Document Execution of
Document
incoming
message
<<OK>> msg := checkout
create(p:Patron, d:Document)
(callNo: String):
<<msg>> String save(l:Loan)
setAvailable(false:boolean)
<<OK>>
save(d:Document)
message
use case. The left column of the tabular specification shows the user input and user
actions while the right column displays the corresponding system responses.
DBMgr CheckoutController
getDocument(callNo: String):Document getDocument(callNo: String):Document
save(l:Loan) checkout(callNo: tring): String
save(d:Document)
User CheckoutGUI
ID: String Loan
password: String
date: Date
phone: String
due: Date
address: String
create(p:Patron, d:Document)
Document
setAvailable(b:boolean)
The software team wants an integrated view of the design. This integrated view is
created by using a UML class diagram, called a design class diagram. In illustration,
Figure 2.21 depicts a design class diagram that is derived from the sequence diagram
in Figure 2.20. The dashed arrow lines in the design class diagram represent uses or
dependence relationships between the classes.
SUMMARY
•
Software development faces project as well as prod- While a software process specifies the phased ac-
uct challenges. To take on these challenges, a software tivities, a methodology describes the steps or how to
process is needed. However, the conventional water- carry out each of the activities of a process. The dif-
fall process is associated with a number of problems. ferences between a process and a methodology are
The reason is that it is a process for solving tame prob- discussed in this chapter. A software methodology
lems but application software development in general is influenced by the software paradigm adopted to
is a wicked problem. The quest for a better process develop the software system. This is because a
leads to the creation of a number of software process paradigm determines how the development team
models with agile processes as the latest member of views the real world and systems. This, in turn, de-
the club. termines the basic building blocks of the software
Chapter 2 Software Process and Methodology 51
system and the development methodology. For exam- agile principles, agile processes, and agile methods
ple, the OO paradigm views the world and systems are all designed to tackle software development as a
as consisting of interrelated and interacting objects. wicked problem. Although agility is rapidly increas-
This implies that the building blocks of an OO sys- ing its popularity in the software industry, conven-
tem are objects. Thus, an OO software development tional plan-driven development approaches will stay
methodology must describe how to perform OO mod- for a long period of time because these approaches
eling, analysis, design, implementation, and testing also have their home grounds in the software indus-
activities. try. Thus, the so-called adaptive approaches, which
The advent of agile processes and methods re- could be tailored to fit agile, or plan-driven develop-
flects a significant advance in recognizing the wicked- ment, are attractive.
ness of software development. The agile manifesto,
FURTHER READING
•
The spiral model, the personal software process, team soft- Orange [50], Lean Development [124], Adaptive Software
ware process, and the Unified Process are described in Development [80], and agile modeling [11]. Abrahamsson
[32, 86, 87, 91], respectively. The classical OO method- et al. [2] provide an excellent briefing and comparison of
ology OMT is described in [131], which defines many of the various agile methods. In [15], Avison and Fitzgerald
the UML notations. The methodology is revised by Blaha review the history of software development methodologies
and Rumbaught to use UML 2.0 [30]. An excellent presen- and suggest a number of future directions. The proceedings
tation of OO analysis and design using UML and patterns of the annual Agile Development Conference publish pa-
is found in [104]. pers on various aspects of agile development. Other papers
The agile methods presented in this chapter are detailed of interest include [35, 69, 88, 126, 144, 145].
in [21, 52, 119, 140]. Other agile methods include Crystal
EXERCISES
•
2.1 What are the similarities and differences between the 2.2 Write an essay about how a good process and a good
conventional waterfall model and the Unified Pro- methodology help tackling the project and product
cess model? Identify and explain three advantages challenges. Limit the length of the essay to five pages,
and three disadvantages of each of these two models. or according to the instructions of the instructor.
52 Part I Introduction and System Engineering
2.3 Write a brief essay on the differences between a soft- the spiral process, the Unified Process, and an agile
ware process and a software methodology. process.
2.4 Write an essay that discusses the following two b. What are the pros and cons of each of these
issues: processes.
a. The pros and cons of plan-driven development and c. Which types of projects should apply which of
agile development processes, respectively. these processes?
b. Whether and why agile development will, or will 2.6 Explain in an essay why the waterfall process is a
not, replace plan-driven approaches. process for solving tame problems.
2.5 Write a short article that answers the following 2.7 Explain in an essay how agile development tack-
questions: les application software development as a wicked
a. What are the similarities and differences between problem.
3
System Engineering
53
54 Part I Introduction and System Engineering
System Deployment
• install system in target environment
• test system by users
Legend:
phase/activity
System Maintenance
• fix field detect defects interaction
• perform system enhancements
workflow
hardware, software, and human resource development activities. The type of system
influences the activities involved. For example, if the system is a software-only sys-
tem, then the hardware development activities are not performed. The phases of the
system engineering process are outlined below and detailed in the following sections:
and other factors. The information collection activity answers the following questions:
1. What is the business that the system will automate?
2. What is the system’s environment or context?
3. What are the business goals or product goals?
4. What is the current business situation, and how does it operate?
5. What are the existing business processes, and how do they relate to each other?
6. What are the problems with the current system?
7. Who are the users of the current system and the future system, respectively?
8. What do the customer and users want from the future system, and what are their
business priorities?
9. What are the quality, performance, and security considerations?
The information collection activity uses several information collection
techniques:
1. Customer presentation. Customer presentation is an effective approach to gather-
ing information. It takes place at the very beginning of the project. A management
or senior personnel designated by the customer presents an overview of the cur-
rent business, known problems, what the customer and users expect the system
to accomplish, and what their business priorities are. The list of questions pre-
sented above may serve as the focus of the presentation. The presentation should
be limited to no more than two hours including questions and answers.
2. Study of current business operations. The team may pay a visit to the business
environment. The team may request a guided tour of the customer’s business
operations where they may collect paperwork forms, descriptions of operating
procedures, policies, and other relevant materials. The team should study these
materials carefully. These activities help the team understand the customer’s
business entities, business processes, and workflows. The workflows may include
information flows and material flows.
3. User survey. User surveys are useful for acquiring users’ opinions about the
current system and their expectations of the new system. The survey questionnaire
should be brief and focus on important issues. Use different survey questionnaires
for different groups of users. Issues that require clarification are identified and
addressed during user interviews.
4. User interview. User interviews are useful for acquiring information that is dif-
ficult to obtain through user surveys. They are also useful for clarifying issues
that are not clear in the user surveys. The interviews are conducted with selected
users, either jointly or individually. Each interview session should last about one
hour. A list of items to be discussed during the interviews should be prepared
beforehand. The list may be shared with the users prior to the interviews.
5. Literature survey. Literature survey provides additional information to help the
development team understand the application domain. Literature survey should
focus on similar projects, domain knowledge, business processes, government
regulations, and industry standards.
60 Part I Introduction and System Engineering
R1. ABHS shall check in and transport luggage to departure gates and baggage
claim areas according to the destinations of the passengers.
R2. ABHS shall allow airline agents to inquire about luggage status and to locate
luggage.
R3. ABHS shall check all baggage and detect items that are prohibited.
R4. ABHS shall be able to serve 20,000 passengers per day.
reduces the complexity and costs of system development because the subsystems
are easier to design and implement.
2. Allocate system requirements to subsystems. This activity assigns the system re-
quirements to the subsystems. It aims to reduce the number of requirements
that are shared among the subsystems. In this way, the responsibilities of the
subsystems are clearly defined. In addition, the requirements allocated to a sub-
system should be functionally related. The allocation is shown in a requirement–
subsystem traceability matrix.
3. Visualize the system architecture. This activity shows the architectural design
as a diagram that consists of the subsystems and the relationships between the
subsystems.
1. The result should enable separate engineering teams to develop the subsystems.
This reduces the system development costs because it reduces the number of
engineers who are specialized in multiple engineering disciplines. It also sim-
plifies the communication between the teams and reduces the communication
overhead.
2. The result should facilitate the use of commercial off-the-shelf (COTS) parts.
COTS are third-party products that can be purchased or acquired. The use of
COTS increases productivity and quality while it reduces cost and time to mar-
ket. For example, the design of the ABHS should consider using COTS for the
conveyor systems, high-speed tracks, bar code readers, and luggage check-in
software rather than developing these from scratch.
3. The result should partition or nearly partition the system requirements. That
is, few subsystems share requirements with other subsystems. This reduces the
possibility that some requirements are not fulfilled adequately due to a misun-
derstanding between the teams that share the requirements.
4. Each subsystem should have a well-defined functionality. This makes the sub-
systems easy to understand. For example, the luggage check-in subsystem deals
with luggage check-in. The conveyor subsystem is responsible for moving the
luggage within a terminal.
5. The subsystems should be relatively independent. That is, changing a subsystem
does not affect the other subsystems. Such a modular design facilitates system
maintenance. For example, the luggage check-in subsystem and the conveyor sub-
system are two independent subsystems. Either of them can be replaced without
affecting the other.
62 Part I Introduction and System Engineering
System System
(a) Partition according to major functionality (b) Partition according to hardware, software,
and human subsystems
6. The subsystems should be easy to integrate. That is, the subsystems should have
simple interfaces and interaction behavior. This simplifies the communication
between the subsystems. It facilitates subsystem integration, integration testing,
and system maintenance.
System decomposition applies a number of strategies, which may affect each
other. Therefore, they should be applied iteratively until a satisfactory result is ob-
tained. The strategies are:
1. Decompose the system according to system functions.
2. Decompose the system according to disciplines.
3. Decompose the system according to existing architecture.
4. Decompose the system according to the functional units of the organization.
5. Decompose the system according to models of the application.
Decomposing the system according to system functions is a frequently used
strategy. It identifies the functions of the systems from the system requirements.
That is, it partitions the system requirements into nearly disjoint functional clusters.
It then identifies the functional subsystems according to the functional clusters. If
there are three functional clusters, then the system is decomposed into three func-
tional subsystems. Figure 3.2(a) shows that the system is decomposed into Subsys-1,
Subsys-2, and Subsys-3. The subsystems are then decomposed into domain-specific
subsystems, that is, hardware, software, and human resource subsystems. This ap-
proach is used if there are development teams to develop the functional subsystems,
or the functional subsystems can be ordered from a third party. Sometimes engineers
need to decompose the system requirements into lower-level requirements to make
the subsystems relatively independent. To illustrate, suppose that the ABHS has the
following requirement:
R1. ABHS shall check in and transport luggage to departure gates and baggage
claim areas according to the destinations of the passengers.
Chapter 3 System Engineering 63
This requirement includes several functions such as luggage check-in and luggage
transportation. If the airport has more than one terminal, then the luggage transporta-
tion function involves conveyors and high-speed tracks. Therefore, the requirement
should be decomposed. Requirements decomposition should ensure that the low-
level requirements are equivalent to the high-level requirements. That is, the high-
level requirement and the resulting low-level requirements state the same capabilities.
Assume that each flight’s check-in area and departure gate are located in the same
terminal. So are the arrival gate and the baggage claim area. The requirement R1 can
be decomposed into the following:
R4.1. Each check-in area shall handle 1,150 check-in baggages per day.
R4.2. Each check-in agent shall check in an average three passengers per minute.
R4.3. Each conveyor hardware shall scan and transport 500 check-in pieces of
luggage per hour.
R4.4. ABHS control software shall process 2,300 check-in bags per day and
1,000 bar code scan requests per hour.
Next, the system requirements are partitioned into functional clusters. That is,
requirements that share the same functionality are grouped together to form a func-
tional cluster. The functional clusters are used to derive the functional subsystems.
Figure 3.3 shows the functional clusters and subsystems derived from the system
requirements.
64 Part I Introduction and System Engineering
Luggage check-in This functional cluster processes luggage check-in. R1.1, R4.1, R4.2 Luggage check-in
subsystem
This functional cluster is responsible for moving R1.2.1, R1.2.2, Conveyor subsystem
Conveyor luggage within a terminal. R1.2.3, and R1.2.4,
R4.3
High-speed track This functional cluster transports luggage between R1.2.3 and R1.2.5 High-speed track
terminals. subsystem
This functional cluster controls the hardware to R1.3, R4.4 Software control
Software control
transport luggage within and between the terminals. subsystem
depends on the results of the previous steps. If the subsystems are derived from the
functional clusters, then the mapping from the functional clusters to the subsystems
is the allocation. This is the case for the ABHS example, as Figure 3.3 shows.
The allocation of the system requirements to the subsystems is visualized in a
traceability matrix as shown in Figure 3.4. The rows show the requirements while the
columns show the subsystems. The entries indicate the allocation of the requirements
to the subsystems. For a real-world project, the traceability matrix is large because
it involves hundreds of requirements and many subsystems. Therefore, Figure 3.4 is
only an illustration. The matrix has a number of advantages:
1. It can check that every requirement is assigned to a subsystem. That is, each leaf-
level requirement row shows at least one cross (‘x’). If a leaf-level row does not
contain a cross, then the system requirement is not assigned to any subsystem.
2. It can check if the allocation is appropriate. Assigning a system requirement
to several subsystems should be avoided because it is difficult to divide the
functionality among the subsystems. The traceability matrix can detect such cases
by counting the number of crosses on each row. If a row contains many crosses,
then the requirement is assigned to many subsystems. In this case, decomposing
the requirement is desired.
3. It shows which requirements are assigned to a subsystem. That is, the crosses
shown in each column indicate the requirements that are assigned to the subsys-
tem represented by the column. The subsystems must satisfy the requirements,
respectively.
4. It can check if a subsystem is assigned too many responsibilities. If a column
contains many crosses, then the subsystem is assigned many responsibilities.
The subsystem may be decomposed to distribute the requirements among the
lower-level subsystems.
5. It can check the functional cohesion of the subsystems. The requirements that are
assigned to a subsystem should be related functionally. If the requirements indi-
cated by the crosses on a column are not related, then the subsystem represented
by the column has low functional cohesion. The requirements should be par-
titioned into several functional clusters. The subsystem should be decomposed
into functional subsystems corresponding to the functional clusters.
66 Part I Introduction and System Engineering
Terminal High-Speed
Passenger Luggages
Luggages, Subsystem Tracks
ticket, ID Luggages Subsystem
Data
ABHS
Control Instructions
Software
Instructions Data
Luggage &
flight data Flight
Information
System
Terminal Subsystem
<<subsystem>> <<subsystem>>
Mobile Units Base Station
Call
Air <<subsystem>> Instructions
Events data <<subsystem>>
<<subsystem>> link Base Station
Mobile Antenna Account
<<subsystem>>
Hardware Controller Management
Software
Legend: component port <<subsystem>> stereotype for introducing new modeling constructs
communicate in the service area. The figure shows that each mobile unit consists of
a mobile hardware subsystem and a mobile software subsystem. The hardware sends
events to the software, which issues instructions to operate the hardware. For example,
when the user makes a call, the event is sent to the software. The software instructs
the hardware to contact the base station through a radio frequency channel, called an
airlink. The high-power transceivers of the base station receive the request and forward
it to controller hardware, which forwards it to the controller software. The controller
software validates the call request. If the caller and callee are valid subscribers, then
it instructs the hardware and the transceivers to establish a connection.
The ability of UML to support system modeling leads to an extension of UML,
that is, the System Modeling Language (SysML). The nine diagrams of SysML and
how they relate to UML are summarized in Figure 3.8. The last column of the table
shows the chapters of this book that cover the UML diagrams. To illustrate, Figures 3.9
68 Part I Introduction and System Engineering
Presented
SysML UML Description Remark
in Chapter
Model activities that relate to each other via SysML activity diagram extends 14
Activity Activity workflows, and exhibit sequencing, exclusion, UML activity diagram.
diagram diagram synchronization, and concurrency relationships
Block Model structural elements called blocks and their Block definition diagram
definition composition and classification extends UML class diagram.
diagram
Internal Model interconnection and interfacing of internal Internal block diagram extends
block elements of a block UML composite structure
diagram diagram.
Package Package Model the logical organization of modeling Same diagrams
diagram diagram artifacts and software artifacts
Parametric Specifies constraints to support engineering
diagram analysis
Model text-based requirements and their
Requirement
relationships with other requirements and artifacts
diagram
such as design elements, test cases, etc.
Sequence Sequence Model time-ordered interaction behavior between Same diagrams 9
diagram diagram objects
State State Model state dependent behavior of an object Same diagrams 13
diagram diagram
Show the functions or business processes of an Same diagrams 7
Use case Use case
application or system as well as relationships of
diagram diagram
these to external entities called actors
and 3.10 show an SysML block definition diagram (bdd) and an SysML internal
block diagram (ibd) for the ABHS. These diagrams correspond to the block diagrams
displayed in Figures 3.5 and 3.6, respectively.
Sometimes, it is desirable to show material flows in addition to information
flows in a model. For example, the ABHS moves luggage from the check-in areas
to the departure gates and the arrival gates to baggage claim areas. Such flows are
Chapter 3 System Engineering 69
Legend:
input or input and association relation,
subsystem or
component output port output port or port-to-port flow
FIGURE 3.10 SysML internal block diagram for ABHS terminal subsystem
1 Valid 2 3
Shipment shipment New titles
slip Verify slip Classify available Handle
Publisher Shipment Publications Documents
Content Received Check-In/Out
Legend:
ID information flow
External Internal
Function Entity Entity
Subsystem material flow
called material flows. In Figures 3.5 and 3.6, material flows and information flows
are represented using the same notation. The SysML diagrams shown in Figure 3.9
and 3.10 also use the same notation for information and material flows. To distinguish,
material flows should be modeled differently. To illustrate, Figure 3.11 shows a data
flow diagram for a library system. The block arrows represent material flows. The
ovals represent tasks or processing functions. The entity or subsystem that performs
that function is shown in the lower compartment of the oval. The upper compartment of
the oval shows the task ID. Material flows are useful in assigning system requirements
to the hardware, software, and human subsystems. For example, the material flows in
70 Part I Introduction and System Engineering
Figure 3.11 suggest that functions involving material flows such as the receiving dock,
cataloging room, and book shelves should be assigned to the appropriate hardware
and human subsystems.
Input pins
1 Microcontroller IC 11 Relay
0 or 1.5 v Coil
2 If room is hot, 12
on/off
set pin 12 to 1
3 Relay Relay 13 switch
Room 0v
4 Off On 14 Power
temperature If room is cool,
sensor Ground switch
5 set pin 12 to 0 15
Power Compressor
6 Power 16
is off
is on
7 17
AC/DC ~
Software control
8 Power 18 adapter 110 – 220 v AC
state diagram
9 Off 19
Power switch
on/off input
In the case shown in Figure 3.12, the interface and interaction behavior specifi-
cation defines the pins that represent the room temperature, the meaning of the byte
read by the software. The specification also defines the output pins and the meaning
of the output values. In this case, the output pin is pin 12. When the pin is set, the
relay is engaged and the cooling begins. Besides software-hardware interface, there are
human-software, software-software, human-hardware, human-human, and hardware-
hardware interfaces. These interfaces and interaction behavior are specified similarly.
System design also produces a system integration test plan and an acceptance
test plan. These specify test procedures to ensure that the subsystems will work with
each other as expected, and the system delivers the capabilities as specified in the
system requirements specification. Required resources to conduct system integration
testing and acceptance testing are also specified. These test plans are used during the
system integration and testing, and acceptance testing phases.
Legend:
1..* 1 or more instances of this
A B A B class are related to instances
Transitive of the related class.
word
Object B is a part
A and B are related.
class of A.
information contained in the context diagram is useful for the design of the software
subsystem.
1. It provides a unified view of the software objects and the context objects. This
helps the team understand the context objects and their relationships to the soft-
ware subsystem.
2. It highlights the interfaces and interaction with the context objects. The context
domain model treats the software as a black box, and shows only the context
objects, their relationships, and attributes that are useful to the design of the
software subsystem.
3. It helps the development of the software subsystem. For example, the attributes
of the bar code scanners are useful for the design and implementation of the
classes that interface with the bar code scanners. The multiplicity, such as “1..*”
in Figure 3.13, specifies the number of scanners the ABHS control software must
Chapter 3 System Engineering 73
support. The information shown in the context diagram is also useful for testing
and maintenance. For example, when adding a new type of bar code scanner
only the classes that interface with the new scanner need to be designed and
implemented.
4. It facilitates the communication and collaboration with other engineering teams.
The object-oriented context diagram highlights the interfaces and interaction with
other engineering subsystems. This helps the software engineering team to focus
on the interface and interaction issues when working with the other engineering
teams.
5. It is useful for training. A software subsystem of a large complex system needs to
interact with many other complex systems. It is not easy to understand the context.
The context diagram is a useful tool for new members to learn the context of a
software subsystem.
1. Configuration item identification. This function defines the project baselines and
associated configuration items. Some examples of baselines are the system re-
quirements baseline, system design baseline, allocation baseline, and subsystem
design baselines. Example configuration items include system requirements spec-
ification, project plan, system acceptance test plan, system design specification,
allocation plan, system integration test plan, and more. A configuration item can
be changed freely before the baseline is established. A baseline can be established
when all the associated configuration items are checked into the configuration
management system. For example, if the system requirements baseline consists
Chapter 3 System Engineering 75
System Configuration
Identified Change Control
changes
Identify Evaluate
Prepare ECP
Needed ECP by
Events that Changes ECP
CCB
mandate
changes ECP
Feedback [revision required] [approved] Incorporate
Changes
of the system requirements specification and the project plan, then the baseline
can be established when both of these documents are checked into the config-
uration management system. Once the baseline is established, changes to the
configuration item need to go through a change control procedure.
2. Configuration change control. This function defines the change control procedure
and executes the procedure. Figure 3.14 illustrates the change control procedure.
First, the needed change is identified and analyzed. Next, an engineering change
proposal (ECP) is prepared. It specifies the change, its impact, duration, and
cost. The ECP is evaluated by a change control board (CCB). The CCB consists
of representatives of parties that may be affected by the proposed change. The
evaluation either accepts or rejects the ECP. As a result, the proposed change is
either implemented or archived.
3. Configuration auditing. This function formally establishes the project baselines.
It also ensures that the proposed engineering changes are made properly. To
achieve these goals, configuration item verification and validation are performed.
Configuration item verification ensures that the required configuration items are
produced when a baseline is established. For example, it ensures that the system
requirements specification and the project plan are produced prior to establishing
the system requirements baseline. Configuration item validation ensures that the
configuration items are correct, for example, the system requirements specifica-
tion is reviewed by the engineering teams, domain experts, customer, and users,
identified defects are removed and concerns are addressed.
4. Configuration status reporting. This function provides database support to the
other three functions. The database can be queried for information about the
configuration items. The function also publishes events about the system con-
figuration. These include the establishment of a baseline and changes to the
configuration items.
76 Part I Introduction and System Engineering
SUMMARY
•
This chapter presents system development activities the system requirements and constraints. During the
that involve hardware, software, and human compo- entire system development process, numerous anal-
nents. It describes the system engineering process and ysis, design, implementation, and testing documents
techniques for system modeling, design, and system are produced and updated. Updating one document
requirements allocation. After allocation, the subsys- may affect many other documents. The updates must
tems are developed by separate teams of various en- be coordinated, which is done by system configura-
gineering disciplines. The subsystems are then inte- tion management.
grated and tested to ensure that the system satisfies
FURTHER READING
•
Excellent presentations of various aspects of system engi- ing principles to developing large, complex software sys-
neering are given by Blanchard [31] and Kossiakoff et al. tems. The paper integrates IEEE software engineering stan-
[99]. SysML is presented in [65] and UML in [36]. In dards and processes into the software system engineering
[152], Thayer presents how to apply system engineer- process.
EXERCISES
•
3.1 Provide a brief description of the functions of a vend- b. Identify and formulate five functional requirements
ing machine. Identify and formulate all functional and two nonfunctional requirements. One of the
and performance requirements. nonfunctional requirements must be a performance
3.2 Identify two embedded systems not mentioned in requirement.
this chapter. For each of these systems, perform the c. Decompose the system and allocate the system re-
following: quirements to the subsystems.
a. Briefly describe the functions of the system. The 3.3 A coin-operated car wash system is a self-service car
description should be about a half of a page to one wash system. A customer inserts the required number
page including diagrams, if any. of quarters to buy a preset period of wash time. The
Chapter 3 System Engineering 77
customer can turn a dial to select soap, foam, rinse, b. Describe how the subsystems relate to and inter-
and wax any time during the wash period. The system act with each other. That is, specify the subsystem
beeps when one minute is remaining. The customer interfaces and interaction behavior.
can insert more quarters to prolong the wash period. c. Construct a system architectural design diagram
Perform the following for the car wash system: to show the relationships between the subsystems.
a. Identify and specify the system require- d. Identify and formulate safety requirements and
ments including functional and nonfunctional allocate them to the subsystems. Describe how the
requirements. subsystems will satisfy the safety requirements.
b. Decompose the system into functional subsystems. 3.5 Managers of a department store want to expand into
Decompose the system requirements if necessary. online retailing. This means that the company needs
c. Allocate the system requirements to the sub- to develop an online system that can take orders on-
systems. line, and ship the ordered items through a designated
d. Construct a system architectural design diagram national shipment carrier. To reduce labor costs, the
using a diagramming technique of your choice or company wants a fully automated system. Perform
as designated by the instructor. the following for this system:
3.4 A railroad crossing system employs sensors, flashing a. Identify and formulate five functional require-
lights, sounding bells, and gates to control the traf- ments and two performance requirements for the
fic at a railroad intersection. When a train approaches system.
the intersection from either direction, a sensor device b. Decompose the system into a hierarchy of subsys-
senses the train and communicates with the software. tems and allocate the system requirements to the
The software turns on the flashing yellow warning subsystems.
light and the sounding bell for a given period. It then c. Produce a system architectural design diagram.
changes the light to flashing red and closes the gates. 3.6 If you have learned UML class diagramming, then
After the train has left the intersection, another sen- produce an object-oriented context diagram for the
sor device detects this and communicates the event software subsystem of the online retailing system
to the software. The software turns off the lights and you produced in exercise 3.5. Discuss the useful-
the sounding bell and opens the gates. Perform the ness of the context diagram for the design, imple-
following for the railroad crossing system: mentation, testing, and maintenance of the software
a. Identify the hardware and software subsystems subsystem.
and specify the functionality of each of the
subsystems.
This page intentionally left blank
part II
Analysis and Architectural Design
Chapter 4 Software Requirements Elicitation 80
Chapter 5 Domain Modeling 105
Chapter 6 Architectural Design 139
79
4
Software Requirements
Elicitation
Key Takeaway Points
•
• Requirements are capabilities that the system must deliver.
• The hardest single part of building a software system is deciding precisely what
to build—i.e., the requirements. (Frederick P. Brooks, Jr.)
• Software requirements elicitation is aimed to identify the real requirements for
the system.
The planning phase of the agile unified methodology of this book accomplishes three
objectives: (1) eliciting software requirements for the future system, (2) deriving a
set of use cases from the requirements, and (3) defining an iterative development
and deployment plan to deliver the use cases. This chapter presents the steps to ac-
complish the first objective. Requirements elicitation is an important and difficult
task in software development. It is important because it defines the capabilities of
the system as well as the constraints on the solution space. These form the basis
for the subsequent development activities. If the requirements and constraints are
incorrect, incomplete, inconsistent, or inadequate, then the system that is eventually
constructed and deployed will not satisfy the customer’s needs. Therefore, an entire
chapter is devoted to requirements elicitation—an activity to identify the real require-
ments. Requirements elicitation is also called requirements analysis. In this book,
these terms are used interchangeably. Through the study of this chapter, you will
learn the following:
• The importance and challenges of requirements elicitation.
• Types of requirement.
• Requirements elicitation activities.
• Assigning priorities to requirements.
• Requirements review techniques.
• Applying agile principles during requirements elicitation.
80
Chapter 4 Software Requirements Elicitation 81
Definition 4.1 Software requirements are capabilities that the system must deliver.
wicked problem, which was discussed in Chapter 2. The difficulties include, but are
not limited to the following:
1. The development team does not know enough about the application and appli-
cation domain. For many real-world projects, in-depth knowledge about the ap-
plication and application domain is critical to the success of the project. This is
because in many cases the software system either automates its manual counter-
part or interacts with the application through the hardware devices. This requires
a good understanding of the application and application domain. However, much
of the application and application domain knowledge can only be obtained by
years of working experience. This is why agile methods emphasize customer
collaboration and active user involvement because these practices are effective
means to acquire the needed domain knowledge.
2. Customers and users do not know what software can do and how to express their
needs. For most users, software is both a mystery and a puzzle. They don’t
know what software is, how it works, what the system can do for them, how the
system will work with them, and how to communicate their needs. Traditionally,
software developers make such decisions for the customer and users without
adequate input from them. Sometime, the developer’s attitude is “you don’t know,
so we decide for you,” or “these are nice features that you ought to like.” One
story shows the users’ feeling toward such a software vendor. The author and
his students visited a health care facility to solicit feedback on the user interface
design. A senior nurse thought it was something new. She expressed her feeling
about the visit, “Always in the past, we were given the software to use, but
this time you are listening to us.” Indeed, during requirements elicitation, the
development team needs to work closely with the customer and users, encourage
and facilitate them to communicate what they want, what they like, and what they
don’t like.
3. Lack of a common background creates a communication barrier between the
team and customer and users. The lack of an understanding of each other’s
field creates a communication barrier between the team and the customer and
users. The same words, phrases, or expressions often have different meanings
in different domains. For example, the word “security” can mean protection and
safety of personnel and physical properties, or protection of information, com-
puting resources as well as services. In the financial domain, security refers
to investment products such as stocks, bonds, mutual funds, and exchange-
traded funds. This is only one of the numerous examples that a term can mean
different things in different domains, or different contexts of the same
domain.
4. Software requirements cannot be specified definitely; the specification and im-
plementation cannot be separated. These are properties of wicked problems.
Unfortunately, software development in general is a wicked problem (see
Chapter 2). Consider, for example, the requirement to provide a “user-friendly in-
terface” for a new system. It is practically impossible to specify the requirement
accurately and adequately. This is because “user-friendliness” is a qualitative
Chapter 4 Software Requirements Elicitation 85
attribute and there is no objective judgment. User interface prototypes are often
used to help specify the requirement. But doing so is implementation, not just
specification.
5. The importance and difficulty of requirements elicitation are often underesti-
mated by management, customers, and users, as well as developers. As a con-
sequence, inadequate time and resources are allocated to requirements
elicitation.
6. Nonfunctional requirements are not identified or understated. Nonfunctional re-
quirements often refer to capabilities that concern the quality, performance, secu-
rity, and reliability aspects of the system, among others. Besides these, there are
nontechnical requirements that are often ignored, such as requirements to comply
to regulations and industry standards. In many cases, nonfunctional requirements
are not identified or understated. The problem is usually not discovered until the
later stage of the project. This could cause a significant increase in the develop-
ment time and costs.
7. Requirements change throughout the entire software life cycle, even after the
software is operational in the target environment. This challenge is a corollary
of the above challenges. The requirements change from day one and continue
throughout the entire life cycle. Change is not limited to functional and per-
formance requirements. User interface change is quite common and volatile,
especially at the beginning of a new development project.
Requirements
& constraints
Software
requirements
specification
(3) Deriving
requirements (4) Conducting
& constraints feasibility
study
More Deriving Use
modeling (5) Reviewing Cases from
requirements Software Requirements
Allocated system
Models specification requirements (Chapter 7)
requirements,
business goals, specification
(2) Constructing current situation,
models wish list, policies
& regulations,
standards, etc. Feedback
(1) Collecting
information
Requirements elicitation begins with the activity that collects information about
the application and application domain. Many pieces of information are useful for
understanding the application and deriving the requirements and constraints. These
include business goals, current business situation, policies, regulations, and standards.
The collected information is then analyzed to identify problems, from which needs
are derived. Sometimes, models are constructed to help understand the application
and the business processes. Due to budget and development time constraints, not all
needs are to be satisfied. Therefore, the team has to work with the customer and
users to identify high-priority needs and derive requirements to satisfy such needs.
Sometimes, feasibility study is required to eliminate or reduce risk items during
requirements elicitation. The requirements and constraints are then reviewed by peers,
domain experts, and the customer and users, respectively. The review results are used
to improve the requirements specification, from which use cases are derived.
1. What is the business for which the computerized system is being built?
2. What is the current business situation and how does it operate?
3. What is the system’s environment or context?
4. What are the existing business processes, their input and output, and how do they
relate and interact with each other?
5. What are the problems with the current system?
6. What are the business or product goals?
7. Who are the users of the current system and the future system, respectively?
8. What do the customer and users want from the future system, and what are their
business priorities?
9. What are the quality, performance, and security considerations?
Information-Collection Techniques
Information-collection methods and techniques are applied to find answers to the
questions presented previously. These techniques include
1. Customer presentation
2. Literature survey
3. Study of existing business procedures and forms
4. Stakeholder survey
5. User interviewing
6. Writing user stories
• Ensure that whoever gives the presentation knows the business and what the
customer and users want, although his knowledge may not be complete or 100%
correct. A manager or administrator who is responsible for the daily operation is
the best choice. A new hire may not be the right one to select for this job.
• Let the customer or its representative know what should be covered. In addition,
ask for pointers to gather additional information.
• If possible, one of the team members should review the presentation slides before
the presentation session to ensure that the needed information is included.
Chapter 4 Software Requirements Elicitation 89
• During the presentation, only ask questions that clarify doubts; avoid
implementation-related discussions. The purpose of the presentation session is
to learn the business and what the customer wants the system to provide.
• Request a copy of the presentation and share it with the team members.
• Avoid long presentation sessions that run more than two hours.
Valuable insight into the customer’s existing business- and system-specific infor-
mation can be obtained by studying similar projects, business documents and forms,
industry and company standards, relevant government policies and regulations, and
other related publications. In addition, the development team can obtain informa-
tion through training or attending tutorials conducted by domain experts. Information
about similar projects, if available, can provide very valuable insight into the system
under development. For example, the software requirements of the new system can
be derived from the capabilities of similar systems. The design and implementation
of the new system may also benefit from the design and implementation of similar
systems.
Many business documents, procedures, operating manuals, and forms are valu-
able sources. By studying these, the development team can obtain a better understand-
ing of the business processes, and the input and output of these processes. Clearly,
the future system must automate some or all of these business processes. Therefore,
the development team should ask the customer to provide all relevant documents and
forms and study them carefully. Each industry and company has its own standards.
Computerized systems must support such standards in one way or another. These
standards can be used to derive requirements or constraints. Government, industry,
and company–specific policies and regulations usually impose restrictions on the so-
lution space. These restrictions are often formulated as constraints in the software
requirements specification.
A survey questionnaire is a good tool to use to acquire requirements from stake-
holders, which include management personnel and end users. This technique has a
number of merits. First of all, wicked problem solving indicates that it is important to
involve stakeholders in the decision process. An anonymous survey encourages the
stakeholders to express concerns, insider information, and improvement suggestions.
These might be difficult to obtain through other information-collection methods. Such
information can be used to derive requirements for the future system. The following
guidelines should be observed when using a survey questionnaire:
• Conduct the interview after the development team has studied the survey ques-
tionnaires submitted by the customer and users. The questionnaires may already
contain the information that the development team wants to know. Therefore, con-
ducting the interviews after the survey can save time and effort. The responses
to the questionnaire can tell the development team on which areas or issues to
focus during the interview.
• The interview should be prepared and focused. That is, the development team
should develop a list of questions to ask during the interview. The list of questions
may be derived from the survey questionnaire. The questions should focus on
the critical or important issues to be solved by the computerized system.
• Each interview session should not last more than one hour.
• Respect the opinions of the customer and users; they are the experts of their
business. Avoid providing advice during the interview.
This step generates a list of items that includes business goals, the current business
situation, user stories or customer and users’ wish lists, government and industry, as
well as company policies, regulations, and standards. If the software system is an
embedded component of a hardware-software system, then the results also include
system requirements that are allocated to the software system.
As an example, consider a project initiated by the Office of International Educa-
tion (OIE) of a university. Several years ago, the OIE recognized the trend of education
globalization. That is, many U.S. universities observed a significant increase in the
number of students enrolling in study abroad programs, which allow a student to study
abroad for one or two semesters and transfer the course credits back to the United
States. To meet this new demand, the OIE started a project to improve the operation
of the Study Abroad Program. A summary of the result of the information collection
step is as follows:
Current Business Situation
The OIE is located in a building somewhat distant from the main campus. It is difficult
for students to access the OIE. The Study Abroad Program of the OIE is mainly a
manual operation. It is time consuming to process student inquiries and study abroad
applications.
Business Goals
1. Greatly facilitate students’ access to the OIE Study Abroad Program.
2. Significantly improve the effectiveness and efficiency of the services provided by
the Study Abroad Program.
Wish List
A website for the Study Abroad Program. The system is named Study Abroad Man-
agement System (SAMS). A list of similar websites was suggested by the OIE.
A directed graph in which the vertexes represent Sequence diagrams help the development team
objects and the directed edges represent time- understand and analyze the existing business
Sequence diagram ordered messages or requests between processes. That is, how the business objects
the objects. process a user request in the existing business
environment.
A directed graph in which the vertexes represent State diagrams are useful for the modeling of
system states and the directed edges represent state dependent, reactive behaviors of existing
State diagram
state transitions caused by internal or external systems or business activities.
events.
A directed graph in which the vertexes represent Activity diagrams are used to model information-
information-processing activities, the directed processing activities of the existing application
Activity diagram edges represent data flows and control flows in which the activities relate to each other
among the activities. The control flows specify through complex data flow and control flow
that the activities are performed sequentially, relationships.
concurrently, and/or synchronously.
by OIE advisors, who either accept or do not accept the applications. If the applica-
tion is accepted, then the overseas institution is contacted, the academic department
and the student are notified, and the application is archived. If the application is not
acceptable, then the student is notified and the application is also archived.
Modeling consumes considerable time and effort. Therefore, construct mod-
els only if they greatly help understanding and analysis. Avoid constructing mod-
els just for the sake of documentation. Agile development suggests “barely enough
modeling”; in other words, do minimum modeling that is just enough to serve the
purpose but no more.
Prepare Receive
Student
Application Notification
Contact
:Application Overseas
Institution
Notify :Student
Student Notification
OIE Advisor/ Review [accepted]
Staff Notify :Department
Applications
Academic Notification
Department
Academic Receive
Department Notification
Legend:
Prepare
:Application Application
object activity decision point work flow forking swimlane separator
• Students should be able to search for overseas exchange programs using a variety
of search criteria.
• OIE staff members should be able to enter, edit, activate, and deactivate overseas
exchange programs.
• Students should be able to create, edit, and submit applications for overseas
exchange programs.
• OIE advisors should be able to process online applications.
is used to identify the needs, meaning things to be done, or capabilities the business
must provide to fill the gap. For example, the business goal to double sales in the
next three years implies that the business has to increase its sales capability. This
could be accomplished in many ways, such as by expanding its sales force, providing
discounts, and/or going online, to mention a few. Often, a computerized solution is
one of the possible solutions but may or may not be the most cost-effective solution
for the problem. For example, going online may increase sales for some types of
product, but this is not true for all types of products. The development team should
work with the customer, users, and domain experts to identify the most appropriate
solution for the business problem.
•
EXAMPLE 4.1 In illustration, after a presentation by the OIE operating director and a couple of
follow-up meetings with the OIE, the SAMS project team identifies two to three
dozen functional requirements for the system. The following are three of them:
R1. SAMS shall provide a search capability for overseas exchange programs
using a variety of search criteria.
R2. SAMS shall provide a hierarchical display of the search results to
facilitate navigation from a high-level summary to details about an overseas
exchange program.
R3. SAMS shall allow students to submit online applications for overseas
exchange programs.
•
•
Figure 4.4 shows an activity diagram for an existing, manual process for the Of- EXAMPLE 4.2
fice of International Education (OIE). Identify functional requirements from the
activity diagram.
Solution: The activity diagram in Figure 4.4 has the following activities:
1. Prepare application. This activity is performed by the student. Currently, the
student fills a form manually and submits it to the OIE.
2. Review applications. This activity is performed by the OIE advisors. The OIE
advisors review each of the applications and determine whether to accept or
not accept the application.
3. Contact overseas institution. This activity is performed by OIE advisors, who
contact the overseas institutions on behalf of the students who are accepted to
exchange programs.
4. Notify student. This function is performed by an OIE staff, who sends letters
to the students informing them of the evaluation results of their applications.
5. Notify academic department. This function is performed by an OIE staff,
who sends a letter to each of the academic departments notifying them which
students are accepted into the exchange program and which students are not.
6. Save to archive. This function is performed by an OIE staff, who archive the
applications that are evaluated.
7. Receive notification by student. This function is performed by the students,
who receive the notification letters sent by the OIE staff.
8. Receive notification by academic department. This function is performed by
secretaries of the relevant academic departments, who receive and archive the
notification letters sent by the OIE staff.
Although these are activities of the existing, manual system, the new system ought
to provide automated means to support these activities because they are part of the
business behavior of the OIE application. This suggests the following requirements
for the new system.
R4. SAMS shall provide online capability for students to prepare applications
to overseas exchange programs.
R5. SAMS shall facilitate review of applications by OIE advisors.
R6. SAMS shall contact the overseas institution when an application is
accepted by the OIE.
R7. SAMS shall notify relevant entities when an application is accepted or
rejected.
R7.1. SAMS shall notify the student when an application is accepted or
rejected.
R7.2. SAMS shall notify the academic department when an application
is accepted.
∨
96 Part II Analysis and Architectural Design
columns represent the use cases. Labeling the requirements and constraints with dotted
numbers makes it easy to construct and use the traceability matrix. The dotted numbers
also imply a refinement or decomposition hierarchy between the requirements as
well as between the constraints. In Example 4.2, requirement R6 is refined by two
requirements R6.1 and R6.2. This means R6 is equivalent to R6.1 and R6.2. That is, R6
is satisfied if and only if R6.1 and R6.2 are satisfied. Such an equivalence relationship
is useful because it is easier to satisfy each of the lower-level requirements.
Prioritizing Requirements
After the derivation of the requirements, an integer priority weight ranging from 1 to
5, or 1 to 10, is assigned to each requirement. Thus, use cases associated with high-
priority requirements will be developed and delivered first. It is important to prioritize
the requirements because time and resources are limited. The priorities help the team
focus on high-priority requirements. This in turn ensures that the business priorities
are met. The development team should work with the customer and users to determine
the priorities of the requirements. Survey questionnaires and interviews, as described
earlier, can be used.
Section Description
1. Introduction Provide an overview of the software requirements specification (SRS)
1.1 Purpose Specify the purpose of the SRS and the intended audience
1.2 Scope a. Identify product by name
b. Explain what the product will and will not do
c. Describe the uses of the product including objectives, goals, and benefits
1.3 Definitions, Acronyms, and Provide definitions of all items, acronyms, and abbreviations to properly
Abbreviations interpret the SRS. It may contain references to appendixes or other documents.
1.4 References List each document referenced in the SRS by title, report number, date,
publisher, and where and how to get it
1.5 Overview Outline the rest of the SRS and how it is organized
2. Overall Description Provide an overview of the product
2.1 Product Perspective Describe the context of the product and its relations and interfaces to other
2.1.1 System Interfaces components of the total system. Block diagrams may be used to show the
2.1.2 User Interfaces context and relationships.
2.1.3 Hardware Interfaces
2.1.4 Software Interfaces Describe also the characteristics and limits on the primary and secondary
2.1.5 Communications Interfaces memory, modes of operations, backup and recovery, and site specific
2.1.6 Memory requirements
2.1.7 Operations
2.1.8 Site Adaptation
Requirements
3.2 Functional Requirements Provide a detailed description of the functionality of each of the functional
requirements beginning with “The system shall (do/perform/provide . . .).” The
description may include input validity checks, sequence of operations,
responses to abnormal situations, input output relationships.
3.3 Performance Requirements Describe all performance related capabilities of the product
3.4 Design Constraints Describe all restrictions on the design alternatives such as restrictions imposed
by standards and hardware limitations
3.5 Software System Attributes Describe all quality related requirements such as reliability, security,
availability, and interoperability, etc.
3.6 Other Requirements
Appendixes
Index
The risks are monitored throughout the development process. The appropriate risk
resolution measures are applied if the risk conditions are detected. Risk management
is presented in Chapter 23.
Technical Review
Technical review is an internal review performed by the development team. Technical
review techniques include peer review, inspection, and walkthrough. Technical review
is aimed to reveal a number of problems, including:
Expert Review
Expert review is conducted with domain experts and aims to answer the following
questions:
1. Are the domain-specific laws, rules, behaviors, policies, standards, and regula-
tions correctly and accurately formulated in the SRS?
2. Are there any incorrect, inaccurate, inappropriate, or inconsistent use of jargons?
3. Is the perception of the application domain correct and accurate?
4. Are there other potential domain-specific problems or concerns?
100 Part II Analysis and Architectural Design
Customer Review
Customer review is performed with the customer and users and seeks answers to the
following questions:
1. Does the requirements specification correctly describe the functional require-
ments of the application for which the system is to be built or extended?
2. Are there incorrectly stated user interface requirements?
3. Are there incorrectly stated nonfunctional requirements including performance,
response time, and security requirements?
4. Are there incorrectly stated application specific-constraints relating to operating
environment, government, and industry policies and regulations?
adequately, and in detail. As the use cases are iteratively installed and operational
in the target environment, the customer’s business evolves, and so changes to the
requirements are needed. Therefore, it is a waste of time and effort to capture
and specify the details of the requirements even if it is possible to do.
3. Good enough is enough---produce a list of software requirements quickly and
move on to the next step. You don’t need to acquire every requirement up front
and you don’t need to have them 100% correct and accurate. The properties
of wicked problems presented in Chapter 2 tell us that requirements cannot be
exhaustively, accurately, and definitely identified and specified. Therefore, agile
methods focus on identifying, validating, and specifying the requirements that
are mission critical, with a high business priority, and a high business value.
This principle is often equated to the 20/80 rule, which encourages identifying
the most used functionalities of the system with a fraction of the effort. These
principles are practically very useful because one cannot have everything—you
give up something to get something else. This means focusing on the require-
ments that are the most valuable to the customer rather than spreading thin on
everything.
4. Just barely enough modeling---if models are constructed to aid requirements elic-
itation, then construct the minimum model quickly, just enough to serve the pur-
pose and no more. Agile development values working software over comprehen-
sive documentation because the former is the bottom line. However, modeling
improves understanding and communication between the team members if used
properly. Just barely enough modeling means that if modeling is desired, you
should then try to limit the scope to just enough to serve the purpose.
SUMMARY
•
This chapter presents the basic concepts, steps, and bility study, and (5) reviewing the requirements and
techniques for requirements elicitation. Also pre- constraints. Three types of requirements review are
sented are the importance and challenges of require- described: technical review, expert review, and cus-
ments elicitation. The steps are: (1) collecting in- tomer review. Each of these reviews focuses on dif-
formation about the application and application do- ferent aspects of the requirements specification. At the
main, (2) constructing analysis models, (3) deriving end of the chapter, agile principles for requirements
requirements and constraints, (4) performing feasi- elicitation are described and discussed.
Chapter 4 Software Requirements Elicitation 103
The SRS specifies the capabilities or what the differently. Use cases are useful in this regard because
system must deliver. It does not specify how to de- use cases are refinements of requirements. While re-
liver the capabilities. How to deliver is left to the quirements specify what the system is to deliver, use
subsequent iterations. Nevertheless, the specification cases describe how the capabilities will be delivered.
of only what but not how may lead to requirements In other words, use cases implement the require-
misinterpretation. That is, the development team and ments. This effectively reduces the possibility for
the customer and users may interpret the requirements misinterpretation.
FURTHER READING
•
David Hay [78] presents requirements elicitation from a techniques. It describes and compares various methods and
business point of view. A practical guide to requirements techniques for requirements elicitation. It also includes an-
elicitation with best practices is found in [161]. An object- notated bibliographies for numerous publications in the field
oriented requirements analysis method using UML is de- of requirements analysis. The book by Berzins and Luqi [25]
scribed in [30]. The book by Alan Davis [56] is an ex- is a valuable reading for requirements analysis and require-
cellent reading for requirements analysis and specification ments review techniques.
EXERCISES
•
4.1 Produce a software requirements specification (SRS) 4.3 Identify and specify the functional and nonfunctional
for a library information system that is similar to requirements for a web-based course management
the system in use in your school. At the minimum, system. The system should allow students to search,
the system should provide functions to allow the register, and drop courses, respectively. It also allows
patron to search, check out, and return documents, the staff members of the study administration of the
respectively. university to schedule classes.
4.2 Formulate the functional and nonfunctional require- 4.4 Formulate the functional requirements for the calen-
ments for each of the following systems. For each dar management system described below. Limit the
system, limit the requirements specification to no length of the SRS to no more than two pages.
more than three pages. This calendar management software allows the
a. A desktop virtual calculator that allows the user to user to schedule personal activities such as meetings
use the mouse as well as the keyboard to enter the and tasks to be performed. An activity can take place
input on a future date during a certain period of time. An
b. A telephone answering machine activity can take place for several consecutive days.
c. A web-based email system Each activity has a brief mnemonic description. An
104 Part II Analysis and Architectural Design
activity can be a recursive activity, which takes place 4.6 In Appendix D.2, a National Trade Show Services
repeatedly every hour, every day, every week, or ev- (NTSS) business is described. Suppose that cur-
ery month. A user can schedule an activity using a rently the NTSS business is conducted manually.
month-by-month calendar to select the date or dates, The company wants to develop a web-based on-
and then zooms in to select the begin time and end line system to automate the business. This exercise
time on a date. The calendar system shall notify the may be an individual assignment or part of a team
user by email, text message, or phone call the day project. It requires the student or team to do the
before and on the activity day. The user can review following:
past activities and modify the schedule including up- a. From the business description, identify and list
dating and deleting activities. the most important business activities of the cur-
4.5 Produce an SRS for the room reservation system de- rent business. These are the functionalities that
scribed below. Limit the length to no more than two the future system must provide. Hint: The number
single-space pages. of such activities may differ from student to stu-
This web-based single-room reservation system dent. However, the combined functionality identi-
is a resource management system that allows regis- fied should cover at least 90% of the current busi-
tered users of an organization to reserve a room for a ness activities, which includes the most important
given period of time on a given date. Moreover, the business functions.
system allows the user to choose whether a reminder b. Identify other necessary functionalities for the
message will be sent automatically to a group of users online system so the business can run online.
and on which date(s) to send the reminder message. For example, the system needs to authenticate
Since only one room is available, therefore, no search users.
capabilities are necessary. The system allows a user c. Formulate the functionalities as software
to navigate to the desired day using a visual month- requirements.
by-month calendar. As the monthly calendars are dis- 4.7 Describe in concrete terms how you would con-
played, the time periods that are already reserved are duct each of the three types of review for the NTSS
colored red and the available time periods are colored software requirements specification you produce in
differently, or shown with no color. The configura- Exercise 4.6. Limit your answer to no more than one
tion of the system is used to specify a number of single-spaced page and no less than 11 point font
properties or constraints: size.
a. Enable or disable a display of which user reserves 4.8 Identify and formulate requirements and constraints
which time period. for the online car rental system described in
b. Enable or disable the ability for a user to reserve Appendix D.1. Also provide priority weights for the
the room recursively for a given period of time. For requirements according to the nature of the car rental
example, 10:00 a.m.–12:00 p.m. every Wednesday business.
for the whole semester. 4.9 Write an article to describe how requirements elicita-
c. Specify a constraint on the maximal period of time tion would be performed using the waterfall process
for recursive reservations. and an agile process, respectively. List the differences
d. Specify a constraint on the number of reservations between the two approaches, and provide a brief
that a user can make. explanation of the differences.
e. Enable or disable automatic system reminder
message.
5
Domain Modeling
105
106 Part II Analysis and Architectural Design
this wireless simulator project. A hardworking student visited my office nearly every
week, bringing the copious notes he had taken while reading materials about wireless
communication. I urged him to construct a domain model instead of taking the notes.
Unfortunately, the student did not do this until the project deadline had approached.
After submitting the domain model, the student came to me and said, “I regret that
I did not start domain modeling earlier. It really helped me to understand wireless
communication in a fast, organized way.”
So, what is domain modeling?
• Domain modeling lets the team members communicate and improve their com-
mon perception of the application and application domain.
• Domain modeling helps the development team communicate their perception to
the customer or users and seek feedback.
• Domain modeling provides a common conceptual basis for the subsequent design,
implementation, testing, and maintenance.
• A domain model can help new team members understand the relevant application
and the application domain.
Inheritance A generalization/
specialization relationship subclass superclass
between two classes.
FIGURE 5.1 Some commonly used class diagram notions and notations
Domain modeling is similar to the child’s perception of the world and uses both
extensional and intentional definitions. The team enters into a new application domain.
Like the child, the team enumerates things it sees, and classifies them into classes,
attributes, and relationships. The result is visualized using UML class diagrams,
defined as follows:
Definition 5.4 A UML class diagram is a structural diagram that depicts the
classes and their attributes and operations, and relationships between the classes.
Figure 5.1 shows the class diagram notions and notations that are used in domain
modeling. The next several sections explain these in detail.
Classes can be shown using either the compact view or the expanded view as
illustrated in Figure 5.2(a) and Figure 5.2(b). The compact view is used if there is no
Chapter 5 Domain Modeling 109
need to show the detail of a class. The expanded view is used to show the attributes
and operations of a class. Both the compact view and the expanded view can be used
in the same class diagram. That is, some classes can be shown in the compact view
and others in the expanded view.
The attributes and operations of a class are also called features of the class. The
word feature nicely reflects the intention to capture and highlight the most essential
and necessary properties and behaviors of the class. A class is a type, be it a built-in
type or a user-defined type. It is an intentional definition because a class can be defined
by a predicate. For example, when the child forms his concepts of dog, cat, animal,
human being, and house, he has a predicate in his mind for each of these. When he
draws his garden house, he also has a predicate. In the object-oriented paradigm, the
predicate that defines a class is the set of attributes and operations of the class. To
facilitate discussion, the following conventions are used in this chapter:
• Class names use an initial capital and take the singular form: Customer, Bank,
and Account could be used to refer to classes.
• A variable x of type X is denoted x:X. This can be applied to both scalar type and
class type. For example, a variable c of the Customer class is denoted c:Customer.
When no confusion can arise and the type of x is clear from the context, the colon
and the type are dropped.
• An instance c of class C is denoted c:C. For example, a1:Account, a2:Account,
a3:Account denote three Account objects a1, a2, and a3. When no confusion can
arise and the class is clear from the context, these objects are referred to as a1,
a2, and a3. It is useful to note the following: (1) :Account denotes an anonymous
object of Account. It is useful in some contexts, for example, objects referenced
in a loop. (2) x: denotes an orphan object, that is, an object of an unspecified
class. It is useful in a polymorphic context or the class type is not of interest.
• The set of all instances of a class C at a given point in time is denoted U(C),
U(C)={ c | c:C }, or as a shorthand notation
U(C)={ c1, c2, . . . , cn } when the objects of C can be enumerated.
Thus, an instance c of class C can also be denoted as c ∈ U(C). Here, U is called
the universe of discourse and U(C) the projection of U on C.
• If c is an instance of class C, then c.a and c.f(. . . ) are used to refer to or access
an attribute a and a function f(. . . ) of c, respectively.
110 Part II Analysis and Architectural Design
Here, independent existence means that the application has an interest in main-
taining information or state about the object. For example, “number of seats” does not
have independent existence because it could be number of seats in a car, a classroom,
or an airplane, which are objects. “Independent existence” is not limited to physical
existence. It includes conceptual or mental existence. For example, a book physically
exists, but a discipline is a mental notion.
GUIDELINE 5.3 Attributes can be entered from an input device (like a keyboard)
but objects cannot; objects are created by calling a constructor.
One cannot enter a student object from the keyboard. One can enter only the
student name, student number, address, phone number, and other information. But
these are attributes, not objects. Student objects are created by invoking a constructor
of the Student class.
5.3.4 Association
Besides classes and attributes, a domain model also documents relationships between
the object classes. Three relationships are commonly used in domain modeling and
are defined in this and the following sections.
Own Work-Supervised-by
Customer Account Student Project Professor
c1 a1 Chen OOM Baker
c1 a2 Chen SOA Liu
c2 a2 Gupta SOA Liu
c2 a3 Rosa Security Brown
c3 a4 Smith Security Shah
Figure 5.2, an association between Employee and Project is shown. That is, employ-
ees work on projects. The small solid triangle indicates the association direction, that
is, employees work on projects but not the other way around.
A tabular representation helps understand association relationships. Consider the
Customer owns Account association, denoted Own(Customer, Account). The type of
Own is the pair (Customer, Account). More strictly, Own:(Customer, Account), but
the colon is dropped for simplicity. Using the conventions presented at the end of Sec-
tion 5.3.2, assume that U(Customer)={ c1, . . . , c4 } and U(Account)={ a1, . . . , a5 }.
C1 has a1 and a2, c2 has a2 and a3, c3 has a4, c4 does not have an account, and a5 is not
owned by any customer. As displayed in Figure 5.3(a), the Own(Customer, Account)
association consists of five pairs: (c1, a1), (c1, a2), (c2, a2), (c2, a3), and (c3, a4). The
table together with U(Customer) and U(Account) show that a customer can own zero
or more accounts and an account can be owned by zero or more customers. In fact,
any subset of the set of the 20 pairs, formed by pairing each of the four customers
with each of the five accounts is allowed. That is, there are 220 such subsets and each
of them is a valid instance of the Own association.
The most commonly encountered associations are binary associations. Binary as-
sociations are relations between objects of one or two classes. For example, that one
account can transfer money to another account illustrates a binary relation between the
objects of one class. As another example, an employee can supervise other employees,
forming an association between objects of the Employee class. Association between
objects of three classes or a ternary association can also exist. For example, a relation-
ship among Professor, Student, and Project in which professors supervise students
working on projects is a ternary, or three-way, association that involves objects of three
classes. Figure 5.3(b) illustrates some possible instances for this ternary association.
As illustrated in the above examples, a binary association can be denoted using
the form V(X, X) or V(X, Y), and a ternary association using the form V(X, Y, Z),
where V is the name of the association and X, Y, Z are classes. This notation will be
used in this book when discussing associations. When there is no risk of confusion,
the pair of parentheses and the arguments are dropped, and Own(Customer, Account)
is referred to as the Own association.
customers can own the same account. Usually, a customer can have more than one
account in a bank. Some banks allow joint account ownership, but some other banks
require that each account can only be owned by one and only one customer. As another
example, a student may work on one or more projects. But a project may have zero
or more students working on it. A project may have no student because the project is
either new or terminated. A student working on a project may be supervised by one
or more professors. These examples demonstrate the need to identify and specify the
so-called multiplicity, defined as follows.
supervisor and the student the research assistant. In the Own(Customer, Account) ex-
ample, a customer plays the role as the account owner. Roles are displayed in a class di-
agram similar to multiplicity. In illustration, Figure 5.2 shows that the roles of Project
and Employee in the work-on association are member and project, respectively.
5.3.6 Aggregation
An association is a general relation between one or more classes. Practical applications
frequently encounter the so-called part-of relationships. For example, an engine is a
part of a car, a book consists of chapters, each of which consists of sections, and so
on. The part-of relationship is a special type of association relationship and deserves
a modeling concept and construct of its own. Therefore, the modeling community has
long introduced the so-called aggregation relationship to accommodate this need.
Reservation
5.3.7 Inheritance
Definition 5.10 Polymorphism means that one thing can assume different forms.
Chapter 5 Domain Modeling 115
By looking at Definitions 5.9 and 5.10, one should see the difference. Inheritance
defines a relationship between two concepts or classes such that one class is more
general (or more specific) than the other. Due to this generalization (or specialization)
relationship, a variable of the superclass type can refer to an object of one of the
subclasses. Therefore, the superclass variable can exhibit different behavior, achiev-
ing polymorphism.
Polymorphism, on the other hand, is concerned with the ability of one thing to
assume different forms. Since “one thing” is unconstrained, it could be anything, not
just classes and objects. The ability to assume different forms is not limited to the
context of inheritance; it can be in any other contexts. For example, two or more
member functions can share the same name but have different signatures. A function
pointer in C++ can point to different functions at run time. These are examples of
polymorphism but not in the context of inheritance.
correspondence between the instances of this Receive association and the Enroll
association. That is, additional effort is required to ensure that every instance of the
Receive association has a corresponding Enroll instance and every Enroll instance
has a corresponding Receive instance. Similarly, if one defines grade as an attribute
of Course, then one will have the same problems as discussed above. Another quick
solution suggests the addition of a Grade class and two associations: one one-to-many
association from Student to Grade, say Has(Student, Grade), and the other is a one-
to-one association from Grade to Course, say Is-for(Grade, Course). But this solution
still does not solve the implicit correspondence assumption problem as previously
described.
A careful analysis of the problems discussed should reveal that the grade attribute
is in fact a piece of information about the Enroll(Student, Course) association. Simi-
larly, the semester in which the student had taken the course to receive the grade is also
a piece of information about the Enroll(Student, Course) association. The above quick
solutions attempt to store these two pieces of information not with the association
itself but with other classes, creating the correspondence problem. A straightforward,
and hence a better, solution would be to store the information about the association
with the association itself. This eliminates the correspondence problem. The question
remains how to accomplish this. The following definition points toward an answer.
Definition 5.11 An association class is a special class that defines properties and
behaviors for the instances of an association.
indicated by a dashed line that connects the association class to the association line.
In Figure 5.5(c), there is a reserve association between Customer and Vehicle. The
Reservation class stores information about which customer reserves which vehicle. It
is an association class, as indicated by the dashed line from Reservation to the reserve
association line.
Domain
information
Word list
(2) Brainstorming
(3) Classifying
(1) Collecting application
brainstorming results
domain information
Classes, attributes,
Feedback, relationships
if any
UML class
diagram (4) Visualizing the
(5) Review and
domain model
inspection
Actor-System Interaction
Modeling (Chapter 8)
The above documents, descriptions, and forms may not exist; the analyst or the
development team may need to use information-collection techniques to obtain them.
These techniques include:
1. Customer presentation.
2. Interviewing customer representatives, users, and domain experts.
3. Study of relevant literature.
4. Study of similar projects.
5. Study of business documentation and forms.
6. Study of government policies and regulations.
7. Study of industry standards.
8. Development and use of questionnaires.
The above techniques were described in detail in Chapter 4 and will not be
repeated here.
Chapter 5 Domain Modeling 119
5.4.2 Brainstorming
After the information-collection step, the team members assemble together and iden-
tify domain-specific concepts by underlining or marking phrases on documents that
describe the application. The end product of this step is a list of identified phrases.
The domain concepts are identified by applying the following rules. That is, the team
members identify domain-specific, or domain-relevant phrases such as:
1. Nouns or noun phrases.
2. “X of Y,” or “Y’s X” expressions (e.g., make of car, engine of car).
3. Transitive verbs.
4. Adjective, adverbs, and enumerations.
5. Numerics and quantities.
6. Possession expressions (has/have, possess, etc.).
7. Constituents, part of, consist of expressions.
8. Containment or containing expressions.
9. “X is a Y” expressions, or generalized/specialized concepts.
While applying the rules, the team members should bear in mind the following
guidelines:
into modeling concepts. In practice, the use of the superscript is not necessary because
one can easily identify the phrases from the underlined words.
•
EXAMPLE 5.1 Identify important application concepts from the following piece of description
for a Study Abroad Management System (SAMS):
“An undergraduate student or a graduate student can apply to no more than two
exchange programs per semester. An application consists of an application form,
two faculty recommendation letters, and a course equivalency form.
···
An exchange program has a program name, program type, academic department,
academic subject, country, region, term of study, and language.”
Solution: Figure 5.8(a) shows the underlined words with superscripts to indicate
which phrases are being identified. Figure 5.8(b) is the listing of the identified
phrases, which will be used in the classification step in the next section.
Note: (1) X is an attribute of Y if X does not have independent existence in the application.
(2) X and Y are related via an inheritance, aggregation, or association relationship if both X and Y
have independent existence in the application.
The end product of this step is a list of classes and their attributes, and relationships
between the classes.
•
EXAMPLE 5.2 Classify the brainstorming result in Example 5.1.
Solution: Figure 5.11 depicts the classification result and is explained as follows:
• Column 1 lists the phrases identified in the brainstorming step along with the
superscripts or phrase identification numbers.
• Column 2 shows the corresponding classes and their attributes, and the rela-
∨ tionships between the classes. These are indicated by using the classification
codes in Figure 5.10.
• Following industry convention, the first letter of each word of a class name is
capitalized.
• The classes and their attributes are shown together. For example, the attributes
of the Exchange Program class are listed under the Exchange Program class.
• In column 2, a binary relationship is displayed using the following notation
relation-name ’(’class-name1, class-name2’)’
[’(’[m],[n]’)’] [’(’[role-name1], [role-name2]’)’]
where m, n are multiplicity expressions and role-name1 and role-name2 are the
role names of the two participating classes. This notation can be extended to
represent n-ary relationships in a similar manner. The order of the multiplicity
and role specifications is immaterial. Figure 5.4 gives the various ways to
express a given multiplicity.
• The multiplicity and role are listed after the relationship using the above nota-
tion. For example, the aggregation or Part-of (Faculty Recommendation Letter,
Application) has a multiplicity of (2,1), which is shown on the following line
along with the numeric two on column 1. This means that an application re-
quires two faculty recommendation letters, which is derived from the numeric
two on column 1.
As another example, the apply-to (Student, Exchange Program) associa-
tion has a multiplicity of “(1, 0..2)” on the line following the association. This
is because every student can apply to “no more than two” exchange programs
per semester.
• A relationship without a multiplicity specification assumes the default value of
(1, 1). For example, the multiplicity for the other two aggregation relationships
is not shown. This means they both have the default value of (1, 1).
• Association classes are shown along with their association relationships,
which are enclosed in a pair of parentheses. For example, Application is
shown with its related association, such as, apply-to, in a pair of parentheses.
• To help the student see which classification rule has been applied, the rule
number is shown in the third column.
•
The student might ask why academic department and country are attributes, not
classes. This is because they do not have an independent existence in the SAMS
application/domain, although a country has independent existence in general, and an
academic department has an independent existence in its host university.
Finding Missing Information
In this step, the development team examines the classification result and identi-
fies missing information using reasoning, common sense, domain knowledge
124 Part II Analysis and Architectural Design
acquired elsewhere, and prior experience. The missing information includes the
following:
1. Missing classes, which may be inferred from existing classes and relationships.
For example, from Undergraduate Student and Graduate Student, it is useful to
infer Student as a superclass because a student can apply to an exchange program.
2. Missing attributes and types, which may be identified from a class or association
class that does not have any attribute. In Example 5.2, Undergraduate Student
and Graduate Student do not have attributes. The missing attributes and types
can be identified from business forms, e.g., request forms, invoices, order forms,
and reservation forms. For example, attributes of Undergraduate Student and
Graduate Student can be obtained from student registration forms.
3. Missing relationships, which may be derived from the isolated classes, i.e., classes
that do not relate to any other class. In Example 5.2, Faculty is not related to any
other class. The description implies that Faculty will provide recommendation
letters; therefore, an association relationship can be identified.
4. Missing multiplicity. Some multiplicity information is important because it spec-
ifies domain laws or application-specific constraints. For example, each appli-
cation must have two recommendation letters. To identify these, each of the
association and aggregation relationships is examined carefully to ensure that no
important multiplicity is missing.
•
EXAMPLE 5.3 Convert the classification result obtained in Example 5.2 into a class diagram.
Solution: Figure 5.13 shows the class diagram obtained.
•
Example:
Exchange Program
(C) Exchange Programs
(A) program name: String program name: String
(A) program type: String program type: String
(A) academic department: String academic department: String
(A) academic subject: String academic subject: String
(A) country: String country: String
(A) region: String region: String
(A) term of study: String term of study: String
(A) language: String language: String
transitive-
(AS) transitive-verb (Class 1, Class 2) (m, n) m verb n
(role 1, role 2) Class 1 Class 2
role 1 role 2
(AC) Class 3 (transitive verb)
Class 3
Example:
apply to Exchange
Student
(AS) apply to (Student, Exchange Program) 0..2 Program
(1,0..2)
(AC) Application (apply to) Application
role 1 role 2
Part-of (Class 1, Class 2) (m, n) (role 1, role 2) Class 1 m n Class 2
Example:
Faculty Recommendation Letter
Part-of (Faculty Recommendation Letter, 2
Application) (2, 1)
Application
Example: Undergraduate
Student
Student
ISA (Undergraduate Student, Student)
‘416 Yates Street, Arlington TX 76010’,” and “Customer C1 reserves Vehicle V1”
are specific assertions. Models that specify specific assertions are instances of models
that specify general assertions. For example, an object diagram is an instance of a
class diagram. In an object diagram, the attribute values and the actual relationships
between objects are displayed. A study of an object diagram is beyond the scope of
this book.
126 Part II Analysis and Architectural Design
apply to
Student Exchange Program
0..2
program name: String
program type: String
Undergraduate Graduate academic department: String
Student Student academic subject: String
country: String
region: String
Academic Application
term of study: String
Advisor
language: String
approved by
2
Course Recommendation Application
Equivalency Form Letter Form
0..1
Faculty missing information found
provide
Although a class diagram can show the operations of a class, a domain model
should not show these. This is because assigning responsibilities or member functions
to the classes is a design decision, which should be dealt with during design. Assign-
ing operations to classes in domain modeling, without taking into consideration how
the software objects should interact, is a premature decision. Therefore, it is important
to refrain from assigning operations to the classes in this step.
Using Aggregation
A very common mistake when using aggregation is misidentifying classes as attribute
types. For example, Engine, Transmission, and Brake are classes, but they are used
as the attribute types of the Car class in Figure 5.14(a). As stated in Guideline 5.1,
while an object has independent existence in the application or application domain,
an attribute does not. Thus, treating an object as an attribute value of another object
introduces a paradox. That is, something has an independent existence and at the same
time it does not—and that is impossible. Therefore, it is incorrect to do so.
Figure 5.5(a) shows the modeling of Car as consisting of an Engine, a Transmis-
sion, and a Brake. This is correct according to common sense. In Figure 5.14(a), it
states that an Engine object, a Transmission object, and a Brake object are attributes
or properties of a Car object. This is not correct because instances of Engine, Trans-
mission, and Brake are objects, not attributes. The attribute compartment of the class
notation should show only attributes, not objects. If the business is a car rental or car
dealership that is interested in maintaining information about various cars, such as the
type of engine (gasoline or diesel engine), transmission (manual or automatic), and
brake (disk or drum brake), then the types for these attributes should have been string,
not classes. If the application is a car manufacturer or car repair shop that is interested
in engine, transmission, and brake objects, then a diagram similar to Figure 5.5(a)
should be used.
Chapter 5 Domain Modeling 127
Car
engine: Engine
Car trans: Transmission
engine: Engine brake: Brake
trans: Transmission
brake: Brake
(a) Engine is an exclusive part (b) Car IS-A Engine (c) Engine IS-A Car
of Car—CORRECT! —WRONG! —WRONG!
Figure 5.14(b) states that Engine, Transmission, and Brake are classes and at-
tributes as well. This introduces a paradox, as pointed out earlier. Two factors may
contribute to the misuses shown in Figure 5.14. First, a component of an object like
an engine of a car is often implemented by a field or attribute of the Car class in
object-oriented programming. Second, some IDE tools confuse or equate modeling
and code generation issues and render aggregation relationships as in Figure 5.14(b).
Even worse, the incorrect way to show aggregation relationships is the only way you
can use the IDE tool.
Using Inheritance
The inheritance relationship is sometimes misused or confused with aggregation.
Figure 5.15(a) displays a correct conceptualization. That is, a car consists of an engine
exclusively. The diagram also shows that Car and Engine have similar attributes,
such as make, model, and year. The fact that the horsepower of a car depends on
the horsepower of its engine causes some modelers to use inheritance, as shown in
Figure 5.15(b). This is certainly incorrect because a car is not an engine; there is no
128 Part II Analysis and Architectural Design
Part Node
* *
Atomic
Part 1
... Atomic
Part n
Composite
Part
Leaf Tree
(a) A composite part is a part that consists (b) A tree is a node that contains
of other parts other nodes
GUIDELINE 5.6 Use inheritance only if every instance of the subclass is also an
instance of the superclass. This is called the ISA guideline.
In Figure 5.15(b) and 5.15(c), inheritance is used between Engine and Car. But
instances of Engine are not instances of Car and vice versa. Therefore, inheritance
should not have been used.
Sometimes, the ISA guideline should be understood in a generalized context.
Consider, for example, a manufacturing company, where parts can be divided into
atomic parts and composite parts. Atomic parts do not contain other parts, but a
composite part may consist of atomic as well as other composite parts. This situation
can be modeled by using the composite pattern as shown in Figure 5.16(a). The
example in Figure 5.16(b) may be easier to understand, where a Tree is a Node and
a composite of Node. Composite pattern will be discussed in detail in Chapter 16. In
these generalized contexts, the ISA guideline is satisfied.
GUIDELINE 5.7 Use inheritance only if all relationships of the superclass are also
relationships of the subclass. This is called the conformance guideline.
Since every instance of the subclass must be an instance of the superclass, the
relationships of the superclass must also be relationships of the subclass. For example,
Student belongs to Department. That is, Belong-To(Student, Department). Undergrad-
uate Student and Graduate Student are Student. That is, ISA(Undergraduate Student,
Student) and ISA(Graduate Student, Student). Therefore, Belong-To(Undergraduate
Student, Department) and Belong-To(Graduate Student, Department).
Now consider Figure 5.17(a), which states that contractors are employees. Ac-
cording to Guideline 5.7, since employees receive benefits, so do contractors. But for
many companies, this is not the case; therefore, Contractor should not be a subclass
of Employee. However, for many other companies, a Contractor is also an Employee.
Chapter 5 Domain Modeling 129
receive receive
Employee Benefits Contractor Full Time Benefits
Contractor
Retirement Health Care Retirement Health Care
Benefit Benefit Employee Benefit Benefit
(a) Incorrect if Contractor does not receive Benefits (b) Only Full Time receives Benefits
Invoice Location
pay *
Company additional charge location name
opened: boolean bill for address
name
sent to phone
address
* Contract fax
phone
{XOR } * contact
fax pay contract number
email
contact
create business hours
email Customer *
business hours sign for
name checkout from returned to
address * *
Payment daytime phone 0..1 reserve * Vehicle
evening phone select
rental charge manufacturer
email check out
price class
rental price
0..1
* make available: boolean
* Reservation
Pay By Credit rented out: boolean
Block time reserv. status
processed * Reservation 2+ grace period
by means
void: boolean
Credit Card Passenger Car
Company available to
make
* *
process model
Rental Plan transmission
Salesperson
number of doors: integer
name body style: String
phone additional charge
depreciation
Daily Weekend
Unlimited Savings {require additional charge if
Miles Plan Plan checkout from ! = returned to}
The figures show additional classes, attributes, and relationships added, for ex-
ample, body style, number of doors, and status. These attributes were derived from
the identified attribute values, such as sedan or hatchback, two or four (doors), and
car status values such as “repair,” and the like. The classification result is then con-
verted into a class diagram, as shown in Figure 5.20, where missing information
is added. It is quite normal for different analysts to produce different results—the
classes, attributes, relationships, and association classes may differ. This reflects the
differences in the perception of the application domain of the analysts; it cannot
be completely avoided. It is partly due to the difference in the domain informa-
tion collected by the analysts, the background, and experiences of the analysts, as
well as how the analysts apply the domain concept identification and classification
rules.
Chapter 5 Domain Modeling 133
GUIDELINE 5.8 The team members should perform brainstorming and classifica-
tion as team activities rather than as individual activities.
Do not brainstrom and classify at the same time so that the team can focus on
one thing at a time. This is an application of the separation of concerns principle.
GUIDELINE 5.10 Each brainstorming and classification session should last one to
two hours.
Savings Plan to Rental Plan with the UML inheritance link to indicate an inheritance
relationship.
The whiteboard can keep the team members informed and focused on what is
being discussed. At the end of the session, one team member can take a digital photo
of the whiteboard and email it to the other team members. One or two members can
draw the domain model and email it to the other team members to review. As an
alternative to whiteboard and digital camera, the team session can also use a laptop
hooked to a data projector to project the team brainstorming and classification results
on a screen so that everybody can see the results.
One of the most time-consuming and unproductive things you can do in a meet-
ing is to argue in circles about whether a concept should be included in the domain
model or how it should be classified. Not every decision you make in software de-
velopment is black and white. Many decisions are premise-based and depend on the
background and experiences of the decision maker. The decision about the inclusion
or classification of a concept in the domain model is not always scientific. There-
fore, brainstorming and classification sessions should be carefully coordinated. The
session coordinator should keep the meeting focused and ensure that time is used
effectively. The meeting should focus on identifying and later classifying domain-
relevant concepts and relationships. Irrelevant or lengthy discussions of design and
implementation issues should be discouraged and carried out after the meeting by
individuals if necessary. Group time can be used more effectively by constantly mon-
itoring the progress. If too much time has been spent on one concept or issue, then
the coordinator should politely end the discussion, table that concept or issue, and
suggest alternative ways to resolve the differences.
GUIDELINE 5.12 Do not draw UML class diagrams during brainstorming and
classification sessions.
GUIDELINE 5.13 Work closely with the customer and users to understand their
application and application domain.
Chapter 5 Domain Modeling 135
The development team needs to understand the application for which the software
system is being built. This is because understanding software requirements depends on
how much the team understands the application and application domain. The process
to acquire domain knowledge is a communication process. Therefore, the team needs
to work closely with the customer and users. The interaction with the customer and
users helps the team solicit the needed domain knowledge, clarify doubts, and correct
misunderstanding.
GUIDELINE 5.14 Perform domain modeling only if the team needs to under-
stand the application domain. Keep the domain model simple and expand it
incrementally.
SUMMARY
•
This chapter presents the usefulness of the do- class,object, inheritance, polymorphism, aggregation,
main model and steps for constructing a domain and association.
model for a given application. It is important to The chapter presents the UML class diagram
recognize that domain modeling is not just draw- modeling concepts and constructs, and guidelines for
ing a UML class diagram. The first three and using some of the modeling constructs. It should be
the last domain modeling steps are more signifi- pointed out that this chapter is not meant to provide
cant and require educated decision making. These a complete coverage of UML class diagram. Rather,
include collecting information about the appli- it is meant to present only a subset that is commonly
cation domain, brainstorming, classification, and used in domain modeling. The car rental application is
finding out missing information. In this sense, used as an example to illustrate the domain modeling
drawing a domain model is the easiest step. This methodology and UML class diagram. This example
chapter explains intentional definition and exten- is small but comprehensive enough to demonstrate
sional definition as two definition techniques. It re- the methodology and most of the UML class diagram
views important object-oriented concepts including features that are commonly used in domain modeling.
FURTHER READING
•
Reference [36] is a good source for learning UML class dia- [131], which also contains a methodology for identifying
gram. A comprehensive specification of UML can be found classes, attributes, and associations. Blaha and Rumbaugh
at the Object Management Group website at www.omg.org. [30] revised the methodology for UML 2.0.
The UML class diagram notations were proposed in OMT
Chapter 5 Domain Modeling 137
EXERCISES
•
5.1 A directed graph or digraph G = (V, E, L) consists 5.3 Perform the brainstorming step for the hotel reser-
of a set of vertexes V = {v 1 , v 2 , . . . , v n }, a set of edge vation system using the description produced in
labels L, and a set of directed edges E ⊆ V × V × L. exercise 5.2.
Suppose you are assigned to design and implement 5.4 Perform the classification step from the brainstorm-
a graph editor, that is, an editor for drawing and ing results produced in exercise 5.3 for the hotel
editing a digraph. You need to construct a domain reservation system.
model. This exercise requires you to perform the 5.5 Draw a UML class diagram as a domain model based
following: on the classification results produced in exercise 5.4.
a. Produce a textual description for a graph. The de-
5.6 Review the domain model class diagram produced
scription must describe the elements of a graph
in exercise 5.5 using the review checklist in Sec-
such as vertexes and edges and relationships
tion 5.4.5. Produce a review report that answers the
between the elements.
list of review questions.
b. Apply the brainstorming rules to the textual de-
scription as described in Section 5.4.2 and produce 5.7 Select another application and do as the above exer-
the brainstorming result. cises for this application.
c. Classify the brainstorming result as described 5.8 Suppose you are assigned to develop a graphical ed-
in Section 5.4.3 and produce the classification itor for a UML class diagram. This exercise requires
result. you to perform the domain modeling steps and pro-
d. Convert the classification result into a UML class duce a domain model that describes the modeling
diagram. notions depicted in Figure 5.1. Hint: This exercise is
5.2 Produce a one-page description of the business op- similar to exercise 5.1 but is a little bit more complex.
eration for a hotel reservation system. State practical The resulting domain model is a UML class diagram
and reasonable assumptions. that describes a UML class diagram.
6
Architectural Design
Software systems are designed and constructed to perform various functions. These
functions are provided by various subsystems and components. Many software sys-
tems are meant to operate for years or decades. For example, many banking systems
constructed in the 1960s are still in service today. Of course, these systems have
experienced significant enhancements and upgrades as well as reengineering. These
software maintenance experiences reveal that the structure or architecture of a soft-
ware system has significant impact on a number of system properties, including
performance, efficiency, security, and maintainability. It is similar to the effect of the
architecture of a building to the utility, efficiency, security, safety, and maintainability
of the building. According to Booch, software development should “focus on the
early development and baselining of a software architecture, then uses the system’s
architecture as a primary artifact for conceptualization, constructing, managing, and
evolving the system under development” [36]. In other words, the architecture of a
software system plays a central role during the entire life cycle of the software system.
In this chapter, you will learn:
139
140 Part II Analysis and Architectural Design
red hot around 1990. Ontologies provided a C++ like query language. This means
that C++ programs could directly access the database. That is, business objects and
the database were “nicely integrated.” However, this integration, or tight coupling,
could also invite trouble if it is not dealt with properly. For example, the applica-
tion code is heavily dependent on the database. If the database is replaced, then
much of the application code has to be rewritten. To prevent this, a suggestion was
made to develop a database wrapper to hide the database from the business objects.
This provides protection to the business objects when the database is changed or
replaced. If this happens, then only the wrapper, not the business objects, needs to
be changed. It is much easier to change the wrapper than the business objects. The
student will see in Chapter 17 that this is in fact the design of a persistence frame-
work. Unfortunately, the development team rejected this because it was considered
too complicated, inefficient, and required too much work. That was at the beginning
of the project.
Ten months later, after most of the system had been implemented, a rumor sur-
faced that the vendor of Ontologies had an internal power struggle. As a consequence,
the cofounders, who were the key technical staff, threatened to leave the company
and start another company. The development team that relied on Ontologies was ner-
vous and hoped that the Ontologies personnel would stay. One month later, the rumor
became a reality—the cofounders left Ontologies and formed a new company. This
was disastrous to the successful completion of the project. The development team
began to implement the database wrapper, but it was too late. The project was terribly
behind schedule. A couple of months later, the Ontologies vendor went bankrupt. A
few months later, the team was fired.
Figure 6.1 shows the architectural design process, which should be performed
recursively for the system as well as the subsystems identified during this design
process.
1. Determine design objectives. In this step, the overall design objectives are iden-
tified and specified. For example, the design is aimed to provide software fault
tolerance, safety and security, and maximize performance. The overall design
objectives may be found or derived from the requirements.
2. Determine type of system. In this step, the type of the system or subsystem is
determined. The type of system and design objectives are used to select an ar-
chitectural style from a repository.
3. Apply an architectural style or perform custom architectural design. If an ar-
chitectural style can be applied, then this step applies the architectural style
to produce a “standard” architectural design; otherwise, a custom design is
produced.
4. Specify subsystem functions, interfaces, and interaction behavior. In this step,
the interfaces between the subsystems are defined and the interaction behavior
between the subsystems are specified.
5. Review the architectural desgin. In this step, the architectural design is reviewed
to ensure that it satisfies the requirements, design objectives, and software design
principles.
the architectural design objectives can be derived from the software requirements
including the quality and security requirements. A partial list of such requirements
or factors that should be considered is as follows:
1. Ease of change and maintenance. Does the application require frequent changes
to the system to respond to changes in the application, such as a response to a
requirement change?
2. Use of commercial off-the-shelf (COTS) parts. Does the project require or pro-
hibit use of COTS, and what is the extent of such reuse?
3. System performance. Does the application require high performance, for exam-
ple, to process real-time data or a huge volume of transactions?
4. Reliability. To what extent does the application require the system to correctly
perform its intended functions under assumed conditions?
5. Security. What is the extent of protection to data and program resources required
by the application?
6. Software fault tolerance. To what extent does the application require the system
to continue operation when a software problem occurs?
7. Recovery. To what extent does the application require the system to return to a
previous state after a system crash?
a b a c
b a c b z
c / /
x y
Interactive Systems
An interactive system typically exhibits the following properties:
1. The interaction between the system and the actor to carry out a business process
consists of a relatively fixed sequence of actor requests and system responses as
illustrated in Figure 6.2(a).
2. The system has to process and respond to each request from the actor.
3. Often, the system interacts with only one actor during the process of a use case.
4. The actor is often a human being although it can also be a device or another
subsystem.
5. The interaction begins and ends with the actor.
6. The actor and the system exhibit a kind of client-server relationship in the sense
that the actor requests services and the system provides the services. This client-
server relationship becomes more apparent when the actor is another system.
7. The system’s state typically reflects the progress of the business process repre-
sented by the use case.
Interactive systems are the most common due to the widespread use of desktop
and web-based applications. The relatively fixed sequence of interaction can be seen
from a typical log-on process. To log on to a system, the user clicks the Log On link,
the system shows the Log On page, the user enters the login ID and password, and the
Chapter 6 Architectural Design 145
system displays the Welcome page or an error message if the login ID or the password
is not valid.
To see that the system state reflects the progress of the business process, consider
the process of online shopping. The customer logs on, selects the items, then checks
out. If the customer has not logged on, then he or she won’t be able to check out because
the system maintains the state of progress. During checkout, the customer has to
provide the shipping address, select the payment type, and provide payment-related
information. Again, the system state reflects the state of progress of the business
process. This state has been utilized by the system to prevent the customer from
performing operations that do not follow the steps of the business process.
Modeling and design of interactive systems typically begin with the identification
and specification of use cases representing business processes that are initiated by an
actor and end with the actor. The use cases are then refined in object interaction
modeling to specify how the objects in the system will interact with each other to
carry out the background processing of the business tasks. Object interaction modeling
is studied in Chapter 9.
Event-Driven Systems
Event-driven systems typically exhibit state-dependent, reactive behavior and the
following properties:
1. The system receives events from and controls the external entities.
2. In general, event-driven systems do not have a fixed sequence of incoming re-
quests; the requests arrive at the system randomly.
3. Event-driven systems do not have to respond to every incoming event. Its response
is state dependent—the same event may result in a different response if the system
is in a different state. The system may also ignore an incoming event.
4. Event-driven systems often interact with more than one external entity at the
same time.
5. The external entities are often hardware devices or other software components
rather than human beings.
6. The system’s state may not reflect the progress of a computation. The states may
represent the recurrences of system conditions. For example, the system may be
in the idle state, then enter into the “process event A” state, and return back to
the idle state.
7. The system may need to meet timing constraints, temporal constraints, and timed
temporal constraints. Examples of such constraints are:
• The processing time for each digit dialed must not exceed N milliseconds—a
timing constraint.
• After transmitting the specified number of ring tones, transmit the greeting
message—a temporal constraint, which specifies a desired event sequence.
• Following the transmission of the push-to-talk (PTT) signal, the network iden-
tification number (NID) must be transmitted within N milliseconds—a timed
temporal constraint, which specifies a timing constraint between two events.
146 Part II Analysis and Architectural Design
Transformational Systems
Transformational systems typically exhibit the following properties:
Object-Persistence Subsystems
Object-persistence subsystem is a subsystem that provides capabilities for storing
and retrieving objects from a database or file system, while hiding the storage media.
Due to its use of a database, it is also called a database subsystem for convenience.
A database subsystem exhibits the following properties:
1. It hides the database from the rest of the system and shields the rest of the system
from changes to database implementation.
2. Unlike the other three types of subsystems, a database subsystem is responsible
only for storing and retrieving objects from the database. It does little or no
business processing except in a few cases when doing so can substantially improve
performance, such as when a large number of records needs to be updated.
3. A database subsystem is capable of efficient storage, retrieval, and updating of a
huge amount of structured and complex data.
with the root or main program and is carried out by the descendants recursively
down the tree. It is useful for designing transformational or workflow-oriented
systems.
4. Event-driven system architecture. This architectural style consists of a state-
based controller that interacts with, and controls a number of components. The
controller knows the components and vice versa, but the components do not know
each other. Interaction between the components is mediated by the controller. It
is useful for designing event-driven, embedded systems.
5. Persistence framework architecture. This architectural style hides the databases
and file systems by decoupling them from the objects that use them. That is,
the objects are unaware of the existence of such storage devices; and hence, all
changes to the databases and file system have no impact to the objects.
The N-tier architecture shown in Figure 6.4(b) is often used as the architectural
design for interactive systems. Such systems interact with the user through use cases
as illustrated by the Checkout Document use case previously described. The N-tier
partitions the objects of the interactive system into layers, where each is assigned a
number of related responsibilities. For instance, the GUI layer for presenting infor-
mation and GUI widgets, the controller layer for handling use case-related events,
the business objects layer is a collection of business objects, the database layer for
storing and retrieving objects with a database, and the network communication layer
for communicating with a remote site.
Nevertheless, the N-tier architecture is not limited to interactive systems. For
example, the ISO Seven Layer Model is a seven-tier architecture used for network
communication. The N-tier architecture is also used in the design of operating systems
and secured systems. One approach to designing secured systems requires the layers
to authenticate to the next lower layer. This creates N obstacles for an intruder and
protects the valuable data and program resources. The N-tier architecture codifies
150 Part II Analysis and Architectural Design
Network
Graphical User Controller Business Objects Database Communication
Interface Layer Layer Layer Layer Layer
requests requests
requests requests requests
requests
several software design principles, which are presented in Section 6.5. For example,
separation of concerns is realized by grouping objects of different concerns into
different layers. As a consequence, high cohesion and designing “stupid objects’’ are
achieved. Information hiding and design for change are supported by the fact that
each layer hides the lower layer and shields the change impact of the lower layer.
computers located at different terminals of the airport. These computers need to access
the flight information system to retrieve flight information as well as update passenger
check-in and flight status. In this case, the passenger check-in computers are the clients
and the flight information system is the server. The clients send service requests to the
server, through remote procedure calls or other network communication protocols.
The server processes the requests and sends the results to the clients. The clients know
the server but the server does not know the clients. This means that clients can be
added to or removed from the system freely without impacting the work of the server
(except performance impact). Usually, the clients and the server reside on different
machines at different locations.
The client-server architecture is useful for applications that requires a desig-
nated subsystem to provide services to other subsystems, which may locate on other
machines. The clients can be made lightweight if most of the needed services are
provided by the server. For example, in the ABHS, the passenger check-in clients
are lightweight clients. Besides the ABHS, many other examples of the client-server
architecture are found in real-world applications. These include most web-based ap-
plications, file servers, and file transfer protocol (ftp).
Main program
<<function call>> <<function call>>
<<function call>>
i0 i1 i2 i3 i4 i5 i6 i7
P1 P2 P3 P4 P5 P6 P7
(b) A data flow model and its mapping to the architecture design
program calls its child subroutines, which, in turn, call lower-level subroutines. Usu-
ally, the child subroutines are invoked from left to right. The main program and
subroutines architecture may have a lattice shape if two parent nodes call the same
child subroutine. Students who have programmed in a procedural language such as
C or Fortran should be familiar with this architecture.
The main program and subroutines architecture is often used as the architectural
design for transformational systems. It is derived from a data flow diagram in SA/SD.
In illustration, the following paragraphs describe how the architecture in Figure 6.6(a)
is derived from the data flow diagram shown in Figure 6.6(b). Before proceeding, it
is useful to know that the processes of a data flow diagram can be classified into three
broad categories:
Formatting processes. Each of these converts its input to produce an output
with a different format. For example, a submitted html form is converted to a
struct. Formatting processes only change the representation, not the content.
Transform processes. Each of these performs an application-related process-
ing, which transforms the input into an output that is semantically different. For
example, the input is search criteria and the output is a list of products satisfying
the search criteria.
Dispatching processes. A dispatching process analyzes its input and, according
to the transaction type, redirects the input to one of the successor processes, which
handle different types of transactions.
The derivation of the main program and subroutines architecture from
Figure 6.6(b) starts from the initial input i0 and traces the processes P1, P2, . . . in
turn until a transform or dispatching process. For example, assume that process P3
is a transform process. The tracing continues until a formatting process is found, say
P6. Thus, the tracing identified input formatting processes P1 and P2, transforma-
tional processes P3, P4, and P5, and output formatting processes P6 and P7. These
are mapped to the lowest-level subroutines in Figure 6.6(a). Note that subroutines
1 to 3 are driver routines, which invoke the input formatting, transform, and output
formatting subroutines. The data flow diagram in Figure 6.6(b) is called a transform-
centered data flow diagram. A transaction-centered data flow diagram is one that
involves a dispatching process, which has outgoing data flows to different transform
processes that handle different types of transactions. The derivation of a main program
and subroutines architecture from a transaction-centered data flow diagram is similar,
except that the dispatching process is mapped to the main program or a subroutine
that invokes one of its child subroutines according to the transaction type.
Consider, for example, the design of an integrated development environment
(IDE). The functions of the IDE include, among others, compiling source programs,
and reverse-engineering source code to produce UML diagrams. The diagrams to be
produced are selectable by the user. For simplicity, only one programming language
is considered. To compile the source code to generate the executable code, a compiler
performs the following tasks, implemented by four components:
1. Lexical analysis. This task analyzes the words of the source program and classi-
fies them into different types of tokens. For example, “1stYear” is not valid, and
Chapter 6 Architectural Design 153
“year1,” “static,” and “++” are recognized as identifier, reserved word, and op-
erator. The output of this task is a stream of tokens, each of which has type, value,
and other attributes. The output goes to syntax analysis, which is described next.
2. Syntax analysis. This task analyzes the syntax of the program statements and
produces a syntax tree to represent the program. The output of syntax analysis
is the input to the code generation task.
3. Code generation. This task performs a post-order traversal of the syntax tree
and generates the executable code while each node is visited. For instance, when
nodes a and b are visited, their values are loaded in some way. When node + is
visited, an addition is performed on the values of its two children and the result
is stored. The output of this step goes to code optimization, as described next.
4. Code optimization. This task performs optimization of the generated executable
code using code optimization techniques. The optimized code is the result of the
compiler.
The reverse-engineering functions are similar, except that code generation and
code optimization are replaced by diagram generation and diagram display, respec-
tively. However, there is a concrete diagram generator and a concrete diagram dis-
player for each type of UML diagram supported. Figure 6.7(a) shows a data flow
Load
Source executable optimized
[if compile] Code code Code code
source code syntax tree Generation Optimization
syntax
Lexical tokens Syntax tree Check
Analysis Analysis Selection diagram
Diagram data Diagram
[if reverse-
eng.] syntax Generation Display
tree
(a) IDE analysis model
IDE Main
syntax tree
syntax tree
Parser Transaction
Checker
tokens syntax tree [if compile] [if reverse-eng]
tokens syntax tree syntax tree
Lexical Syntax
Code Diagram
Analyzer Analyzer
Generator Generator
source code
executable code diagram data
Source
Code Diagram
Reader
Optimizer Displayer
(b) Main program and subroutines architectural design for the IDE
Component 1
events instructions
instructions events
Component 2 State-Based Component 4
events Controller instructions
instructions events
Component 3
diagram for the IDE described above. The main program and subroutines architec-
tural design for the IDE is shown in Figure 6.7(b), where only one diagram generator
and diagram displayer are depicted.
state transition
event instruction state point to initial state
(event/instruction)
integrated circuit (IC) chip. The IC chip has input pins and output pins. The input
pins are connected to the AC unit switch and room temperature sensor. The output
pins are connected to the fan and condenser. Each pin represents one bit; its value is
determined by the voltage, for example, high is 1 and low is 0. By reading and setting
the pins of the IC chip, the software receives the incoming events or data and controls
the fan and condenser. For example, to start the condenser, a designated pin is set to
1; to stop the condenser, the pin is set to 0.
Each time the AC unit switch is pressed, the software changes state from AC
Off to AC On and vice versa. That is, the switch toggles on and off. The software
also issues the corresponding on/off and start/stop commands to control the fan and
the condenser. In the AC On state, the temperature status from the room temperature
sensor is used by the software to start or stop the condenser. If the software is in the
Fan Only state and the room temperature is hot, the software changes to the Cooling
state and at the same time starts the condenser. If it is already in the Cooling state,
then the isHot event is ignored. The other transitions can be interpreted similarly.
Neither the N-tier architecture nor the client-server architecture is an appropriate
architectural design solution for the control problem discussed above. The reason is
that the problem and the software are event driven and state dependent. For instance,
it would be difficult for the N-tier to handle the on/off events from the AC unit
switch because the N-tier architectural styles does not remember the previous state.
It does not know what is the next state. One could add a state variable. But doing so
changes the architecture. It is no longer an N-tier. In the client-server architecture,
the clients know the server but the server does not know the client. If it is used as the
architecture for the window AC, then when the room temperature sensor triggers a
state transition, it would not know to which device to send the control command. The
AC control software can ignore an event if it is not in an appropriate state. However,
each layer of the N-tier and the server of the client-server architecture must respond
to every request they receive. They do not know which event should be processed and
which one should be ignored—they must process every request.
Business DB 1
DB Manager DB Access 1
Object A
It is responsible for
Business storing and retrieving DB 2
DB Access 2
Object B objects from different
databases. It hides the
different databases
Business from the business DB 3
Object C objects. DB Access 3
from the business objects to the database access objects, which communicate with
the different types of databases from different vendors. This greatly simplifies the
design, implementation, testing, and maintenance of the business objects.
To reap the benefits of the software architecture for the development activities, the
team needs a way to organize the software artifacts that are produced during the devel-
opment process. The UML package diagram provides a mechanism to achieve this.
The notions and notations of a UML package diagram are shown in Figure 6.11(a).
•
To illustrate, suppose that a library information system is designed to use the N-tier EXAMPLE 6.1
architecture. The four layers of the architecture are as described in point 2 above:
the presentation layer, the business objects layer, the database layer, and the net-
work layer. The corresponding package diagram is displayed in Figure 6.11(b). The
diagram shows that the library information system has four packages, each corre-
sponding to a layer in the architecture. The GUI package owns four classes: Main,
Main Frame, Checkout Dialog, and Return Dialog. Among these, the first two are
public classes while the last two are private classes. The business package owns five
classes: Checkout Controller, Return Controller, Loan, Document, and Patron. The
first two are public and the last three are private. The GUI package imports the busi-
ness package. This means the public classes of the business package—not the pri-
vate classes— are imported. The database package owns only one class—Database
Manager—which is imported to the business package. The classes of a package can
be shown by using textual format or visual format. While the GUI, business, and
database packages show the package names in the folder tabs, the network package
shows its package name in the folder body. This is because the first three packages
show the package contents while the network package does not show the content.
•
160 Part II Analysis and Architectural Design
database
+ Database
Manager
architectural design. For example, functionally unrelated use cases are assigned to
a subsystem. In object-oriented programming, a class has low-functional cohesion
if it encapsulates many unrelated functions or methods. Such classes are difficult to
understand, test, and maintain. Another type of “bad program” exhibits the so-called
high-coupling problem. That is, functions of the program call each other in a rather
arbitrary manner, resulting in a rather complicated call graph. Clearly, such programs
are difficult to understand, test, and maintain. The same problem exists in architec-
tural design, and object design and implementation. That is, it is not uncommon to
see complex dependence relationships among subsystems, components, and objects.
Software design principles are proposed to solve these problems. This section presents
software design principles so they can be applied during the design process.
Definition 6.3 Software design principles are widely accepted guiding rules for
software design—correctly applying these principles can significantly improve
software quality.
Software design principles are collective wisdom acquired and validated by the
software engineering community during decades of software research and develop-
ment (R&D). They are valuable assets of the community. The next several sections
are devoted to the study of software design principles including design for change,
separation of concerns, information hiding, high cohesion, low coupling, and keep it
simple and stupid (KISS).
A good design, if implemented accordingly, should yield a system that can adapt
to change, or can be changed easily. Design for change means that the software
design should come with a “built-in mechanism” to adapt to, or facilitate anticipated
change. Here, software design includes all types of design, such as architectural
design, component design, module design, object design, and program design.
In Section 6.2, the Ontologies story is presented to illustrate the importance
of architectural design. Viewing from a different angle, the story also shows the
importance of design for change. That is, if the team had applied the design for
change principle and implemented the database wrapper, the project would have been
saved. Another design for change story is the following. Many years ago, the author
was given a contract to design and implement a web-based commercial product. At
the outset, the customer representative demanded that the product would exclusively
use the LDAP database. LDAP stands for Lightweight Directory Access Protocol—
a hierarchical database that is very efficient for data retrieval. It is widely used for
web-based applications.
The design for change principle advised us that LDAP should not be the only
database choice for the commercial product. Customers of the product should have
the choice to use other types of database management systems (DBMS). The DBMS
should be transparent. Therefore, patterns are applied to hide the database from the
business objects and support other DBMSs. However, the customer representative
rejected the design, citing that it was not needed and not efficient. Several months
later, the first prototype was delivered and the company’s salespersons began to market
the product. Despite the fact that the potential customers liked the innovative features,
the product did not sell. Many potential customers had never heard of LDAP and did
not want to risk the hassle and financial burden to introduce yet another database. The
customer representative came back and required the product to support all DBMSs in
the market. He thought that the rework would cost a fortune. When he knew that the
product had been designed and implemented to support multiple DBMS, he was very
pleased. Many years have passed, the product is still on the market. Its architecture
does not require much change.
Applying the design for change principle means the design of the software archi-
tecture should consider anticipated changes and include mechanisms to accommodate
such changes. In the above example, it was anticipated that the product would have to
support other types of DBMS, not just LDAP. Therefore, the design of the architecture
included a database manager to facilitate such a change. No rework was necessary
when the product was required to support other types of DBMS.
application or system. For example, the UML class diagram is concerned with the
modeling and design of the structural aspect. The sequence diagram is concerned
with object interaction modeling and design. The use case diagram is concerned with
use cases and their contexts.
Software design is a problem-solving activity. With respect to separation of con-
cerns, it needs to consider the software design problem at two levels. At the higher
level, the problem is concerned with how to proceed with the overall design process.
At the lower level, the problem is concerned with how to design the individual com-
ponents of the software system. In other words, software design is concerned with
both the design process and the design product. Separation of concerns is a guiding
principle for solving the design problem at both levels. With respect to the overall
design process, separation of concerns tells us that the design should focus on one
aspect of the overall design process in isolation and temporarily ignore the other as-
pects. Consider, for example, the methodology described in this book. Separation of
concerns is reflected in the steps of the methodology, that is, each step focuses on one
aspect of the design process. The expanded use case is concerned with the modeling
and design of the actor-system interaction aspect. The high-level use case is concerned
with the specification of use case scope, or when and where a use case begins and
when it ends. Domain modeling is concerned with the acquisition and modeling of
application domain knowledge. Object interaction modeling is concerned with how
objects collaborate to carry out a business process.
With respect to the design of individual components, separation of concerns tells
us that each component should focus on one aspect of the subject matter. For example,
a GUI component should focus on presenting information to the end user. A database
component should focus on data storage and retrieval. The business objects should
focus on their respective business responsibilities. These are provided by the N-tier
architectural styles. As another example, each use case should model and implement
one and only one business process. Different business processes should be modeled
by different use cases. The use cases of a software system should be partitioned
according to their common core functionality and assigned to different subsystems.
These are example applications of the principle of separation of concerns.
Applying the separation of concerns principle to architectural design means that
the responsibilities of different concerns should be assigned to different subsystems.
This also leads to high functional cohesion and facilitates the understanding and reuse
of the subsystems. At the object design level, the principle suggests that responsibil-
ities of different concerns should be assigned to different objects. This is detailed in
Chapter 10 (Applying Responsibility-Assignment Patterns).
ripple effect of changes made to the data structures and the implementation of the
member functions. The introduction of the interface programming construct makes
information hiding even more attractive. An interface can be implemented by one
or more classes. A client will not know that there is more than one implementation
and which implementation is being used. This effectively realizes the benefits of the
information hiding principle.
Applying the information hiding principle to architectural design means design-
ing the software system to shield the implementation detail of parts of the system
from the rest of the system. Consider, for example, the design of a software system
that uses a database. The design for change principle suggests that the design should
take into consideration that the database management system may change. The design
should hide this implementation detail from the rest of the system. To accomplish
this, the design may use the bridge pattern (presented in Chapter 17) to hide the
implementation detail of which DBMS is being used.
Consider, as another example, the need to apply an algorithm to elements of a data
structure. The data structure could be a tree, a hash table, a linked list, or whatever.
It would be nice if the algorithm could be applied to process the elements without
needing to worry about the data structure that is used. The iterator pattern presented in
Chapter 16 fulfills this need. That is, a common interface providing functions needed
to traverse an aggregate is defined as follows:
• first(): This function sets the cursor to refer to the first element of the aggregate.
• next(): This function advances the cursor to the next available element.
• isDone(): boolean This function returns true if all elements of the aggregate are
visited.
• getElement(): Object This function returns the element referred to by the cursor.
Each concrete data structure such as tree, linked list, hash table, dictionary, and
the like, implements the interface to provide concrete functions for traversing the
concrete data structure. For example, a linked list would implement first() to set the
cursor to the first element in the linked list while a tree would set the cursor to the root.
The implementation of next() for a linked list would advance the cursor one element
while a tree would set it according to the type of tree traversal, for example, preorder,
postorder, and inorder traversals. In this way, the concrete data structure to organize
the elements and the implementation detail to traverse the data structure are hidden
from whatever software client visits the elements of the aggregate.
the modules should strive to achieve a higher degree of relevance of the functions of
a module to the module’s core functionality. Applying the high cohesion principle to
architectural design means that the components or object classes of each subsystem
should have a high degree of relevance to the core functionality of the subsystem.
performance, and the like. Similarly, the architectural design should be checked
with respect to design principles to ensure that desired design principles are
followed.
5. Iterate the steps if needed. Architectural design has significant, long-lasting im-
pact to software productivity and quality. The design process is a cognitive pro-
cess. Therefore, it is worth the time to iterate the steps a few times to produce a
good design.
The architecture evolves during the iterations as feedback and changes are incor-
porated into the system. Although architectural design is important, overdocumenting
the architecture must be avoided. Comprehensive documentation consumes valuable
time and resources and pushes back the implementation activity. Often, the most ap-
propriate architecture for the system is discovered during implementation. During this
actual problem-solving process, the team increases its understanding of the problem
and refines the solution. This in many cases changes or refines the architecture. There-
fore, valuing working software over comprehensive documentation can improve the
architectural design.
GUIDELINE 6.2 Apply the 20/80 rule---that is, good enough is enough.
SUMMARY
•
This chapter presents the architectural design process merits and limitations. The architectural styles include
and the importance of architectural design. The chap- the N-tier, client-server, main program and subrou-
ter also presents in detail four types of systems and tines, event-driven, persistence framework, and other
their characteristics. These are interactive systems, architectural styles. Also presented is the choice of
event-driven systems, transformational systems, and an architectural style according to the type of system
persistence storage systems. A software system may and/or subsystem under development. Software de-
include one or more of these systems as its subsys- sign principles are presented in this chapter. These
tems. The design methods or techniques are differ- include design for change, separation of concerns, in-
ent for different types of systems. In this chapter, the formation hiding, high cohesion, low coupling, and
implication of type of system to the choice of de- keep it simple and stupid. Software design principles
sign methods is discussed. This chapter also presents guide the entire design process, not just architectural
different software architectural styles and their design.
FURTHER READING
•
The book by Taylor et al. [148] is an excellent read for architectural design. The book by Clement et al. [48] focuses
software architectural design. It presents the analysis and on documenting an architecture for others to use, maintain,
design activities as well as a structured description of the and build a system based on the architecture. References
various architectural styles. In [18], Bass, Clements, and [7, 153] present methods for checking that the code matches
Kazman introduce the concepts of software architecture and the architectural design. The book by Gamma et al. [67]
best practices. The book considers the business context in is the classical book on software design patterns. It presents
Chapter 6 Architectural Design 169
23 well-known patterns. Larman [104] presents these pat- books by Booch, Jacobson, and Rumbaugh [36, 91, 132]
terns as well as nine GRASP patterns. (GRASP stands for present UML and the Unified Process, which include archi-
general responsibility assignment software patterns.) The tectural design activity.
EXERCISES
•
6.1 Construct a table with rows corresponding to the ar- c. Specify the functionality and interface for each of
chitectural styles in Figure 6.3, and columns corre- the subsystems and components in the architec-
sponding to the design principles presented in this tural design.
chapter. Fill in the entries to show which architec- d. Discuss which software design principles are ap-
tural styles apply which design principles. plied in the design, how they are applied, and the
6.2 For each architectural style listed in the previous ex- benefits of applying each of the principles. Also
ercise, briefly explain how it applies the design prin- point out the potential problems associated with
ciples and what are the benefits. the application of the design principles, if any.
6.3 In exercise 4.4, you produced the software require- 6.5 Consider the Airport Baggage Handling System dis-
ments specification (SRS) for a calendar manage- cussed in Chapter 3. The conveyor subsystem em-
ment system. In this exercise, do the following: ploys bar-code scanners and pushers to guide the
a. Identify the type of system and briefly justify your pieces of luggage to travel toward their destinations
answer. on the conveyor belts. There is a software subsystem
b. Produce an architectural design for the system. that works with these two types of devices. Deter-
c. Specify the functionality and interface for each of mine the type of this subsystem. Note that the subsys-
the subsystems and components in the architec- tem may involve more than one type of subsystem.
tural design. Select the architectural style(s) to apply. Also pro-
d. Discuss which software design principles are ap- duce a sketch of the architectural design and specify
plied, how they are applied, and the benefits of the functionality for each of the subsystems and com-
each of the principles. Also indicate the potential ponents.
problems, if any. 6.6 In exercise 4.5 you produced the SRS for the web-
6.4 Do the following for the Study Abroad Management based multiple-room reservation system. In this exer-
System (SAMS) presented in Chapter 4. cise, you are required to identify the type of system
a. Identify the type of system and briefly justify your and sketch an architectural design for the system.
answer. Also briefly specify the functionality for each of the
b. Identify an architectural style and produce an subsystems and components in the architectural
architectural design for the system. design.
This page intentionally left blank
part III
Modeling and Design of
Interactive Systems
Chapter 7 Deriving Use Cases from Requirements 172
Chapter 8 Actor-System Interaction Modeling 200
Chapter 9 Object Interaction Modeling 216
Chapter 10 Applying Responsibility-Assignment
Patterns 251
Chapter 11 Deriving a Design Class Diagram 276
Chapter 12 User Interface Design 293
171
7
Deriving Use Cases from
Requirements
Chapter 4 presents methods and techniques for requirements acquisition and spec-
ification. Requirements are capabilities that the system must deliver. Requirement
statements are declarative sentences that state what capabilities the system must de-
liver, not how the system will deliver them. This gives the developer the freedom to
design and implement the best software solution. However, due to the lack of business
insight and domain knowledge, the best software solution from the developer’s point
of view may not meet the users’ expectations.
“Use case” offers a solution to this problem. Consider, for example, a library
information system (LIS). One requirement may state that the LIS must allow a
patron to check out documents. A use case derived from this requirement specifies
how the system will interact with the patron to deliver the capability. In addition to this
actor-system interaction part, a use case also involves a background processing part.
For example, to check out a document, a Loan object must be created and saved in
the database. The Document object and the Patron object must be updated and saved
back to the database. Actor-system interaction modeling and design are presented in
Chapter 8 and background processing or object interaction modeling is presented in
Chapter 9. In this chapter, you will learn:
172
Chapter 7 Deriving Use Cases from Requirements 173
This definition indicates that an actor is a role played by some entities, not the
entities themselves. The distinction is useful when an entity plays two or more roles
at the same time. For example, a librarian checks out a book and handles the checkout
transaction. Here, the person plays two roles, a librarian role as well as a patron role.
Definition 7.2 A use case is a business process. It begins with an actor, ends with
the actor, and accomplishes a business task for the actor.
Balance business process ends with the ATM customer pressing the OK but-
ton to confirm seeing the expected balance.
4. A use case must accomplish a business task for the actor. For example, Withdraw
Money lets the ATM customer withdraw money from her or his account.
The above discussion indicates that Deposit Money, Withdraw Money, Check
Balance, and Transfer Money possess the four attributes of a use case; therefore, they
are use cases for the ATM application.
•
EXAMPLE 7.1 Consider the design and implementation of a graphical editor for drawing UML
class diagrams. The editor allows the user to create new diagrams, save diagrams,
delete diagrams, and edit diagrams. What are the use cases for the editor? ∨
Chapter 7 Deriving Use Cases from Requirements 175
To edit a class diagram, the user may add, update, or delete classes or rela-
tionships. These must not be identified as use cases because they are not business
processes; rather, they are operations of the Edit Class Diagram use case.
•
Referring to Example 7.1, what are the actions that need to be performed to add a EXAMPLE 7.2
class to a class diagram?
Solution: To add a class to a class diagram, the following actions are performed:
1. The user right-clicks in a clear area of the drawing area (called the canvas).
2. The system shows a pop-up menu that includes Add Class as one of the
options.
3. The user selects the Add Class option.
4. The system shows a dialog box for the user to enter information about the
class to be added.
5. The user enters the information and clicks the OK button.
6. The system verifies the information entered and draws the class (or displays
an error message).
•
176 Part III Modeling and Design of Interactive Systems
This example shows that an operation (e.g., adding a class) consists of a series of
actions. Figure 7.1 shows examples of use cases, and related operations and actions.
high-level
use cases
use cases
Requirements (2) Specifying use
Elicitation case scopes
(Chapter 4)
use case
diagrams
(3) Visualizing use
requirements
case contexts
(1) Identifying
use cases (4) Reviewing the
use case diagrams Actor-System
Interaction
(5) Allocating the use cases Modeling
to iterations (Chapter 8)
requirement-use
case traceability use case
matrix diagrams
use case-iteration
allocation matrix
The team members also identify the actors and the systems/subsystems while the
use cases are identified. To identify the actors, look for or infer nouns and noun phrases
that represent business roles played by external entities that initiate the use case, or
for which the business task is performed. To identify the systems or subsystems
that contain the use cases, look for or infer nouns and noun phrases that represent
systems, subsystems, or aspects of the business to which the use cases belong. Note
that the requirements may not always show explicitly, exactly, or literally a verb-noun
phrase. For example, “startup system” and “shutdown system” are often abbreviated
to “startup” and “shutdown” in requirements specification documents. In some cases,
the team may need to infer the business processes from the requirements and then
derive the use cases. Fortunately, if the requirements specification is written properly,
then the derivation of use cases is not difficult.
•
EXAMPLE 7.3 Derive use cases from the following requirements of a library information system
(LIS):
R1. The LIS must allow a patron to check out documents.
R2. The LIS must allow a patron to return documents.
Solution: Figure 7.3 shows how use cases, actors, and subsystems are identified,
where the dog-eared notes are UML notation for comments. The decision table
in Figure 7.3 illustrates how to determine whether a verb-noun phrase is a use
case. It helps the team members determine if a verb-noun phrase is a use case. For
example, it indicates that “Checkout Document” and “Return Document” are use
cases because the answers to the four questions are positive. “Allow a Patron”
∨ is not a use case because all of the answers are no and one negative answer is
sufficient to conclude that it is not a use case. Thus, the above two requirements
produce the following use cases, actors, and subsystems:
UC1. Checkout Document (Actor: Patron, System: LIS)
UC2. Return Document (Actor: Patron, System: LIS)
•
•
The Office of International Education (OIE) of a university wants to develop a EXAMPLE 7.4
web-based Study Abroad Management System (SAMS). The following are three
of the functional requirements:
R1 SAMS must provide a search capability for overseas exchange programs
using a variety of search criteria.
R2 SAMS must provide a hierarchical display of the search results to facilitate
navigation from a high-level summary to details about an overseas exchange
program.
R3 SAMS must allow students to submit online applications for overseas
exchange programs.
Identify use cases, actors, and subsystems from these functional requirements.
Solution: Figure 7.4 shows how use cases, actors, and subsystems are identified.
One cannot literally identify the actors from R1 and R2. In this case, the require-
ments are examined carefully to infer the actors. It seems that every web user can
use the search and view program detail functions, therefore, the actors for these
two use cases are web users, which include students as well as OIE staff. From R3,
one can identify Student as the actor for the Submit Online Application use case.
actor
In summary, the use cases derived from the above requirements are:
UC1. Search for Programs (Actor: Web User, System: SAMS)
∨
UC2. Display Program Detail (Actor: Web User, System: SAMS)
UC3. Submit Online Application (Actor: Student, System: SAMS)
This example illustrates that not every requirement clearly and literally shows the
verb-noun phrase that indicates a use case, the actor, or the system; inference is
required to derive them from the context. Note that “provide search capability”
and “facilitate user” are not use cases because the answers to the four questions
are not yes.
•
•
EXAMPLE 7.5 Which of the following are not use cases and why?
1. Press the Submit Button
2. Search a Linked List
3. Process Data
4. Query Data Base
5. Startup System
Solution: As listed, SAMS has 25 use cases. These use cases are not closely related.
Therefore, the functional cohesion of the system is low. The use case diagram that
displays all these use cases will appear very complex and difficult to comprehend.
Role-based partition is applied to partition the use cases. This results in Figure 7.5.
•
•
EXAMPLE 7.7 Partition the following use cases
UC1: New Project (Actor: User, System: GED)
UC2: Edit Project (Actor: User, System: GED)
UC3: Open Project (Actor: User, System: GED)
UC4: Close Project (Actor: User, System: GED)
UC5: Delete Project (Actor: User, System: GED)
UC6: Edit New Diagram (Actor: User, System: GED)
UC7: Edit Existing Diagram (Actor: User, Syste: GED)
∨
Chapter 7 Deriving Use Cases from Requirements 183
∨ Solution: The subsystem and actor components of these use cases are the same.
Applying communicational partition produces two partitions as displayed in
Figure 7.6.
•
Requirement Priority UC1 UC2 UC3 UC4 UC5 UC6 UC7 UC8
R01 1 x
R02 4 x x x
R03 3 x
R04 5 x x
R05 5 x x x
R06 1 x
R07 2 x
R08 4 x x x
R09 5 x x
R10 3 x
UC Priority 1 4 1 2 3 5 4 3
support multiple database management systems (DBMS). Then the fact that Search
for Programs must access a database is relevant to this requirement. In this case, the
corresponding entry in the RUTM is checked.
The RUTM has a number of merits. It can be used to identify use cases that
realize a given requirement. It can also be used to identify requirements that are
realized by a given use case. This bidirectional traceability offers three advantages.
First, it ensures that each requirement will be delivered by some use cases (i.e., there
are no blank rows). It is easy to verify whether the use cases satisfy the requirement,
that is, whether some use cases are missing. Second, it ensures that all the use cases
are required (i.e., there are no blank columns). Finally, it ensures that high-priority
use cases are developed and deployed as early as possible.
Often, we as developers like to implement nice features or use cases that are not
required. We think that the customer would love to have them for free. Unfortunately,
most customers do not think so because the extra features and use cases incur un-
necessary learning curves. I have encountered cases where the customers explicitly
requested that these be dropped because they do not need them and would never use
them. The traceability matrix helps us identify such use cases.
begin? And when does the use case end? A high-level use case provides the answers:
Definition 7.6 A high-level use case specifies when and where a use case begins
and when it ends. In other words, it specifies the use case scope.
The specification of use case scopes in effect defines the stopping rule. For each
use case, three decisions are made:
1. When does the use case begin? That is, what is the actor action that causes a
stimulus or a system event to be generated and delivered to the software system
being developed? For example, an ATM user inserts an ATM card, a SAMS user
clicks the “Search for Programs” link, or a caller picks up the handset.
2. Where does the actor action take place? For example, a SAMS user clicks the
“Search for Programs” link on the SAMS home page. If the SAMS home page is
not specified, then the SAMS user would not know where to find the “Search for
Programs” link. The programmer would not know where to include the search link.
3. When does the use case end? This involves the specification of explicit or implicit
actor action to acknowledge the completion of the use case. For example, the caller
hears the ring tone when the Initiate Call use case ends successfully. The web user
sees a listing of overseas exchange programs when Search for Programs use case
completes. As an example that requires an explicit actor action, consider an ATM
application. The ATM customer may be required to press the OK button to confirm
seeing a “transaction completed successfully” message.
Use case scopes are specified in two declarative sentences:
1. The first sentence is formulated as “this use case begins with (TUCBW)” followed
by the actor performing the actor action and where the actor action takes place.
Always use third-person, simple present tense.
2. The second sentence is formulated as “this use case ends with (TUCEW)” followed
by the actor explicitly or implicitly acknowledging that the use case accomplishes
the intended business task (for the actor). Again, always use third-person, simple
present tense.
•
Specify high-level use cases for (1) Search for Programs, and (2) Display Program EXAMPLE 7.8
Detail for the SAMS web-based application.
Solution: The high-level use cases are:
UC1. Search for Programs
TUCBW a web user clicks the “Search for Programs” link on the SAMS home
page.
TUCEW the web user sees a tabular listing of programs satisfying her or his
search criteria.
UC2. Display Program Detail
TUCBW a web user clicks the “view detail” link of a program in the tabular
listing of programs.
TUCEW the web user is shown the program detail for the selected program.
•
186 Part III Modeling and Design of Interactive Systems
•
EXAMPLE 7.9 Specify high-level use cases for (1) Initiate Call, and (2) Receive Call use cases
of a telephone system.
Solution: The high-level use cases are:
UC1. Initiate Call
TUCBW the caller picks up the handset from the phone base.
TUCEW the caller hears the ring tone.
UC2. Receive Call
TUCBW the callee (hears the ring tone and) picks up the handset from the
phone base.
TUCEW either the caller or the callee puts the handset on hook.
•
Definition 7.7 A use case diagram is a UML behavioral diagram that depicts
the following:
• Use cases of a system or subsystem.
• Actors that use the use cases.
• The system or subsystem boundary.
• Inheritance relationships between actors.
• Relationships between use cases.
Figure 7.8 shows a use case diagram for an ATM application. The use case
diagram says that the ATM has four use cases. The actor of these use cases is the
ATM Customer. The ATM Customer uses these use cases to accomplish four business
tasks: Check Balance, Deposit Money, Withdraw Money, and Transfer Money.
•
EXAMPLE 7.10 Depict use case diagrams for the use cases of the web-based SAMS in
Example 7.4.
Solution: The use cases, actors, and subsystems are already identified in
Example 7.4. It is relatively easy to convert these into a use case diagram, as
shown in Figure 7.10.
SAMS
Display Program
Detail
Student Web User
Submit Online
Application
Definition 7.8 Inheritance is a binary relation between two concepts such that
one concept is a generalization (or specialization) of the other.
The inheritance relationship is also called IS-A relationship because every in-
stance of the specialized concept is an instance of the generalized concept. Steps for
identifying inheritance relationships are presented in domain modeling in Chapter 5.
Exploring the inheritance relationships between actors can simplify a use case
diagram. Figure 7.11(a) is a use case diagram without using actor inheritance and
Figure 7.11(b) uses actor inheritance.
SAMS SAMS
OIE Staff
(a) Use case diagram without using (b) Use case diagram using actor
actor inheritance inheritance
Funds Management
Deposit
Funds
Deposit w/ Deposit Deposit w/a
Wire Transfer w/e Bank Check
Withdraw
Investor Funds
SAMS
Security Management
Reset Password
Login
<<include>>
Logout
Note that in these cases, the student may continue with Display Program Detail
after Search for Programs, but the student is not required to do so. Similarly, the
student may choose not to continue with the Submit Online Application use case after
viewing the program detail. That is, the extend relationship cannot be used to express
that the execution of one use case requires prior execution of another use case.
A business process may include another business process. So may use cases.
Consider, for example, a Login use case and a Change Password use case. If a user
logs in with a temporary password that is received from email, then the user is required
to change the temporary password. In this case, the Login use case (conditionally)
includes the Change Password use case as shown in Figure 7.14.
2. The dependencies among the use cases. If use case B depends on use case A,
then B must not be deployed before A because the users won’t be able to use B
without A.
3. The team's ability to develop and deploy the use cases. The effort required by
the use cases allocated to an iteration must not exceed the ability of the team to
develop and deploy them.
Figure 7.15 shows a sample schedule, called use case to iteration allocation
matrix. The rows are the use cases and the columns are the iterations. The entries
show the effort distribution of the use cases to the iterations. Care should be given
to ensure that the sum of the efforts of each column must not exceed the ability of
the team, which is nine person-weeks in this example. The sum of the efforts of each
row must not be less than the required effort to develop and deploy the use case. The
dependencies and the priorities of the use cases are satisfied.
GUIDELINE 7.1 Use cases should be derived from and satisfy functional
requirements.
GUIDELINE 7.2 Use cases may also be derived from nonfunctional requirements
(e.g., security requirements).
GUIDELINE 7.4 High-level use case specifications should end with what the actor
wants to accomplish.
Guideline 7.3 and Guideline 7.4 let the development team focus on the design,
implementation, and testing of use cases that will accomplish what the actors expect.
GUIDELINE 7.5 A use case should accomplish exactly one business task for the
actor (functional cohesion).
For example, “Login and Place Trade” should be two use cases: Login and Place
Trade. Similarly, “Check Balance and Inventory” should be Check Balance and Check
Inventory.
GUIDELINE 7.6 High-level use cases should not specify background processing
activities.
Figure 7.16 shows an overly complex use case diagram that should be avoided.
GUIDELINE 7.8 Carefully partition the use cases into groups of use cases that are
closely related.
See Section 7.4.1 for some partition techniques. As an example, applying role-
based partition to the diagram in Figure 7.16 produces the diagram in Figure 7.17.
This significantly reduces the complexity of the use case diagrams while at the same
time improving the functional cohesion of the subsystems.
GUIDELINE 7.9 Show only use cases and actors that are relevant to a subsystem
or aspect.
GUIDELINE 7.10 Provide a meaningful name for each subsystem based on the
subsystem’s functionality.
194 Part III Modeling and Design of Interactive Systems
SAMS
Set Pref.
Upload Program
Search for Approve
Programs Eq. Form Add Program
Display List
Admin Update Staff
Detail Applications Program
Submit Create
Application Delete
User Acct Program
Web User Log On Delete
User Acct Check Student
Status
Log Off
Update Request
Edit Application User Acct Recommend.
Advisor
Startup Faculty
Edit Sys
Submit
Settings
Shutdown Recommend.
Login Login
Delete Program
Delete Program
SAMS SAMS DB
Staff Edit Program Staff
Edit Program
Logout
Login
GUIDELINE 7.11 Use actor inheritance to reduce the number of actor-use case
links in a use case diagram (as illustrated in Figure 7.11).
GUIDELINE 7.13 Only use cases and their relationships can be shown within the
system boundary.
Figure 7.18 shows two incorrect use case diagrams. One of the diagrams places
the actor inside the system boundary and the other includes a database inside the
system boundary.
GUIDELINE 7.14 Work closely with the customer and users to understand their
business processes and priorities and help them identify their real needs.
Use cases are business processes. Only the customer and users know the business
processes, how they work, and their priorities. Therefore, the development team needs
to work closely with the customer and users to identify and validate the use cases.
GUIDELINE 7.15 The team members should work together to identify use cases,
actors, and subsystems, and specify the use case scopes.
196 Part III Modeling and Design of Interactive Systems
The process to derive and specify use cases is not for the sake of documentation.
Through the process, the team members understand and communicate their under-
standing about the business processes. This provides the basis for the components
developed by the team members to work with each other. This is one of the reasons
that agile approaches value individuals and interaction. Dividing the work without
working together to identify and specify the use cases could produce poor results in
subsequent phases.
Agile development tends to use a fixed timescale for the iterations. This makes
it easier for the team members to work with the iterations. For example, after a few
iterations, the team members would know how much can be done in one iteration.
Thus, the team would move forward with a constant speed. If the iteration cannot
complete all the features, then take out low-priority features or move them to the next
iteration after consulting with the customer and users.
This increases the visibility. That is, it is easy to decide how much can be done
in two weeks than how much can be done in six months. Moreover, frequent deliv-
ery of small increments reduces the risk of requirements misconception. It supports
continuous testing by users and reduces users’ learning curve.
GUIDELINE 7.18 Do not attempt to derive an optimal set of use cases. Good
enough is enough.
First, there is no optimal set of use cases because the criteria cannot be defined.
Moreover, requirements change all the time. This means the use cases ought to change.
Therefore, it is sufficient to identify and specify most of the high-priority requirements
and use cases. It is more important to move on to implementing the use cases and
solicit users’ feedback. That is, good enough is enough.
The engineer clicks Derive Use Case button to identify each use case. The engineer highlights the actor, verb-noun phrase
and system, and clicks the corresponding button to enter the use case. The tool displays a confirmation message. If the
engineer selects yes then the use case appears in the table in the lower pane. The engineer clicks the Generate Diagram
button to show the use case diagram.
presented at the end of the domain modeling chapter (Chapter 5). That is, it guides
the software engineer to identify the verb-noun phrases that are potential use cases.
It asks the software engineer to verify that the use case satisfies the four properties—
it must be a business process, it must begin with an actor, end with the actor, and
accomplish a business task for the actor. In addition, the tool also guides the software
engineer to identify the actors and systems for the use cases. The engineer may edit the
use cases during the process. Once the use cases are identified, the software engineer
clicks the Generate Diagram button, the tool computes the graph layout and draws
the use case diagrams automatically.
The tool works in four modes like the domain modeling tool. In the manual iden-
tification and manual classification mode, the software engineer manually identifies
the use cases, actors, and systems. The tool draws the use case diagrams automati-
cally. Figure 7.19 shows how this works. After reading in the requirements specifica-
tion texts, the engineer clicks the Derive Use Case button, highlights the verb-noun
phrase, actor, and system, respectively, and clicks the corresponding buttons to clas-
sify them. The tool displays a message asking the engineer to confirm that the use
case satisfies the four properties of a use case. If the engineer clicks yes, then the
use case appears in the table in the lower pane. The engineer clicks the Generate
Diagram button to display the use case diagram. In the automatic identification and
automatic classification mode, the tool does all these automatically. Figure 7.20 il-
lustrates how it works.
198 Part III Modeling and Design of Interactive Systems
SUMMARY
•
This chapter presents how to identify use cases, ac- level use cases specify use case scopes or when and
tors, and subsystems from requirements, and record where a use case begins and when it ends. The use
the relationships in a requirements-use case traceabil- cases, actors, and subsystems as well as the relation-
ity matrix (RUTM). The RUTM also shows the prior- ships between them are visualized using UML use
ities of the requirements and use cases. These are used case diagrams. This chapter signals the completion
to generate an iteration schedule so high-priority use of the planning phase. In the iterative phase, the use
cases are developed and deployed as early as possi- cases are developed and deployed according to the
ble. The allocation of the use cases to the iterations is schedule of the iterations.
shown in a use case-iteration allocation matrix. High-
FURTHER READING
•
The notion of a use case was introduced by Ivar Jacob- case writing. Instances of use cases were referred to by other
son in his use case engineering approach [90]. The unified authors as scenarios [104, 131]. Reference [131] describes
process for use case modeling is described in [91]. Alistair informally how to prepare scenarios using an ATM example.
Cockburn [49] provides a comprehensive treatment of use Reference [104] informally defines a scenario as an instance
Chapter 7 Deriving Use Cases from Requirements 199
of a use case and a specific sequence of actions and interac- hensive presentation at www.omg.org. Finally, Bittner and
tions between actors and the system. A concise presentation Spence present a use case modeling approach with real-life
of use case diagram can be found in [36] and a compre- examples in [29].
EXERCISES
•
7.1 You produced a requirements specification for a d. Apply the use case partition rules if necessary to
desktop virtual calculator, a telephone answering ma- reduce the number of use cases allocated to each
chine, and a web-based online email system in exer- subsystem.
cise 4.2. Derive use cases, related actors, and systems 7.4 Do the following for the Car Rental System (CRS)
for each of these applications. Also specify the high- given in Appendix D.1:
level use cases and draw use case diagrams for the use a. Derive use cases from the requirements you pro-
cases. duced in exercise 4.8.
7.2 Derive use cases from the functional requirements b. Construct a requirements-use case traceability
for the calendar management system you produced matrix.
in exercise 4.4. Also specify the high-level use c. Specify the high-level use cases.
cases. d. Draw use case diagrams.
7.3 For the National Trade Show Services (NTSS) 7.5 Formulate your functional requirements for a use
requirements specification you produced in exer- case modeling tool that implements the methodol-
cise 4.6, do the following: ogy described in this chapter. Limit the specification
a. Derive use cases from the requirements specifica- to no more than a couple of pages. Derive the use
tion. cases, specify the high-level use cases, and produce
b. Specify the high-level use cases. the use case diagrams. Review these using the review
c. Draw use case diagrams. checklist and produce a review report.
8
Actor-System
Interaction Modeling
Chapter 7 presented how to derive the use cases from the requirements and how to
specify the scope of each use case. The results are referred to as abstract use cases and
high-level use cases. A use case is a business process. It begins with an actor, ends
with the actor, and accomplishes a business task for the actor. To do this the system
must interact with the actor to carry out the use case. This interaction is called actor-
system interaction. Modeling and design of this interaction behavior are called the
modeling and design of the actor-system interaction behavior. This chapter focuses
on the modeling and design of such behavior. As mentioned in previous chapters, use
cases are modeled with three levels of abstraction:
1. Abstract Use Case. An abstract use case is a verb-noun phrase that highlights
what the use case will accomplish for the actor.
2. High-Level Use Case. A high-level use case consists of a TUCBW-clause that
specifies when and where a use case begins and a TUCEW-clause that specifies
when it ends. TUCBW and TUCEW stand for “this use case begins with” and
“this use case ends with,” respectively. In other words, a high-level use case
specifies the scope of the use case.
3. Expanded Use Case. An expanded use case specifies how an actor will interact
with the system/subsystem. It is a continuation and refinement of the high-level
use case. It specifies the interaction using a two-column table. The left column
specifies the actor input and/or actor actions and the right column specifies the
system responses.
200
Chapter 8 Actor-System Interaction Modeling 201
For simplicity, abstract use cases are referred to as use cases in this book. Abstract
use cases and high-level use cases were described in Chapter 7 (Deriving Use Cases
from Requirements). This chapter presents expanded use case specification. When
you complete this chapter, you will learn:
• Actor-system interaction modeling.
• The importance of actor-system interaction modeling.
• How to perform actor-system interaction modeling.
5. The patron clicks the OK button 6. The system (updates the database and)
When the use
case ends
to confirm the checkout. displays a confirmation message to
patron.
3. When and where to start the use case. Step 1 on the left column specifies when
and where the use case begins. This is the TUCBW clause of the high-level
use case.
4. The actor input and actor action at each step of the interaction. This is spec-
ified in the left column on each row of the two-column table.
5. The corresponding system response. This is specified in the right column on
the corresponding row of the two-column table.
6. When the use case ends. The last entry of the left column specifies when the
use case ends. This is the TUCEW clause of the high-level use case.
increase as more steps are inserted. Leave the first entry of the left column, that is,
the entry right beneath the left column header, blank. Next, infer the initial system
display according to the TUCBW clause of the use case and specify this in the first
entry of the right column. Label this step as step 0. Figure 8.2 show the result of this
step for a library information system (LIS). Note that main menu is referred to in the
TUCBW clause in step 1, therefore, step 0 is “0. The LIS displays the main menu.”
this. For example, program information is requested in step 4, the information is found
as attributes of the Program class in the domain model. Similarly, the attributes of the
Application association class in Figure 8.3(b) can be used in the specification of the
Apply Online expanded use case. If the domain concept is not found in the domain
model, then the domain model should be updated. If the domain concept is found but
the information is not complete, then its attribute list should be expanded.
1. Are there a use case ID and a use case name for the specification? Do they match
with the use case ID and name in the requirement-use case traceability matrix
and the corresponding high-level use case?
2. Are the actor and system correctly identified and specified, and match with the
their counterparts in the high-level use case?
3. Does the expanded use case specify the initial system display in step 0?
4. Are the TUCBW and TUCEW clauses matched with their counterparts in the
high-level use case?
5. Does the use case begin and end with the actor on the left column?
6. Are there blank entries during the course of interaction between the actor and the
system?
7. Does the expanded use case correctly and adequately specify the actor-system
interaction to carry out the business process?
8. Do the left-column steps clearly and correctly specify the actor input, and actor
actions such as clicking the OK button?
9. Do the right-column steps clearly and correctly specify the system responses to
the actor?
1. It is extremely helpful in obtaining customer and user feedback in the early stages
of the development life cycle.
2. Using UI prototypes in the expanded use case specification facilitates the prepa-
ration of the user’s manual.
3. Using UI prototypes helps in early preparation of use case–based test cases.
be reused when generating the preliminary user’s manual. Since UI exhibits are a
necessary component of a user’s manual, the construction of the UI prototype exhibits
does not necessarily introduce additional effort. As a matter of fact, producing the UI
prototype exhibits at expanded use case specification time could save development
effort because (1) early user feedback avoids rework, (2) the user’s manual preparation
effort is reduced, and (3) the effort to generate test cases is reduced. The expanded use
Chapter 8 Actor-System Interaction Modeling 207
case specifications that are augmented by UI prototype exhibits facilitate test case
generation because they visually describe the expected graphical user interfaces.
These are part of the test case descriptions. Test cases should be generated and run
to ensure that the system correctly displays the windows, dialogs, and computation
results. Testing is described in Chapter 20.
UC1: Login
Actor: User System: WebApp
0. WebApp displays homepage.
1. TUCBW user clicks the Login link on 2. WebApp displays the login page.
the homepage.
3. User enters user name and password 4a. If user logs in for the first time,
and clicks the Login button. TUCCW Reset Password;
4b. Else WebApp displays the
welcome page.
5. TUCEW user sees the welcome page.
FIGURE 8.10 Expanded use case that includes another use case
should see. Preconditions and postconditions are not always required but the initial
and final system displays are required for all expanded use cases.
FIGURE 8.12 Transfer funds with a check continues another use case
and lists the use cases. As an illustration of how this use case would continue with
one of the fund transfer use cases, Figure 8.12 shows the expanded use case for the
Transfer Funds with a Check use case.
The interaction between the actor and the system should be a continuous flow of
interactive requests and responses between the actor and the system, not intermittent,
as pointed out by notes (b) and (e). Note (c) indicates that the actor input and actor
action should be performed in one step, not two. Note (b) indicates that there is no
system response to the actor input and actor action. The actor would not know whether
the step is performed successfully and might wait indefinitely for the system response.
Steps 5 and 6 specify the background processing, which is not recommended in
expanded use case specifications. Background processing should be described during
object interaction modeling (see Chapter 9). On the other hand, these steps do not
specify the expected system displays. Finally, the expanded use case does not specify
the TUCEW clause, as indicated by note (g). The TUCEW clause should state what
the use case accomplishes for the actor. To fix these problems, step 4 should be merged
into step 3, steps 5 and 6 should be deleted, step 7 should be changed to become step 4,
and a TUCEW step should be added. It says “TUCEW student sees the ‘Registration
is successful . . . ’” message.
Other commonly seen problems are as follows:
• Specifying exception handling in expanded use cases.
• Missing actor input or actor action, as indicated by the blank entries in the left
column in Figure 8.13.
• Making the specification unnecessarily complex, as shown in Figure 8.14. It may
be simplified by combining steps 2 to 15 to one step, such as “3. User enters first
name, last name, email, phone number, user name, password, retype password
in the registration form, and clicks the Submit button.”
Chapter 8 Actor-System Interaction Modeling 213
An expanded use case should contain only a few steps. Moreover, each step should
be simple, clear, and straightforward. If an expanded use case has more than half a
dozen steps such as in Figure 8.14, then there are two possibilities. It is likely that
lower-level operations are treated as steps of the process. Another possibility is that
the use case is in fact a concatenation of two use cases. In these cases, the expanded use
case should be examined carefully to determine the appropriate improvement action.
That is, the expanded use case should hide the lower-level operations and show only
the steps of the business process. For example, steps 3–15 should be merged into one
step. If the use case has combined two or more consecutive business processes, then
the use case should be decomposed. For example, Purchase Item, and Make Payment
are sometimes combined into one. It should be two separate use cases.
An expanded use case with many alternative flows increases the complexity of
the actor-system interaction. It increases the users’ learning curve. It is more difficult
to understand, implement, test, and maintain. It is likely that the use case is not one
business process but several business processes combined. The alternative flows in
fact reflect the selections of the business processes. To determine this, try to produce
214 Part III Modeling and Design of Interactive Systems
Background processing and exception handling are not part of the actor-system
interaction behavior. Therefore, they should not appear in an expanded use case.
Leave background processing to object interaction modeling, and exception handling
to implementation.
SUMMARY
•
This chapter presents how to use expanded use cases to in another use case, and continuation with another use
model actor-system interaction and the steps for con- case. Commonly seen problems of expanded use case
structing expanded use cases. It also describes how specifications are discussed to help beginners avoid
to use user interface prototypes to facilitate solicita- such problems.
tion of user feedback. Preconditions are used to state The expanded use cases specify the foreground
implicit assumptions needed for the successful execu- processing of the business processes as they are car-
tion of use cases. Similarly, postconditions are used to ried out by the actors and the system. The background
specify the resulting state. The chapter presents how to processing of the business processes are purposely
specify the expanded use cases for different situations left out and assigned to Chapter 9 (Object Interaction
including alternative flows, inclusion of one use case Modeling).
FURTHER READING
•
Use case modeling is presented in [29, 30, 49, 90, 104]. use cases. However, the tabular format was used in earlier
In particular, a textual format is used to describe expanded versions of [104].
Chapter 8 Actor-System Interaction Modeling 215
EXERCISES
•
8.1 Write expanded use cases for the Deposit Money, cases for the online car rental application described
Withdraw Money, Check Balance, and Transfer in Appendix D.1.
Funds use cases of an automatic teller machine 8.5 In Appendix D.2, a National Trade Show Services
(ATM) application. (NTSS) business is described. In exercise 4.6 and
8.2 Write expanded use cases for the Edit Report use case exercise 7.3, you produced the requirements and de-
for a typical word processor. rived use cases for this application. Now write the
8.3 Write expanded use cases for the Make Payment use expanded use cases.
case of a retail business. Assume that the customer 8.6 Formulate several requirements for a state diagram
can Pay with Check, Pay with Credit Card, and Pay editor. Derive use cases from these requirements and
with Cash. produce the corresponding expanded use cases.
8.4 Write expanded use cases for the Search Car, Reserve
Car, Edit Reservation, and Cancel Reservation use
9
Object Interaction
Modeling
A use case is a business process. The business process is being automated by the
software system under construction. More precisely, the business process will be
carried out jointly by the actor and the system in two parts: the foreground actor-system
interaction part and the background system processing part. Chapter 8 presented how
to model and specify actor-system interaction using expanded use cases. This chapter
deals with modeling and specification of how objects interact with each other to carry
out the business processes. In this chapter, you will learn:
216
Chapter 9 Object Interaction Modeling 217
processes of the use cases. As for the software development concerns, there are two
issues to consider:
1. The analysis issue. How do the objects interact with each other to accomplish
the business tasks in the existing, possibly manual, business processes?
2. The design issue. How should the objects interact in the proposed system to
improve the business processes?
The analysis issue is important because the development team may not be familiar
with the existing business processes. In this case, the development team may need
to collect information and construct models to help understand the existing business
processes. In addition, the development team may need object interaction models to
identify problems or weaknesses in the existing business processes. Therefore, it is
helpful to construct object interaction models for analysis purposes.
The design issue is important because the existing business processes were de-
signed years ago. They may be manual or even be outdated because the business may
have expanded considerably, the business environment may have changed drastically,
and technologies may have advanced significantly. The existing processes may need
to be redesigned. Therefore, it is necessary to construct object interaction models for
the design purpose. This brings us to the following definition.
In this definition, the first two objectives address the analysis issue while the last
objective addresses the design issue. More specifically, OIM addresses the following
analysis and design problems:
1. Modeling and analysis. This addresses the first two objectives stated above.
2. Object interaction design. This addresses the last objective, that is, designing
object interact behaviors to solve these design problems:
a. Design of object interaction behavior. This concerns the design of sequences
of messages between the objects or how objects collaborate to improve the
existing business processes.
b. Object interfacing. This concerns the design of the signatures and return
types of the functions of the objects.
c. Design for better. This concerns the application of design patterns to produce
a design that meets specific needs and exhibits desired properties, including
low coupling, high cohesion, proper assignment of responsibilities to objects,
and easy adaptation to changes in requirements and operating environment.
218 Part III Modeling and Design of Interactive Systems
Lifeline Indicating that the object exists in the system but it is Connect an object/collection
not executing a method. to a method execution, and
connect two adjacent
method executions.
Method Indicating, by the rectangular shape, that the object Connect to an object/
execution exists in the system and is executing a method. The collection, or to a method
dashed line is the lifeline. execution via a segment of
a lifeline.
Object The cross at the tip of the lifeline indicates that the
destruction object is destroyed or ceases to exist.
Message A message is sent from one object to another object, Connect method executions
passing m i.e., a function call from one object to another object. of two interacting objects.
Stereotyped A stereotyped, or user-defined, message. Connect method executions
message <<data/info>> of two objects, or connect an
actor and the method
execution of an object.
<<jsp>>
A stereotyped object.
LoginPage:
219
220 Part III Modeling and Design of Interactive Systems
to that instance? The fourth case shows a collection of instances of a class, such as
an array of book objects. The representation does not say anything about the type
of the collection, that is, whether it is an array, a linked list, or a hash table. If it
needs to indicate the collection type, then a stereotype can be used. The last case is a
stereotyped instance. A UML stereotype allows the users to define their own classifiers
that extend the standard UML modeling concepts and constructs. For instance, in the
last row of Figure 9.2, a stereotyped object such as a LoginPage Java server page (JSP)
is illustrated. The string <<JSP>> indicates that the LoginPage is not an ordinary
object class, it is a JSP page. Similarly, one may use a stereotype to indicate that a
given collection is a hash table.
<<html>>
WelcomePage: <<redirect to>>
(10)
save(d:Document)
This example illustrates that from a (carefully constructed) sequence diagram one
can reproduce the scenario. Similarly, from a well-formed scenario one can produce
the sequence diagram. As another example, Figure 9.4 depicts a sequence diagram
for a portion of a Checkout Document use case. It visualizes the following scenario.
else
CheckoutController sets msg to “Document not found.”
CheckoutController returns msg to CheckoutGui.
CheckoutGui shows msg to Patron.
Patron sees the msg.
Note the letter d has been used in several places, including the named instance
in the last column of the sequence diagram, to refer to the same Document object.
In practice, the instance variables are often omitted when writing the scenarios; they
are shown explicitly in the sequence diagrams. This example shows the instance
variables in the scenario description and the sequence diagram to make it easy to see
the correspondence between the scenario description and the sequence diagram.
Analysis Design
• Application problem oriented • Software solution oriented
• Models an application domain • Models the software system
• Classes and objects are domain • Classes and objects are software
concepts and instances classes and software objects
• Describes what the world is • Prescribes a software solution
• Allows multiple design • May reduce implementation
alternatives choices
(a) Correct: during the execution of (b) Incorrect: the long rectangle (c) Incorrect: methods must be
checkout(...), three separate beneath DBMgr should split called to execute.
calls to DBMgr are made. into three as in (a).
Checkout Checkout
DBMgr
Controller: GUI:
(d) Not preferred: the back dashed (e) Incorrect: an actor cannot call a
arrow line can be interpreted function of an object; should use a
differently. Do as (a) is preferred. dashed line and stereotype message.
It should be replaced by a dashed arrow line. The dashed arrow line should be labeled
by a stereotype message such as “<<check out cn>>.”
scenario tables
scenario
descriptions (3) Constructing
scenario tables domain model,
(4) Constructing and design class
sequence diagrams diagram
sequence
(1) Collecting info diagrams
(2) Describing about business
scenarios processes Deriving Design
design sequence Class Diagram
business feedback, diagrams (Chapter 11)
processes info if any
Actor-System (5) Review and
Interaction inspection
expanded use cases
Modeling
for current iteration
(Chapter 8)
objects are determined. The input of this step is the scenario descriptions or
scenario tables, the design class diagram produced in previous iterations, and the
domain model. The output of this step is a set of sequence diagrams.
Step 5. Reviewing the object interaction models.
In this step, the object interaction models are reviewed and revised for consistency,
completeness, and correctness.
The sequence diagrams are then used to derive the classes to be implemented.
Also derived are attributes and operations of the classes, and dependency relationships
between the classes. The results are depicted in a UML class diagram, called the design
class diagram (DCD). The DCD serves as the design blueprint for implementation and
testing. The derivation of the DCD is described in Chapter 11. In agile development,
some or all of the OIM steps are omitted if the team has adequate knowledge and
experience. However, for beginners and for teams with less knowledge and experience,
it is recommended that the preceding steps are followed, at least for the first couple
of projects. The following sections describe each of the steps in more detail.
including the functionality of similar systems, and how these systems are
designed and implemented.
3. Using questionnaires. Survey questionnaires are useful for collecting informa-
tion from the users. They are more effective if they are used after the customer
presentation so that the team knows better what should be included in the survey.
The list of survey questions should be brief and easy to understand by the users.
It may be desirable to use different survey questions for different groups of users
if their business processes are different.
4. Interviewing users. A one-to-one personal interview with the users lets the team
clarify issues found in the survey. It is important to create and maintain a friendly
and relaxed interview atmosphere because this improves communication effec-
tiveness. Each interview session should be limited to one hour. The interviewers
should focus on collecting information, rather than on solving problems of the
existing business processes.
5. Studying procedures and forms. All businesses have operating procedures and
forms as well as records and reports. Such business items are valuable sources
for information collection.
1. TUCBW patron clicks the Checkout 2. The system displays the checkout
Document button on the main GUI. GUI.
3. The patron enters the call numbers 4. The checkout GUI displays a
of documents to be checked out and checkout message showing the
clicks the Submit button. details.
Nontrivial steps require the system to perform background processing. The fol-
lowing tips are useful for identifying nontrivial steps:
1. If the system response simply displays a menu, or input dialog, then the step is
trivial. One characteristic of the display is that it is the same for all instances of
the actor of the use case. For example, in Figure 9.8, step 2 displays the checkout
GUI, which is the same for every patron. Therefore, step 2 is trivial.
2. If the system response is different for different instances of the actor, then the
step is nontrivial. Step 4 in Figure 9.8 satisfies this criterion.
What Is a Scenario?
Object interaction is similar to the interaction between the actors and actresses in a
play. The actors and actresses interact following the script of the play to act out the
scenes, or scenarios. This similarity has led the software engineering community to
borrow the word scenario to describe how objects interact with each other to carry
out a use case. Although the scenario of a Broadway play is fascinating, the scenario
that describes how objects interact to carry out a use case is usually very dull. This
is because the underneath computer is very boring. This implies that the language
used to describe object interaction scenarios should be limited to a small subset of
the natural language. The sentences of the language are defined as follows.
•
EXAMPLE 9.1 The following are examples of object interaction statements:
• Romeo gives Julia a bunch of roses.
Here, “Romeo” is the subject, “gives” the subject action, “Julia” the object
that is acted upon, and “a bunch of roses” the secondary object or object that
is required by the subject action.
• The user enters user ID and password on the Login graphical user interface
(GUI).
∨
Chapter 9 Object Interaction Modeling 229
In this case, “the user” is the subject, “enters” the action of the subject, and
∨ “user ID” and “password” are data required by the subject action. The object
acted upon is the Login GUI.
• The checkout controller gets the document from the database manager using
the document call number.
In this case, the subject is the “checkout controller,” the subject action is “get
document,” the object that is acted upon is the “database manager,” the data
or object required by the subject action is the “document call number.”
•
The steps for writing scenarios for nontrivial steps are the following:
Step 2.1 Identify nontrivial steps in the right column of the expanded use case.
Mark the right-column step with an asterisk (“*”). A scenario beginning with the
corresponding left-column step and ending with the marked right-column step
needs to be specified.
Step 2.2 Specify a scenario for each nontrivial step. It should be a high-level
specification of an algorithm. It begins with the actor input and actor action
in the left-column step, and ends when the system response described in the
nontrivial step is produced. This step produces a partial use case scenario. The
complete use case scenario consists of all the steps specified in the expanded use
case with the nontrivial steps replaced by the partial use case scenarios.
230 Part III Modeling and Design of Interactive Systems
Step 2.3 Number the scenario statements using legal decimal numbers like 4.1,
4.2, 4.2.1, to highlight sequencing and nesting.
•
EXAMPLE 9.2 Produce a use case scenario for the expanded use case in Figure 9.8.
Solution: According to the criteria presented in Section 9.3.2, step 4 is nontrivial.
Therefore, step 4 is marked with an asterisk. A scenario for the step is shown
in Figure 9.9. The complete use case scenario consists of all of the steps of the
expanded use case with steps 3 and 4 replaced by the steps in Figure 9.9.
3. The patron enters the call numbers of documents to be checked out and clicks the Submit
button.
4.1. Checkout GUI checks out the documents with the checkout controller using the
document call numbers.
4.2. Checkout controller creates a blank msg.
4.3. For each document call number,
4.3.1. the checkout controller gets the document from the database manager (DBMgr)
using the document call number.
4.3.2. DBMgr returns the document d to the checkout controller.
4.3.3. If the document exists (i.e., d!=null)
4.3.3.1. the checkout controller checks if the document is available (for checkout).
4.3.3.2. If the document is available for checkout,
4.3.3.2.1. the checkout controller creates a Loan object using patron p and document d,
4.3.3.2.2. the checkout controller sets document d to not available,
4.3.3.2.3. the checkout controller saves the Loan object with DBMgr,
4.3.3.2.4. the checkout controller saves document d with the DBMgr,
4.3.3.2.5. the checkout controller writes “checkout successful” to msg.
4.3.3.3. else,
4.3.3.3.1. the checkout controller writes “document not available” to msg.
4.3.4. else,
4.3.4.1. the checkout controller writes “document not found” to msg.
4.4. The checkout controller returns msg to checkout GUI.
4.5. Checkout GUI displays msg to patron.
statement number. The other columns correspond to the subject, subject action, data
or objects required by the subject action, and the object acted upon, respectively. In
other words, a scenario table is a tabular representation of a scenario. It separates
the components of the scenario sentences into the columns of the scenario table.
This tabular representation facilitates the conversion of the scenario into a sequence
diagram, to be illustrated in a later section. Another reason to construct the scenario
table is that it facilitates automatic generation of sequence diagrams because the
mapping from the table to a sequence diagram can be carried out mechanically.
Converting a scenario into a scenario table involves identifying and highlighting
the subject, subject action, data or objects required by the subject action, and the
object acted upon. These are then entered into the scenario table row by row and
column by column. The following example illustrates this.
•
Figure 9.10 shows the highlighted scenario for the Checkout Document use case EXAMPLE 9.3
and Figure 9.11 shows the scenario table produced from the marked scenario.
3. The patron enters the call numbers of documents to be checked out and clicks the
Submit button.
4.1. Checkout GUI checks out the documents with the checkout controller using the
document call numbers.
4.2. Checkout controller creates a blank msg.
4.3. For each document call number,
4.3.1. The checkout controller gets the document from the database manager (DBMgr)
using the document call number.
4.3.2. DBMgr returns the document d to the checkout controller.
4.3.3. If the document exists (i.e., d!=null)
4.3.3.1. the checkout controller checks if the document is available (for checkout).
4.3.3.2. If the document is available for checkout,
4.3.3.2.1. the checkout controller creates a Loan object using patron p and document d,
4.3.3.2.2. the checkout controller sets document d to not available,
4.3.3.2.3. the checkout controller saves the Loan object with DBMgr,
4.3.3.2.4. the checkout controller saves document d with the DBMgr,
4.3.3.2.5. the checkout controller appends “checkout successful” to msg.
4.3.3.3. else,
4.3.3.3.1. the checkout controller appends “document not available” to msg.
4.3.4. else
4.3.4.1. the checkout controller appends “document not found” to msg.
4.4. The checkout controller returns msg to the Checkout GUI.
4.5. Checkout GUI displays msg to patron.
Legend: Subject Subject Action Object Acted Upon Other Required Data or Objects Composition operator
The conversion result presented in Figure 9.11 shows that textual scenario de-
scriptions and scenario tables are equivalent representations. Therefore, the team may
choose to construct both, or only one of the two. It is useful to point out that for most
of the rows in Figure 9.11, the subject is either the subject or the object acted upon on
the previous row. This is also true for the textual scenario description. The developer
should observe this when writing the scenario for a nontrivial step.
232 Part III Modeling and Design of Interactive Systems
FIGURE 9.11 Scenario table for the Checkout Document use case
1. What must be done to fulfill the nontrivial actor request? That is, the tasks to be
carried out to fulfill the actor request should be identified.
2. What is the desired order to carry out the tasks?
3. For each of the tasks, determine the object to carry out the task, that is, the object
that is acted upon.
4. For each of the tasks, determine the object to issue the request to perform the
task.
Chapter 9 Object Interaction Modeling 233
The remainder of this section presents the design activities that make these deci-
sions. The process is an iterative process. It begins with the nontrivial step and decom-
poses it into a number of tasks. Each of these tasks is decomposed until no refinement
is needed. The next step arranges the tasks in the desired order to execute them.
•
The only nontrivial step in Figure 9.8 is step 4. The task to begin with is “check out EXAMPLE 9.4
documents,” which is the name of the use case. This task is broken into a number
of subtasks, which are derived from the business process of the library application.
For example, the checkout documents task needs to retrieve the documents from the
database, create the Loan objects, update the documents, and save the documents
and Loan objects to the database. The task may also return a checkout message,
as hinted by the description of step 4. These subtasks are ordered and listed as
follows:
Checkout documents
Get documents from database
Create Loan objects
Set documents to unavailable
Save documents and Loan objects to database
Return a checkout message
A careful analysis reveals that the “save documents and Loan objects to
database” subtask should be decomposed into two subtasks so that each does
only one thing. This is an application of the separation of concerns as well as the
high-cohesion design principles. The result is
Checkout documents
Get documents from database
Create Loan objects
Set documents to unavailable
Save Loan objects to database
Save documents to database
Return a checkout message
•
The next activity is to identify the object to perform each of the tasks. To accom-
plish this, the worksheet in Figure 9.12 is used. The task and its subtasks are displayed
in the third column followed by the nontrivial step in the last row. Examine each of
the tasks and determine which object should perform the task. Enter the result in the
last, or Object Acted Upon, column. Also specify the required input. To determine
which object performs the task, look it up in the following places:
1. First, look up the object in the second and the last columns of the current work-
sheet. These are the objects that participate in the current scenario. If the desired
object is found, then there is no need to introduce other objects into the current
scenario. This simplifies the design and implementation.
234 Part III Modeling and Design of Interactive Systems
2. Second, look up the object in the design class diagram. The design class diagram,
to be presented in Chapter 11, defines the classes of objects that participate in
the scenarios of other use cases. Therefore, they should be considered next. If
the desired object is found, then there is no need to introduce other objects into
the design class diagram. This reduces the number of classes to implement.
3. Third, look up the object in the domain model. The domain model specifies the
business objects, their properties, and relationships. It is a valuable source to
identify the object to perform the task.
4. Finally, look up the object elsewhere. If the object is not found in the above
places, then look up the object in other places such as code and related business
documents.
•
EXAMPLE 9.5 The first task in Figure 9.12 is to checkout documents. Which object should perform
this task? One possible candidate is the checkout GUI because it knows when the
patron clicks the Submit button. However, letting the checkout GUI perform this
task may overload the checkout GUI object with responsibilities that are not rele-
vant to a GUI object. A better design assigns the task to a checkout controller. This
design lets the checkout GUI focus on its responsibility—that is, presenting infor-
mation to the user. To check out the documents, the controller needs to know the
document call numbers. Therefore, the required input is document call numbers.
The second task in Figure 9.12 is to get documents from the database. This
requires connecting to the database, querying the database, and processing the
query result. If the task is assigned to the checkout controller, then the controller
could become overloaded with database-related operations. Therefore, the deci-
sion is to assign the task to a database manager (DBMgr). The required input is the
document call numbers. For the same reason, the other two database-related tasks,
save Loan objects and save documents, are also assigned to the database man-
ager. The required inputs of these two tasks are the Loan objects and documents,
respectively. Loan objects are created by calling the constructor of the Loan class.
∨
Chapter 9 Object Interaction Modeling 235
The input parameters are the patron and the documents to be checked out. Follow-
ing object-oriented programming practice, the set documents to unavailable task
should be carried out by the documents themselves. The results of these design
decisions are displayed in Figure 9.13.
Now determine which object should issue the request to perform each of the
tasks. As a rule of thumb, the object to issue the request is either the subject on
the previous row or the object on the previous row. This is detailed as follows:
1. If the task on the current row is a subtask of the task on the previous row, then
the requesting object is the object on the previous row.
2. If the task on the current row is not a subtask of the task on the previous row,
then the requesting object is the subject on one of the previous rows. In most
cases, the requesting object is the subject of the previous row.
3. For the first task, the requesting object is the GUI object that receives the
nontrivial actor request. This GUI object is usually named after the name of
the use case. Examples are login JSP for the Login use case and checkout GUI
for the Checkout Document use case.
•
•
The first task in Figure 9.12 is to check out documents. Which object should issue EXAMPLE 9.6
the request to perform this task? The answer is the checkout GUI because it receives
the actor request to check out documents, as shown in step 3 of Figure 9.8. Next,
which object should issue the request to get documents? Since get documents is
a subtask of checkout documents, checkout controller should issue the request
because it is the object on the previous row. The controller also issues the requests
for the next five tasks. Finally, which object should display the checkout message?
Since the task is not a subtask of the task on the previous row, it should be the
subject of one of the previous rows. In this case, it is the checkout GUI on a
previous row. The results of these design decisions are displayed in Figure 9.14.
Two other activities are performed to complete the scenario. First, for each task
that returns a result, insert a row to return the result from the object acted upon to the
∨
236 Part III Modeling and Design of Interactive Systems
which object sends which messages to which other objects and what the sender objects
may get in return from the receiver objects. Second, it is not easy to see what actions
the receiver object would perform when it receives a message. It is not easy to produce
a software design from the textual, informal descriptions of scenarios. Finally, the
informal style of scenario specification is not suitable for design verification and code
skeleton generation. Since the scenario table is merely a tabular representation of a
scenario, it also suffers the same set of problems. To overcome these problems, it is
beneficial for the developer to visualize the scenarios of object interaction with UML
sequence diagrams. This involves the following steps:
Case 1. The subject is an actor. In this case, the object acted upon can only be an
object. This case represents an actor issuing a request to the software system. The
request is entered in some way through the keyboard, mouse, touchscreen, or other
hardware input devices. This converts to a stereotype message from the actor to the
software system. The stereotype message is a dashed arrow line with its label enclosed
in a pair of double angle parentheses, as shown by the first case in Figure 9.16.
Case 2. The subject is an object and the object acted upon is an actor. This case
represents the system delivering the system response to the actor. Most of the time
this is accomplished through displaying a menu, a dialog, or information on the screen.
This converts to a stereotype message from the system to the actor, as illustrated by
the second case in Figure 9.16.
Case 3. The subject is an object and the object acted upon is an object. This case
represents a function call from one object to another object. It is widely referred to as
message passing. The call may involve a returned result from the object being called
to the object that issues the call. This case converts to a solid arrow line, labeled by
indicative texts, from the caller to the callee. The returned result, if any, is modeled
by a dashed arrow line, labeled by the returned result, from the callee back to the
caller. The third case in Figure 9.16 illustrates how to convert this case. The dashed
arrow line is used to distinguish the returned result from the function call, which is
modeled by a solid arrow line. Note that the use of the dashed arrow line in this case
Case Example
object :
:MainGUI
<<enters call numbers>>
<<action + data/
actor objects>>
Patron
Case 2: subject is an object and object acted Other Data/ Object Acted
upon is an actor Subject Subject Action
Objects Upon
Subject Data/ Object confirmation
Subject system displays Patron
Action Objects Acted message
object action message actor
system:
object: <<confirmation
message>>
Patron
<<message>>
actor
Case 3: both subject and object acted upon are Other Data/ Object Acted
objects Subject Subject Action
Objects Upon
Subject Data/ Object checkout gets
Subject call number DBMgr
Action Objects Acted controller document
data/
object1 action object2
objects
object1 : shipment:
and in Cases 1 and 2 causes no confusion because in this case two software objects
are involved while in Cases 1 and 2 there is an object and an actor.
Case 4. The subject and the object acted upon are the same object. This case repre-
sents a call from a function of an object to another function of the same object. It is
modeled by a solid arrow line from the object back to itself, as shown in the last case
of Figure 9.16.
•
Construct a sequence diagram from the scenario table shown in Figure 9.17. EXAMPLE 9.7
Solution: The scenario table converts to the sequence diagram shown in Figure 9.3.
save Loan l
setAvailable to false
save Document d
add “d checkout successful.”
<<msg>> msg
Data coupling means that a single data value is passed as a parameter or return
value from one function to another. The data value is only used in a computation to
produce some result, not in selecting a path or control flow in a program.
GUIDELINE 9.2 Prefer object coupling over stamp coupling. Make sure that the
update functions implement the necessary integrity checks.
Stamp coupling means that a data structure is passed as a parameter or return value
from one function to another. Similarly, object coupling means that an object is passed
between two functions. Often, the data structure has semantics and assumptions. These
may not be obvious. Therefore, the data structure could be used incorrectly. Object
subject: object acted: <<jsp>> : LoginController
: LoginPage
<<jsp>>
subject: object acted: : LoginPage : LoginController
b := searchPrograms
setAvailable(false) (criteria): boolean
opt
programs := getPrograms():
[b] Program[]
searchJSP: : SearchController
searchPrograms (criteria)
coupling is preferred because the accessor functions, such as getX() and setX(), could
implement integrity checks to ensure that the data structure is used correctly.
GUIDELINE 9.4 Avoid control coupling, common coupling, and never use external
coupling.
Control coupling means that two functions are coupled with a control variable,
which determines the program path or control flow at runtime. For example, a pa-
rameter used as the case variable in a switch statement is a control variable. Its
value determines the case statement to be executed. Control coupling means that
the behavior of one object is controlled by another object. The runtime behavior
is very difficult to predict, test, and debug. Therefore, control coupling should be
avoided.
Common coupling means that functions communicate through a global data area
or a global variable. Concurrent updates to such variables may produce unpredicable
behavior. In object-oriented programming, the use of a public static data member
constitutes a common coupling because that data member can be accessed and up-
dated by all objects. External coupling means that functions communicate via the
memory space of an external device. This type of coupling should be avoided be-
cause the external memory space could be modified by external programs, resulting
in unpredictable behavior.
•
Discuss the design in Figure 9.20 and make necessary improvements. EXAMPLE 9.9
Solution: The design in Figure 9.20 exhibits control coupling due to the use of
the control variable r. The value of r is computed by the User object and af-
fects the behavior of the JSP page. Figure 9.21 shows the improved sequence
diagram in which the three-value control variable r is replaced with two boolean
variables. The semantics of the boolean variables and the sequence diagram is
clearer.
Suppose that the verify function of the User class is changed to return four
values instead of three values, with the additional value to indicate that the user’s
account has been revoked. Suppose for some reason, that the meaning of the return
values is reassigned, for example, 0 means valid login, 1 means need to change
password, 2 means invalid login, and 3 means account revoked. In this case, the
system implemented according to the design in Figure 9.20 will no longer work.
However, the system implemented according to the design in Figure 9.21 will still
work except that the newly added case will not be in effect until the design and the
∨ JSP page are changed accordingly.
244 Part III Modeling and Design of Interactive Systems
<<jsp>>
Login Page:
: LoginController : DBMgr u:User
∨
<<uid, password>>
r := verify(uid, u := get(uid): User
User password):int
<<html>>
<<html>> ChangePassword
WelcomePage: Page:
<<redirect to>>
<<uid, password>>
r := verify (uid, u := get(uid): User
User
password): boolean
<<html>>
<<html>> ChangePassword
WelcomePage: Page:
<<redirect to>>
•
Convert the informal sequence diagram in Figure 9.18 into one with formally EXAMPLE 9.10
specified messages.
Solution: Figure 9.22 shows the formally specified sequence diagram as the result
of the conversion.
create(p:Patron, d:Document)
save(l:Loan)
setAvailable(false:boolean)
save(d:Document)
add(“Checkout success.document”+d)
[else] add(“Not available.document”+d)
<<msg>>
b. The sequence diagram speaks the right ideas—meaning the sequence diagram
correctly describes the algorithm, or scenario.
GUIDELINE 9.5 Work closely with the customer and users to understand their
business processes, especially how the business processes the transactions.
Agile development emphasizes active user involvement during the entire devel-
opment process. In particular, with active user involvement, information about the
existing business processes could be obtained more easily and more accurately. This
information is useful for constructing object interaction models to help the develop-
ment team understand the current processes. Users also help the development team
to analyze the current business processes to identify problems and develop viable
solutions. Another benefit of active user involvement is validating that the proposed
computerized solutions would solve their business problems. It should be noted that
although UML sequence diagrams are relatively easy for the development team to un-
derstand, they are not easy for most users. Therefore, scenarios rather than sequence
diagrams should be used to communicate with the users.
GUIDELINE 9.6 The team members write the scenarios and construct the scenario
tables together. Do not do these individually.
UC 8: Update Configuration
Actor: User System: LIS
0. LIS displays the main menu.
1. TUCBW the user clicks the Update 2. LIS shows the Update Configuration nontrivial
Configuration button in the main menu. dialog. steps
3. The user modifies the configuration 4. LIS shows the Configuration Updated
information and clicks the Save button. message dialog.
5. TUCEW the user clicks the OK button
in the Configuration Updated message
dialog.
integration, and testing phases due to the lack of a common understanding and the
inconsistencies.
The “barely enough modeling” principle tells us that modeling is performed only
when it is needed. Therefore, if the team has a good understanding of the scenario,
then object interaction modeling for that scenario can be skipped except that docu-
mentation is compulsory. This is because modeling is aimed to help understanding
and communication. If the team already understands the scenario, then models are
redundant. Modeling could be skipped if the scenario is simple enough or the team
has prior experience. Consider, for example, the Update Configuration expanded use
case shown in Figure 9.23. There are two nontrivial steps. The scenario for step 2
begins when the Update Config GUI calls the getConfig():Config method of the
Update Config Controller, which calls the getConfig():Config method of the database
manager. The scenario ends with the Update Config GUI displaying the Update
Configuration dialog. This scenario is simple and straightforward. If the getCon-
fig():Config methods of the controller and the database manager, respectively, are
already defined, then construction of this scenario is not necessary. Similarly, the
construction of the scenario for step 4 is not required.
Once the scenario or the scenario table is produced, drawing the sequence diagram
is the easiest thing of all. In fact, the sequence diagram can easily be produced by a
computer. Therefore, drawing the diagrams should be performed by a team member
off-line.
248 Part III Modeling and Design of Interactive Systems
3. The patron enters the call numbers of documents to be checked out and clicks the
Submit button.
4.1. Checkout GUI checks out the documents with the checkout controller using the
document call numbers.
4.2. Checkout controller creates a blank msg.
4.3. For each document call number,
4.3.1. the checkout controller gets the document from the database manager (DBMgr)
using the document call number.
4.3.2. DBMgr returns the document d to the checkout controller.
4.3.3. the checkout controller processes the document and updates the msg.
4.4. The checkout controller returns msg to checkout GUI.
4.5. Checkout GUI displays msg to patron.
GUIDELINE 9.9 Keep it simple and stupid. Omit programming detail in the sce-
nario and the sequence diagram.
Scenarios contain sentences that refine the actions of the objects acted upon. Con-
sider, for example, Figure 9.9. Steps 4.3.3 through 4.3.4.1 are a detailed description of
how the checkout controller processes the document returned by the DBMgr object.
If these steps are obvious to the team members, then these steps can be replaced by
the following step:
4.3.3. The checkout controller processes the document and returns the updated msg.
In this way, the details are removed from the design and given to the implemen-
tation. Figure 9.24 shows the simplified scenario description.
SUMMARY
•
This chapter presents the OIM methodology and UML of one of the three behavioral aspects of an object-
sequence diagram. Scenario and scenario table are oriented system—that is, object interaction modeling,
defined to facilitate sequence diagram construction. state modeling, and activity modeling. This chapter
A scenario is produced for each nontrivial step of an does not consider many object-oriented design prin-
expanded use case. The scenario is then converted into ciples. This is done on purpose to let the student focus
a scenario table, which is converted into an informal on one aspect at a time. The next chapter will present
sequence diagram. The informally specified messages how to apply responsibility assignment design pat-
of an informal sequence diagram are translated into terns during OIM. Design patterns incorporate object-
formally specified messages, resulting in a design se- oriented design principles. Therefore, when design
quence diagram. patterns are applied correctly the design principles
OIM is an important step of object-oriented anal- are applied as well.
ysis and design. It concerns the analysis and design
FURTHER READING
•
The notion of a scenario was introduced in the 1970s. The lated into an event trace diagram, which is an earlier version
Object Modeling Technique (OMT) [131] also uses scenar- of sequence diagram. OMT also introduces the event flow
ios to describe object interaction. Communication diagram diagram, which is an earlier version of communication dia-
was called collaboration diagram in UML 1.0. The book by gram. Larman [104] uses a sequence diagram, called system
Booch, Rumbaugh, and Jacobson [36] provides a concise sequence diagram, to highlight the interaction between an
introduction to UML 2.0 sequence diagram and communi- actor and the system. Each actor input is considered a sys-
cation diagram. A much more comprehensive specification tem event. The processing of system events is modeled by
can be found at www.omg.org. In OMT, a scenario is trans- additional sequence diagrams or communication diagrams.
EXERCISES
•
9.1 Write a scenario for the Order a Dish use case of a 9.3 Represent the Order a Dish scenario using a scenario
manually operated restaurant. For simplicity, assume table.
that only one dish is ordered. 9.4 Construct an informal sequence diagram for the
9.2 Highlight the subjects, subject actions, the objects Order a Dish scenario.
acted upon, and data and objects required by the sub- 9.5 Produce scenarios, scenario tables, and design se-
ject action in the Order a Dish scenario. quence diagrams for the Deposit Money, Withdraw
250 Part III Modeling and Design of Interactive Systems
Money, Check Balance, and Transfer Money ex- the user may need to edit the generated diagrams.
panded use cases you produced for the ATM appli- The following are some of the analysis and design
cation in exercise 8.1. tasks:
9.6 For the online car rental application described in Ap- a. Produce a list of requirements for this software
pendix D.1, produce scenarios, scenario tables, and tool.
design sequence diagrams for the nontrivial steps b. Derive use cases from the requirements.
of the Search Car, Reserve Car, Edit Reservation, c. Construct a requirements-use case traceability
and Cancel Reservation expanded use cases you matrix.
produced in exercise 8.4. d. Construct a domain model for this application.
9.7 Produce scenarios, scenario tables, and design se- e. Specify the high-level and expanded use cases.
quence diagrams for the nontrivial steps of the ex- f. Perform OIM for some of the nontrivial use cases.
panded use cases you produced for the state diagram Which of the OIM steps can be fully or highly
editor problem in exercise 8.6. automated and how?
9.8 Suppose that you are to design and implement a soft- 9.9 Modify the expanded use case in Figure 9.8 to al-
ware tool for OIM using the methodology presented low a patron to start the use case before or after log
in this chapter. The tool should support the method- on. If the patron has not logged on, the use case will
ology steps discussed and automatically generate the redirect the patron to the Log On use case. After the
design artifacts whenever possible. This includes au- patron has logged on, the use case will resume the
tomatic generation of sequence diagrams from the checkout process. Perform the steps described in this
scenario tables—that is, there is no need for the user chapter to construct the design sequence diagram for
to draw the sequence diagrams manually although the modified expanded use case.
10
Applying
Responsibility-Assignment
Patterns
Chapter 9 presented the basic methodology for object interaction modeling (OIM).
It is a basic methodology because it does not take into account the various software
design principles. This is done on purpose to make the steps easy to understand and
easy to follow. This chapter presents how to apply certain software design patterns
during OIM. It will discuss relevant software design principles to help understand
what is considered a good design. In particular, it will discuss problems associated
with some of the commonly seen design sequence diagrams. The problems will be
explained in terms of violation of software design principles. To solve these problems,
several design patterns are introduced and how to apply these patterns to improve the
design is illustrated. Throughout this chapter, you will find answers to the following
questions:
251
252 Part III Modeling and Design of Interactive Systems
1 Strictly speaking, a singleton can have a limited number of globally accessible instances.
Chapter 10 Applying Responsibility-Assignment Patterns 253
how the participants interact with each other to solve the design problem. UML notes
are commonly used to provide additional information, as illustrated in Figure 10.1(a).
are useful for solving structural design problems. An example is how to represent
a complex class structure such as a block diagram. Behavioral patterns are used
to solve behavioral or algorithmic design problems. Examples are how to schedule
the execution of operations, how to process events, and how to perform analysis
algorithms on elements of a complex class structure.
Another set of well-known software design patterns is the General Responsibility-
Assignment Software Patterns (GRASP), published by Craig Larman [104]. Unlike
GoF patterns, GRASP patterns are general responsibility-assignment patterns. Gen-
eral, because they can be applied to design almost every software system.
Responsibility-assignment, because they address an important object-oriented de-
sign problem. That is, which object should be assigned a given responsibility so that
the resulting design will exhibit properties advocated by software design principles.
This chapter is devoted to the presentation and application of three of the GRASP
patterns. These are the controller, expert, and creator patterns.
Name Singleton
Type GoF/Creational
Specification
Problem How does one design a class that has only a limited number of globally accessible instances?
Solution Make the constructor of the class private and define a public static method to control the creation of the instances.
Design
Structural
Subject
Behavioral
:Client Subject instance:Subject
instance:=getInstance()
opt create()
[instance == null]
operation()
Roles and • Subject: It provides a public static getInstance() method for the client to retrieve its instance.
Responsibilities • Client: It calls the getInstance() method of Subject to retrieve the instance and calls its operation().
Benefits • It limits the number of instances.
• It supports global access to the instances.
Liabilities • Concurrent update to the shared instance may cause unwanted effect.
Guidelines
Related Patterns • Singleton limits the number of instances of a class. Flyweight supports numerous occurrences of an object.
Prototype reduces the number of classes.
• Visitor is often a singleton.
Uses Singleton is used in many applications. Calendar, Desktop, Runtime and Toolkit are Java APIs that apply the
singleton pattern.
user interface, a web-based interface, or others. The controller pattern is a special case
of the well-known model-view-controller (MVC) pattern. That is, it is an application
of the MVC to the handling of actor requests of a use case.
msg := checkOut
(callNo: String): String
<<call number>>
Patron
d := getDocument (callNo: String):
Document
[d!=null] a:=isAvailable():boolean
alt
setAvailable(false:boolean)
save(d:Document)
<<msg>>
makes more sense to rearrange the values. In this case, changes to the presentation
are also required.
The tight coupling between the presentation and business objects makes it
difficult and costly to support multiple presentations. These include desktop user
interface, web-based user interface, PDA user interface, and cellular phone user
interface, to mention a few. This is because the business logic must be duplicated
in each of the presentations. That is, every message or function call in Figure 10.3
has to be duplicated for each of the presentations. As a consequence, changes to
the business logic are difficult because every presentation has to be changed. If
the multiple presentations are not changed consistently, then the software system
will behave inconsistently or produce inconsistent results.
For the simple example shown in Figure 10.3, these do not seem to be a
problem. But the scale of the problem should be understood by multiplying the
effort to make the changes and the difficulty to maintain the consistency with the
number of use cases that a real-world application could have. This number easily
adds up to more than 20 use cases for a very small application and hundreds of
use cases for a large system.
The tight coupling create problems for software evolution or maintenance.
One type of evolution is enhancement. For example, consider a system that was
originally designed as a desktop application. Later on the business wants to make
it an online application. In this case, a web-based interface is added. The tight
coupling between the presentation and business objects make it difficult and
costly to add the web-based interface because everything must be duplicated in
the implementation of the new interface. This is one of the reasons that companies
finally decide to reengineer their software systems to make them easier to enhance
in the future.
2. The presentation has to handle actor requests. The design in Figure 10.3 in-
dicates that the presentation has to handle actor requests that require background
processing. For example, the presentation in Figure 10.3 processes the docu-
ment checkout request from the patron. It should not be the responsibility of
the presentation to handle such an actor request because the functionality of the
presentation is to display the user interface and system responses.
In Section 6.5.3 of Chapter 6, the principle of separation of concerns was dis-
cussed. The principle was originally proposed by Dijkstra as a problem-solving
principle, that is, focusing on one aspect of the problem rather than tackling
all aspects at the same time. With regard to software design, this principle sug-
gests that each component should focus on one aspect of the subject matter.
According to this, the responsibility to handle actor requests that require back-
ground processing should be assigned to business a object rather than to the
presentation.
3. The presentation is assigned too many responsibilities. As a consequence,
the presentation is assigned too many responsibilities. That is, it is assigned the
responsibility to present system responses as well as the responsibility to process
the business logic. It is not a “stupid object” because it knows how to do both. It
also violates the principle of high cohesion because the two sets of responsibilities
are not cohesive and should be assigned to two or more objects.
258 Part III Modeling and Design of Interactive Systems
Presentation: :?
<<actor request>> actor request
Presentation: :Controller
<<actor request>> actor request
business
objects
<<result>> processing result
Name Controller
Type GRASP
Specification
Problem Who should be responsible for handling an actor request?
Solution Assign the responsibility to handle the request to a dedicated class called the controller.
Design
Structural
Presentation Controller Business Object
invoke invoke *
Behavioral
:Presentation :Controller :Business Object
<<actor request>>
actorRequest()
Actor request()
<<system response>>
Roles and • Business Objects: Object classes responsible for the business logic of an application.
Responsibilities • Controller: A class dedicated to handle designated actor requests. It takes requests from the presentation and
works with the business objects to fulfill the request. A use case controller is dedicated to handle all actor requests
of a given use case. It keeps track of use case state.
• Presentation: A class responsible for interacting with an actor of the system. It delegates the actor requests
to the controller and delivers the responses from the controller to the actor.
<<call number>>
msg := checkOut
Patron d := getDocument
(callNo: String): String
(callNo: String):
Document
alt [d!=null] a:=isAvailable(): boolean
[a] save(l:Loan)
setAvailable(false: boolean)
save(d:Document)
<<msg>>
Changes to certain requirements can be easily made. Suppose that the library
information system is extended with additional requirements to support multiple
user interfaces using different technologies like web interface, cellular phone
interface, and voice interface. With the previous design in Figure 10.3, one has
to design and implement the new user interfaces. In addition, the business logic
must be duplicated in each of these presentations. Changes to the business logic
or business objects will require similar changes to each of these duplicates. With
a sizable number of use cases, the effort to making the changes and maintaining
the consistency is enormous.
The design in Figure 10.6 only needs to add the new user interfaces and
have each of them invoke the appropriate functions of the Checkout Controller.
Changes to the business logic or business objects would have little impact to the
user interfaces. This is attractive when the number of use cases is large.
2. Separation of Concerns. Separation of concerns is well supported by the design.
The Checkout GUI object now deals with only the presentation aspect while the
Checkout Controller is responsible for processing the Checkout Document use
case. In the previous design, both concerns are assigned to the Checkout GUI.
3. High Cohesion. Previously the responsibilities of presenting information to the
patron and processing the Checkout Document use case are assigned to the
Chapter 10 Applying Responsibility-Assignment Patterns 261
Checkout GUI. But these two sets of functionality do not belong to a single
core function. Therefore, the cohesion of the previous design is surely not func-
tional cohesion. The fact that the Checkout GUI first receives the actor request
and then processes it indicates that the Checkout GUI in the previous design
exhibits procedural cohesion. In the new design, both the Checkout GUI and the
Checkout Controller exhibit functional cohesion for obvious reasons.
4. Designing “Stupid Objects.” The new design exhibits the principle of keep it
simple and stupid, especially, designing “stupid objects.” Previously, the Check-
out GUI knew how to present information to the patron as well as how to process
the business logic. In the improved design, each of the Checkout GUI and the
Checkout Controller knows only one thing, presenting information and process-
ing the Checkout Document use case, respectively.
departure and
arrival airports,
and travel dates route passenger
entered selected info entered
Cities & Dates Flight Passenger Info
Init
Selected Selected Entered
Back Back Back
Hold Back Purchase
payment info payment option
ticket option entered selected
Reservation selected Payment Info Pay Option Purchase
Successful Entered Selected Selected
Back Back
FIGURE 10.7 State transition diagram for the Reserve Flight use case
displays the Flight Reservation page. The customer selects Round Trip or One Way
and enters the departure airport, destination airport, and dates of travel. The system
displays the available routes. The customer selects the desired route and clicks the
Continue button. The system asks the customer to enter the passenger information.
The customer enters the passenger information and clicks Continue. The system
asks the customer to select Purchase or Hold. If the customer selects Hold, then
the system will hold the reservation for the customer for 24 hours. If the customer
selects Purchase, then the system will ask the customer to select payment options.
The customer selects the payment option. The system asks the customer to enter
payment option-related information. The customer enters the requested information.
The system asks the customer to select ticketing option. The customer selects ticketing
option. The system displays a flight reservation success message. The use case ends
when the customer sees the flight reservation success message.
The use case controller will be responsible for handling all actor requests for this
use case. This means each of these actor requests will be delivered in some way to the
same use case controller to process. The processing of all these requests comprises the
business process of purchasing a flight ticket. In the above scenario, there are seven
use case-related actor requests: (1) the customer selects Round Trip or One Way and
enters the departure city, destination, and travel dates, (2) the customer selects the route
and clicks the Continue button, (3) the customer enters the passenger information and
clicks the Continue button, (4) the customer selects Purchase or Hold, (5) the customer
selects the payment option, (6) the customer enters the payment information, and (7)
the customer selects the ticketing option.
As each of the actor requests is successfully processed, the state of the use case
changes. Figure 10.7 illustrates the state transition diagram for the Reserve Flight use
case. With this state model, the system can be made more user friendly and robust
because the system knows what the user can do next and what will be the resulting
state. Thus, the system can show only the links or buttons that the user can click
at each step. This effectively eliminates the out-of-sequence requests and makes the
system more robust.
A facade controller is responsible for handling all actor requests for the entire
system. Facade controller is used when there are only a few use cases and the system
is not likely to expand. If the system will expand, then more use cases will be added.
As more use cases are added, the cohesion, coupling and separation of concerns
Chapter 10 Applying Responsibility-Assignment Patterns 263
attributes of the facade controller deteriorate. Eventually, the facade controller will
become overloaded with excess responsibilities to handle many actor requests and
use cases. It will be difficult to comprehend, implement, test, and maintain. Since
system expansion is inevitable in most cases, the design for change principle suggests
that use case controllers should be used for most applications.
: CheckoutGUI : CheckoutController DB
<<msg>>
Separation of Concerns
The controller in Figure 10.8 has all the responsibilities to process the Checkout use
case. Therefore, it does not achieve separation of concerns. On the other hand, the
controller in Figure 10.6 is assigned the responsibility to carry out the check-out
procedure only. The database-access responsibilities are assigned to the DBMgr and
the business objects are responsible for maintaining the states of the business objects.
Therefore, separation of concerns is well-supported by the design in Figure 10.6 but
not by the design in Figure 10.8.
High Cohesion
In Figure 10.8, various responsibilities are assigned to the controller. These responsi-
bilities are functionally divided and distributed to the various objects in Figure 10.6.
Therefore, the design in Figure 10.6 exhibits higher cohesion than the one in Fig-
ure 10.8.
Low Coupling
The tight coupling between the controller and the database in Figure 10.8 means sig-
nificant change impact if the database is replaced or the database schemes are changed.
Thus, low coupling is not accomplished. On the other hand, the DBMgr in Figure 10.6
decouples the controller from the database. Therefore, the change impact is low.
Information Hiding
The DBMgr in Figure 10.6 hides the database from the controller. The database
implementation details are not shielded from the controller in Figure 10.8. Therefore,
information hiding is violated.
Chapter 10 Applying Responsibility-Assignment Patterns 265
If there are many actor requests or the system is likely to expand with more use
cases, then use case controllers should be used.
If care is not exercised, a controller could be overloaded with too many irrelevant
responsibilities. This could happen in the initial design, which allows a controller
to process actor requests that are associated with several use cases. When the de-
sign is envisioned, only a few actor requests are known to exist. As the design and
implementation proceed, more actor requests are identified. As a consequence, the re-
sponsibilities of the controller increase. Since the responsibilities come from different
use cases, the controller is overloaded with responsibilities that should be assigned to
distinct use case controllers. In this case, the overloaded controller should be split into
several use case controllers, each of which is responsible for handling actor requests
for one use case.
A controller could be assigned too many irrelevant responsibilities if the role and
responsibilities of the controller are misunderstood. As discussed earlier, a controller
decouples the presentation and the business objects. Its responsibility is to supervise
or coordinate the business objects to jointly carry out the steps of a use case. In
other words, the controller is responsible to keep track of when to perform which
step, invoke the appropriate business objects to carry out the step, and coordinate
the activities of the business objects. If the role and responsibilities of a controller
is misunderstood, then irrelevant responsibilities could be assigned to the controller.
If many such responsibilities are assigned to the controller, then the functional co-
hesion of the controller decreases and the controller is overloaded with irrelevant
responsibilities. This leads to the next guideline.
GUIDELINE 10.3 Properly assign the responsibilities to process a use case to the
controller, the business objects, and other resource management objects.
pw := getPassword ( ): Password
alt [!b]
msg := “Login failed.”
[else]
<<msg>>
<<html>> In practice, the design should
also check if the user is in the
WelcomePage:
database.
<<redirect to>>
the DBMgr to retrieve the User object and gets the password from the User object. It
then verifies whether the submitted password matches the stored password.
The design in Figure 10.10 is not uncommon. However, the design exhibits some
problems. First, the responsibility to verify whether the submitted password matches
with the stored password should be the responsibility of the User object, not the
Login Controller. That is, the responsibility is not assigned to the right object. The
reader might wonder why it is the case. Shouldn’t the Login Controller be responsible
for processing the Login use case and hence verify the password? This is because
only the User object has the password information to verify the submitted password.
The controller does not have this information. If this responsibility is assigned to the
controller, then the controller has to ask the User object to give it the password so that
it can verify the validity of the submitted password. However, this does not satisfy
the principle of make it simple and stupid because letting the User object verify the
password is a simpler solution.
Second, security requires that the passwords should be encrypted. In this case,
the Login Controller in Figure 10.10 has to know password encryption and password
decryption. Another security problem with the design in Figure 10.10 is that the
getPassword():Password function of User allows an object to retrieve the password
of a user. If the password is not encrypted, then a security vulnerability is present.
Applying the expert pattern solves these problems. The result is shown in Figure 10.11,
in which only one call to the verify(password):boolean function of a User object is
required.
Chapter 10 Applying Responsibility-Assignment Patterns 269
alt [!b]
msg := “Login failed.”
[else]
Applying expert
<<msg>> pattern: assigning the
<<html>> responsibility to
verify password to
WelcomePage:
User because it has
the information to
fulfill the request.
<<redirect to>>
GUIDELINE 10.4 Look for the information expert in the current sequence diagram,
then in the design class diagram, and finally in the domain model.
:? :B :A :B
(a) Who should be responsible (b) Creator suggests that :A should create :B
for creating a B object?
creator pattern suggests that the responsibility to create an object of Class B should
be assigned to an object of Class A if one of the following holds:
1..*
create(...) create(...)
:Chapter
(a) Who should be (b) In the domain model, (c) Therefore, :Book should
responsible for creating Book is an aggregate be responsible for creating
a Chapter object? of Chapter. a Chapter object.
maintain
create(...) * create(...)
Position
(a) Who should be responsible (b) In the domain model, Portfolio (c) Therefore, :Portfolio should be
for creating a Position object? maintains Positions. responsible for creating a
Position object.
In Figure 10.14(a), who should be the creator for a Position object? In investing,
the term position denotes the number of shares of a stock that you own and the average
cost of the shares. As you buy or sell shares of a stock, the number of shares and the
average cost change. The domain model shows that Portfolio maintains Positions as
shown in Figure 10.14(b). That is, as you buy or sell shares the positions are updated
through a Portfolio object. Therefore, Portfolio objects should be responsible for
creating the Position objects in the portfolio, as shown in Figure 10.14(c).
The third example shows that the Checkout Controller uses the DBMgr object to
retrieve business objects from the database; therefore, the Checkout Controller object
should be responsible for creating the DBMgr object. This is shown in Figure 10.15.
Finally, to create a Loan object, one needs a User object and a Document object
because Loan is an association class for the borrow (User, Document) association
(Figure 10.16[b]) and the Checkout Controller has these objects as shown in Fig-
ure 10.15(b). Therefore, the Checkout Controller should be the creator of the Loan
object.
d: = getDocument(...)
borrow
:? :Loan User Document :CheckoutController :Loan
(a) Who should be the creator? (b) Loan is an association class (c) :CheckoutController
between User and Document. should be the creator.
SUMMARY
•
This chapter presents the controller, expert, and cre- suggests that the responsibility to handle a given re-
ator patterns. These patterns address a common de- quest in the business object layer should be assigned
sign problem—how does one assign responsibilities to the information expert, which has the information
to objects? In particular, these patterns answer the fol- to fulfill the request. The creator pattern suggests that
lowing questions: the responsibility to create a given object should be
1. Who should be assigned the responsibility to assigned to the object that is an aggregate of, depends
handle an actor request? The answer is the con- on, or has the information to create the given object.
troller. This chapter discusses problems associated with
commonly seen designs that do not apply the con-
2. Who should be assigned the responsibility to
troller, expert, and creator patterns. It then shows how
handle a request in the business object layer?
these patterns are applied to improve the design. These
The answer is the expert.
discussions should help the student understand not
3. Who should be assigned the responsibility to cre- only what the controller, expert, and creator patterns
ate a given object? The answer is the creator. are and how to apply them, but more importantly,
The controller pattern is meant to decouple the when to apply these patterns and why. Knowing these
presentation from the business logic by assigning the answers enables the student to properly apply the three
responsibility to process an actor request to a con- GRASP patterns in the practical field of software de-
troller rather than the presentation. The expert pattern velopment.
274 Part III Modeling and Design of Interactive Systems
FURTHER READING
•
Larman’s book [104] presents the controller, expert, creator The book by Wirfs-Brock and McKean [163] presents the
and other GRASP patterns. A summary of the nine GRASP latest practices in Responsibility-Driven Design (RDD)—
patterns is given in Figure 10.17. The book also presents the designing objects with specific roles and responsibilities
23 situation-specific or Gang of Four patterns [67]. These and as members of an object community.
patterns are described in subsequent chapters of this book.
EXERCISES
•
10.1 Construct a table with columns for the controller, 10.5 Identify and explain the improvements that the con-
expert, and creator patterns and rows for the design troller, expert, and creator patterns introduce to the
principles presented in Chapter 6. Check the entries behavioral design for the UML Class Diagram Edi-
to indicate which patterns support which design prin- tor. Hint: Compare the design with one that does not
ciples. Provide explanations to justify the result. apply the patterns to identify the improvements.
10.2 See the Online Car Rental application described in 10.6 Which classes in the UML Class Diagram Editor de-
Appendix D.1. Its use cases include Search for Cars, sign could be a singleton? Justify your answer.
Reserve Cars, Edit Reservation, and Cancel Reser- 10.7 Write an essay to discuss the similarities and differ-
vation. Do the following and at the same time apply ences of the controller, expert, and creator patterns.
the controller, expert, and creator patterns whenever 10.8 Describe three realistic, not dummy or hypothetic,
appropriate: situations to apply the controller, expert, and creator
a. Specify the expanded use cases and identify the patterns.
nontrivial steps if you have not specified these.
10.9 In exercise 8.6, you produce the expanded use cases
b. Produce scenarios, scenario tables, and sequence
for a state diagram editor. In this exercise, you are
diagrams for the nontrivial steps.
required to identify the nontrivial steps. For each
10.3 Identify and explain the improvements that the con- nontrivial step, write a scenario, construct a scenario
troller, expert, and creator patterns introduce to the table, and convert the scenario table to a design se-
behavioral design for the Online Car Rental system. quence diagram. Apply the controller, expert, creator,
Hint: Compare the design with one that does not ap- and singleton pattern if appropriate during this pro-
ply the patterns to identify the improvements. cess. Preferably, the patterns should be applied when
10.4 Do the same as in exercise 10.2 but for the Edit Class you describe the scenarios.
Diagram use case for a UML Class Diagram Editor.
11
Deriving a Design Class
Diagram
1. System engineering (Chapter 3). During this step, the system requirements spec-
ification for the total system as well as the overall system architecture are pro-
duced. The overall system architecture depicts hardware, software, and human
subsystems and their interrelationships. The system requirements are allocated
to the subsystems.
2. Software requirements analysis (Chapter 4). In this step, the system require-
ments that are allocated to the software subsystems are analyzed and refined, and
additional software requirements are identified.
3. Domain modeling (Chapter 5). In this step, a domain model is constructed or
extended to help the development team understand the application domain and
requirements. Often, domain modeling is performed during requirements analysis
and subsequent iterations. The domain model is visualized using a UML class
diagram.
4. Architectural design (Chapter 6). This step produces the architectural design for
the software system, which is used to guide the subsequent design, implemen-
tation, and testing of the subsystems and components. The artifacts produced
during the subsequent activities are organized according to the subsystems.
276
Chapter 11 Deriving a Design Class Diagram 277
5. Deriving use cases from requirements (Chapter 7). In this step, use cases are
derived from the software requirements and allocated to the iterations. UML use
case diagrams are produced to visualize the use cases, subsystems, and actor-use
case relationships. This step concludes the planning phase.
6. Actor-system interaction modeling (Chapter 8). During this step, the expanded
use cases for the current iteration are produced. These specify how the actors will
interact with the system to carry out the use cases. The domain model provides
the information needed to specify the actor input and system responses.
7. Object interaction modeling (chapters 9 and 10). In this step, the nontrivial steps
of actor-system interaction are identified and sequence diagrams are produced to
show how the software objects interact and collaborate to carry out these steps.
Design patterns are applied to produce a better design.
The UML diagrams produced by the above steps describe different aspects of
the application as well as the system under development. However, the collection of
these diagrams does not provide a class structure and a road-map to guide the sub-
sequent test-driven development (TDD) and integration testing. For example, either
conventional implementation or TDD needs to know the classes that must be imple-
mented as well as their behavior and relationships. Such information is contained
in the diagrams, but unfortunately it is scattered in several diagrams. Consider, for
example, a library information system project. The Loan class appears in the domain
model as well as more than one sequence diagram. That is, it occurs in the checkout
document sequence diagram and the return document sequence diagram. Similarly,
the database manager appears in all sequence diagrams that access the database. Thus,
the team members must examine all the UML diagrams to look up the classes, their
functions and attributes, and relationships between the classes. This is only feasible
for a very small project. The effort to look up these is tremendous for most real-world
projects. If classes or operations are overlooked, then the problem will surface dur-
ing integration testing. This will significantly slow down the progress of the entire
project.
The discussion indicates that the team needs a diagram to serve as a design
specification of the classes and the class structure. This diagram is called a design
class diagram (DCD). The DCD is a UML class diagram that depicts the classes,
their operations and attributes, as well as the relationships between the classes. All
these are derived from the diagrams produced in the current iteration and added to
the DCD. There is only one DCD for the whole system, not a DCD for each iteration.
How to derive the DCD from the collection of diagrams is the focus of this chapter.
In particular, you will learn the following:
• What is a design class diagram, and how does it differ from a domain model?
• What is the usefulness of a design class diagram?
• How does one derive the design class diagram from the analysis and design
diagrams?
• How does one organize large design class diagrams using UML package
diagrams?
278 Part III Modeling and Design of Interactive Systems
Definition 11.1 A design class diagram is a UML class diagram, derived from
the behavioral models and the domain model. It is a design blueprint to facilitate
the subsequent implementation, testing, and integration activities.
The DCD is derived from the behavioral models and the domain model. The
behavioral models include sequence diagrams (Chapter 9), state diagrams (Chap-
ter 13), and activity diagrams (Chapter 14). They are constructed to help develop,
communicate, and validate design ideas, which are otherwise distributed among the
team members. The processes of design review and inspection ensure that the dia-
grams satisfy the requirements and constraints. If the team derives the DCD from
the behavioral models, then the DCD should contain all the classes, operations, and
relationships that are needed to satisfy the requirements. The team implements and
deploys all and only the classes in the DCD. That is, all classes required to satisfy the
requirements are implemented and no more.
Due to encapsulation and information hiding, the classes of object-oriented pro-
grams implement the ordinary get and set methods, also called getters and setters.
These methods simply return or set the appropriate attribute values. Since there are
many such methods, if all of them are shown in the DCD, then the DCD will be
crowded with such methods and obscure the other more important behavior of the
classes. Therefore, as a convention, the DCD must not show the ordinary get and
set methods. It should be pointed out that this convention should not be applied to
all classes of the DCD. For example, the database manager class is responsible for
retrieving from, and storing objects to the database. If the retrieving object operations
are named getX(. . .):X, getY(. . .):Y, . . . , where X and Y are class names, then these
operations must not be suppressed from the interface specification of the database
manager class. This is because they are not the ordinary getters and setters.
1. It brings together the most significant design artifacts in one diagram. As dis-
cussed at the beginning of this chapter, the classes and information about the
classes to be implemented are distributed in a collection of analysis and design
diagrams. The DCD integrates these design artifacts into one design blueprint.
This integration facilitates implementation, integration testing, and maintenance.
2. It facilitates quality measurement and assurance. The DCD provides a basis for
the definition and calculation of design quality metrics, which are useful for
assessing a design and identifying potential design problems. For example, if a
class has a large number of operations, then it is likely that the class is assigned too
many responsibilities. A class with many outgoing edges means that it depends
on many other classes; and hence, it is difficult to reuse the class.
Chapter 11 Deriving a Design Class Diagram 279
setAvailable(false:boolean)
save(d:Document)
are passed as parameters must be implemented and delivered, they must appear in
the DCD. Such classes are identified from the parameters passed in the messages
sent or received by the objects in the design sequence diagrams. In Figure 11.1,
two such classes are identified, i.e., Document and Loan, although they are also
identified as classes that receive messages.
3. Identify classes that serve as return types.
Returning an object from a function call is a common practice in object-oriented
programming. This is also true for design sequence diagrams. Classes that are
return types are identified from the return types of the messages between the
objects in the design sequence diagrams. In Figure 11.1, Document is the only
class that is used as a return type. As illustrated in Figure 11.1, applying the
above three rules identifies six classes: CheckoutGui, CheckoutController, DB-
Mgr, Loan, Document, and Patron classes. These are entered into the DCD, as
shown in Figure 11.2.
4. Identify classes from the domain model.
Classes in the domain model that are parent classes of the classes identified may
be added to the DCD if doing so facilitates understanding, implementation, and
testing.
While identifying the classes, one must bear in mind the following: (1) the above
rules should be applied to all of the design sequence diagrams produced in the current
iteration, not to just one of the sequence diagrams produced; (2) a class may be
Chapter 11 Deriving a Design Class Diagram 281
CheckoutGUI
CheckoutController Patron
Loan
DBMgr Document
identified by more than one rule, therefore, once a class is identified, it will not be
identified again; (3) since the DCD serves as the design blueprint for the system, one
needs only one DCD for all the behavioral models and all iterations, not one DCD
for each sequence diagram, or each iteration.
Method of
<<call number>>
msg := checkOut CheckoutController
Patron d := getDocument
(callNo:String): String
(callNo: String):
Document
alt [d!=null] a:=isAvailable():boolean
Method of
Loan
alt create(p:Patron, d:Document)
Methods of
[a] save(l:Loan) Document
Methods of
DBMgr
setAvailable(false:boolean)
save(d:Document)
<<msg>>
Class Methods
Checkout GUI
Checkout Controller checkout(callNo: String): String
DBMgr getDocument(callNo: String): Document
save(l: Loan)
save(d: Document)
Loan create(p: Patron, d: Document)
+isAvailable(): boolean
+setAvailable(b: boolean)
CheckoutController
Loan
These messages suggest that the noun X or x is an attribute of A and the type of
the attribute is T. For example, a t := getTitle():String message that is sent to a
Document object suggests that title is an attribute of Document and the type of
that attribute is String.
3. Identify attributes from isX():boolean and setX(b:boolean) methods, where X is
an adjective. Recall from the domain modeling chapter, an adjective could be
an attribute or attribute value. Methods that are named isX():boolean or setX(b:
boolean), where X is an adjective, often suggest that isX is a boolean attribute
of the object that receives the message. For example, in Figure 11.6, the a :=
isAvailable(): boolean and setIsAvailable(false) messages to the Document object
suggest that isAvailable is a boolean attribute of Document.
4. Identify attributes from methods that compute a scalar type value. A message
of the form computeX(. . .) or x := computeX(. . .):T, where T is a scalar type
and computeX(. . .) is a computation that produces a scalar type value, may sug-
gest that X is an attribute of the object that receives the message. The type
of the attribute is T. In Figure 11.7(a), a Shipment object receives a com-
puteCharge(. . .):double request to calculate the shipment charge. If the Ship-
ment object stores the value of the computed charge, then charge is an attribute
of Shipment and double is the type of this attribute.
5. Identify attributes from the parameters to a constructor. Most often, the scalar
type parameters that are passed to a constructor are used to initialize the newly
created objects of a class. Consider, for example, a create(callNo: String, title:
String, author: String, year: String, . . .) message that is sent to a Document object,
where create is chosen by UML to name the constructor of a class. In most cases,
the parameters of this message are used by the Document class to initialize the
attributes of the object that is created. Therefore, from these parameters, one can
identify that callNo, title, author, year and the like, are attributes of Document.
The type of these attributes are String. Another example for this rule is illustrated
in Figure 11.7(b). Again the identified attributes and types should be verified
with the domain model or domain knowledge.
284 Part III Modeling and Design of Interactive Systems
Attribute and
<<call number>> type of
msg := checkOut Document
Patron d := getDocument
(callNo:String): String
(callNo: String):
Document
alt [d!=null] a:= isAvailable ():boolean
setIsAvailable (false:boolean)
save(d:Document)
Attribute and type
msg := “Checkout successful.” of Document
<<msg>>
:Shipment :Shipment
computeCharge(...)
create(zip: String, weight: int,
length: int, width: int, height:
Charge is possibly an int, insurance: int)
attribute of Shipment. Attributes may be identified
from the scalar type parameters
of a constructor.
(a) identifying attribute x from (b) identifying attributes from scalar type
computeX(...) methods parameters of a constructor
6. Attributes are identified from the domain model. For each class of the DCD,
examine the corresponding class in the domain model and identify attributes that
are needed by the operations of the DCD class.
The identified attributes are entered into the DCD as shown in Figure 11.8, where
the minus sign (“-”) is the UML notation for the private scope. Note in the figure, the
dueDate attribute of the Loan class is identified from the domain model. This attribute
Chapter 11 Deriving a Design Class Diagram 285
Loan
−dueDate: String
DBMgr +create(p:Patron, d: Document)
+getDocument(callNo:String): Document
+save(l: Loan) attribute identified
+save(d: Document) from domain model
might be needed by the constructor of the Loan object to set the due date for the loan
so that a notification message will be sent to the patron automatically.
Checkout
<<call number>> Controller and
msg := checkOut
Patron DBMgr use
(callNo:String): String d := getDocument Document
CheckoutGui calls (callNo: String):
CheckoutController Document
alt [d!=null] a:=isAvailable():boolean
CheckoutController
creates Loan (Rule
alt create (p:Patron, d:Document)
1). An association CheckoutController
between Patron and calls Document
Document exists with [a] save(l:Loan)
Loan as the
association class.
setAvailable(false:boolean)
save(d:Document)
<<msg>>
In Figure 11.9, there are two such relationships, that is, DBMgr uses Loan
and Document because save(l: Loan) and save(d: Document) are functions of
DBMgr.
d. Class B is the return type of a function of class A. In this case, A uses B as a
return type. At least, A needs to create or obtain an instance of B and returns it.
In Figure 11.9, there is one such relationship. That is, DBMgr uses Document
because Document is the return type of the getDocument(. . .): Document
function of DBMgr.
3. Identify association relationships from calls to constructors that pass two ob-
jects as parameters. If an object of class B and an object of class C are used
as parameters to invoke a constructor of class A, then it is likely that an as-
sociation relationship exists between class B and class C with A as the as-
sociation class. These should be verified with the domain model or domain
knowledge. In Figure 11.9, a Patron object and a Document object are used
to invoke the constructor of Loan. Therefore, an association exists between Pa-
tron and Document, and Loan is the association class. The Loan object stores
the checkout-related information such as which patron checks out which doc-
ument and the due date. Indeed, these are true according to the library domain
knowledge.
4. Identify relationships from get object and set object messages. If getB(. . .):B or
setB(b:B) is a message to an object of class A, and A and B are user-defined
classes, then
a. A is an aggregation of B if an object of B is a part of an object of A. For exam-
ple, a message e := getEngine(): Engine to an object of the Car class signifies
such an aggregation relationship. Such a relationship must be verified with
the domain model, or domain knowledge. Sometimes, it should be verified
with design decisions. For example, design patterns often use aggregation and
inheritance relationships to provide behavioral variations. Such relationships
may not exist in the application domain; and hence, they cannot be verified
with domain knowledge.
b. A uses B, as explained in item 2 above.
c. A associates with B if A and B are not aggregates of, or used by each other.
The relationship so identified should be verified with the domain model, do-
main knowledge, or design decisions. An example of such an association
relationship is Student enrolls Course. This association relationship could be
identified from the c:=getCourse():Course message that is sent to an Enroll-
ment object.
5. Identify call relationships. If an object of class A calls a method of class B,
then A calls B. From Figure 11.9, several such relationships exist, for example,
Checkout GUI calls Checkout Controller.
6. Identify containment relationship from messages to add, get, or remove objects.
A containment relationship between class A and class B, such that A contains
B, is identified if an object of class A receives messages of the form: add(b: B),
get(. . .): B, getB(. . .): B, or remove(b: B), where A and B are user-defined classes.
For example, if add(v: VendItem), get(v: VendItem): VendItem, and remove(v:
288 Part III Modeling and Design of Interactive Systems
<<call>> <<create>>
Loan
DBMgr −due: String
+create(p: Patron, d: Document)
+getDocument(callNo: String): Document <<use>>
+save(l: Loan)
+save(d: Document) <<use>>
different ways. Two commonly used organizations and their combination are:
Purchasing Providing functions such Purchasing Include all purchasing Import database package
Subsystem as review and process related classes such as
faculty and student Publisher, Order, Purchase
purchase requests, order Request, Shipment, and
publications from GUI and controller classes
publishers, track order for purchasing related use
status, and process cases.
shipments from publishers.
User Assistance Providing functions for User Include all user assistance Import database, and
Subsystem user training, user helping, assistance classes such as Tutorial, cataloguing packages
questions and answers, and Help Topic, Question,
other user assistance Answer, GUI and
activities. controller classes for
user-assistance use cases.
Interlibrary Providing functions for Interlibrary Include all interlibrary Import database package
Loan interlibrary loan loan loan-related classes such
Subsystem processing. as Collaborator, Checkout
To, Loan From, and GUI
and controller classes for
interlibrary loan use cases.
Database Providing functions for Database Include all database manager Import circulation,
Subsystem storing and retrieving related classes such as DB cataloguing, purchasing,
objects with a database Manager, DB Connection, user assistance, and
management system. and many other classes that interlibrary loan packages
facilitate the implementation
and maintenance of the
database subsystem.
The hybrid approach has the advantages of the other two approaches. For ex-
ample, in Figure 11.11, each package contains more than one type of object classes.
Therefore, separation of concerns is not supported. The hybrid approach solves this
problem.
The DCD is derived from the design diagrams, which are derived from the require-
ments and reflect the team’s design ideas. For wicked problems, the implementation
and the specification cannot be separated. The specification and the design ideas need
testing by the working software. Therefore, the team should not spend a lot of effort
to make the DCD complete for the application domain. The DCD should add only
the classes, attributes, methods, and relationships for the use cases allocated to the
current iteration, not for future iterations.
The DCD derived according to the steps described in this chapter will include
most of the classes, features, and relationships needed for the current iteration. It
is good enough for test-driven development of the current iteration in many cases.
Therefore, the team should not need to add many other classes and relationships.
292 Part III Modeling and Design of Interactive Systems
SUMMARY
•
This chapter presents the steps for deriving the DCD age diagrams to organize the classes in a DCD. In
from the behavior models and the domain model. particular, the functional subsystem organization, the
The DCD serves as the design blueprint that inte- architectural style organization, and their combina-
grates the design artifacts produced in the previous tion are discussed using a library information system
steps. The chapter also presents how to use pack- example.
FURTHER READING
•
Reference [36] provides a nice presentation of ULM class fication of the class diagram.
diagrams. The OMG site provides a comprehensive speci-
EXERCISES
•
11.1 Derive a DCD from the design sequence diagram in you produced for the state diagram editor in
Figure 9.21. exercise 9.7.
11.2 Derive a DCD from the design sequence diagram 11.4 Derive a DCD from the design sequence diagrams
you produced for the Order a Dish use case in the that you produced for the ATM application in
exercises of Chapter 9. If you have not produced the exercise 9.5.
sequence diagram, do the relevant exercises in Chap- 11.5 Derive a DCD from the design sequence diagrams
ter 9 and then produce the DCD. that you produced for the car rental application exer-
11.3 Derive a DCD from the design sequence diagrams cise 9.6 in Chapter 9.
12
User Interface Design
The user interface of a software system is the means and mechanism through which a
user interacts with the system to carry out business tasks. The users use the interface
to request system services, provide user input, and receive system responses. Their
feeling about the interface greatly influences the acceptance of the system and success
of the project. If the user interface is easy to learn and use, then the users are more
likely to use the system and use it correctly. This leads to an increase of productivity
and acceptance of the new system. On the other hand, if the user interface is com-
plex, confusing, or difficult to use, then the users are more likely to feel frustrated
and make mistakes. Therefore, user interface design is a crucial activity in software
development. Its importance can never be overestimated.
Chapter 8 presented actor-system interaction modeling. That is, how the users
will interact with the system to perform the use cases are described. Actor-system
interaction modeling specifies the sequences of pairs of a user request followed by
a system response to the request. These are referred to as the actor-system interac-
tion behavior. They are part of a user interface design, that is, part of the design
of the user interface behavior. Chapter 8 did not cover the appearances of the user
interface and other user interface interaction behavior that is specific to the graph-
ical widgets, for example, using a text field to enter data is different from using
a selection list.
This chapter presents the basic concepts and steps for user interface design. In
particular, you will learn the following:
• Components of a user interface design
• Importance of user interface design
• User interface design process
• User interface design principles
293
294 Part III Modeling and Design of Interactive Systems
User interface design is aimed to use these features to facilitate user interaction
and delivery of system capabilities. To achieve these goals, user interface design
normally includes the following design activities:
1. Layout design for windows and dialog boxes. This is concerned with the overall
partitioning of the display areas of windows and dialog boxes to facilitate user
interaction, and working on different tasks. For example, most window-based
applications partition the display area to include a menu bar and a toolbar on the
top and a status bar at the bottom. Most integrated development environments
(IDEs) partition the remaining area to include a project pane, a navigation pane,
and a content pane to facilitate the user working on a project.
2. Design of interaction behavior. This is concerned with the design of sequences
of messages exchanged between the user and the system. For example, an IDE
user presses File, and then selects New Project to open a Project Specification
dialog.
3. Design of information presentation schemes. This is concerned with the design
of the presentation of information processing results. For example, using a bar
chart to highlight differences in monthly sales of different products, or a pie chart
to display the sales percentage of each product in the sales total.
Chapter 12 User Interface Design 295
4. Design of online support. This is concerned with the design of an online user
guide, a user’s manual, error messages, help facility, undo and redo, backup and
restore, recovery, as well as many other support capabilities.
the competing software is keep it simple and stupid, and lazy evaluation—that is, do
no more than needed. For example, instead of four windows, one window is used.
Rather than requiring the user to enter all pieces of information regardless whether it
is required, the competing software uses default values. It requires the ship-to name
and address only when the customer decides to ship, in other words, lazy evaluation.
This is because some customers only want to know the shipping costs or package
arrival time.
GUIDELINE 12.1 Minimize the number of windows and dialog boxes that need
to be opened to complete a business task while keeping the user interface easy to
understand and use.
Reducing the number of windows improves the user experience. However, this
must not lead to increased complexity of the windows and dialog boxes and make
them difficult to understand and use. In this regard, creative thinking is needed. The
GUI shown in Figure 12.1 illustrates how. For instance, although the number of dialog
boxes reduces to one, the software does not make the user interface more difficult to
understand and use. This is because it displays the choices in a well-organized, easy-
to-understand manner. The display helps the customer select a shipping option, or a
store employee to answer the customer’s inquiries. The software uses default values
for insurance and package dimension, these are the same for 90% of the shipments.
It does not require the user to enter the ship-to name and ship-to address until they
are required.
298 Part III Modeling and Design of Interactive Systems
GUIDELINE 12.2 To reduce human error, use selection input whenever possible
and appropriate.
Example. People may mistype state names. Therefore, a combo box or spinner is
preferred. However, a text field, possibly a formatted one, is a preferred choice for
Chapter 12 User Interface Design 299
Type of
Category Widget Use Description
Data
Text Field Input Single line Lets the user enter a single line of texts up to a specified number of
Formatted of texts characters. A formatted text field lets the programmer specify the valid
Text Field set of characters. A password field is like a text field except that it hides
Text- Password the texts that were typed.
Oriented Field
Text Area Input/ Multiple Lets the user enter, edit, or view multiple lines of text. A formatted text
Formatted output lines of area allows styled texts while text area supports only plain texts. Styled
Text Area texts texts may contain characters of different fonts, and images.
List Input Single or Lets the user select from a list of choices. Multiple selections are allowed.
Drop-Down multiple A drop-down list displays the list of choices when it is clicked. A combo
List items box combines the features of a list and a text field, allowing the user to
Combo Box select from a list or type in a value.
Check Box Input Boolean Lets the user select one or more items or answer yes/no questions.
Radio Button Selecting one of the radio buttons of a group automatically deselects
the other.
Spinner Input Single A spinner lets the user step through an ordered list of elements to make
Selection- Slider selection a selection, or type a valid input directly. It is sometimes preferred over
Oriented from an combo boxes because no drop-down list is displayed that could block
ordered list the view of important data. A slider is useful for selecting continuous
or a range types of input such as volume control and sensitivity.
of values
File Chooser Input File, item, Lets the user select the file, color, location, or calendar date through
Color or value browsing or clicking on a map or calendar.
Chooser
Location
Chooser
Calendar
etc.
Table- Table Input/ Table or Lets the user view, edit, or enter data using a table or form.
Oriented output form
Diagram- Canvas Input/ Drawing Lets the user view or edit a diagram in a drawing area.
Oriented output
Structure- Tree Input/ Hierarchical Information is organized and displayed as a tree to facilitate viewing
Oriented output and navigation.
Bar Chart Input/ Information is displayed using appropriate charts to highlight difference,
Pie Chart output distribution, trend, and other attributes.
Chart-
Oriented Line Chart
Histogram
etc.
Image- Image Input/ Pictorial Information is input by click on an image, or displayed as an image.
Oriented output
entering zip code because it is extremely difficult to locate the desired zip code from
a list of thousands of zip codes.
GUIDELINE 12.3 Properly partition a long list into a hierarchy of shorter lists to
facilitate selection.
300 Part III Modeling and Design of Interactive Systems
Example. Partitioning all countries according to their continents facilitates the user
to locate a country. Sometimes, an enormous amount of information needs to be
displayed. In these cases, abstraction and classification techniques should be ap-
plied. Abstraction means suppressing unnecessary detail to focus on a high-level
view of the information. It allows for navigation from a high-level view down to
detail. Classification partitions the information into a number of categories and sub-
categories. The following guidelines should be observed when designing information
displays.
Example. The Search for Overseas Programs use case of the Study Abroad Man-
agement System (SAMS) may return all programs in the database. In this case, the
application of abstraction would display a list of high-level summaries of the programs
and let the user click a program link to view the program details.
(4) Implement
a prototype
(optional)
Actor-System
Interaction
Modeling (1) Identify major system
Expanded
(Chapter 8) displays
Use Cases
do not contain other states. Composite states, or states that contain other states, are
considered an extension.
A part of the requirements for the state diagram editor that serves our purpose is
given as follows: “The state diagram editor shall allow a user to edit a new diagram
or an existing diagram. The editor shall allow the user to add, delete, and edit states
and transitions as well as undo and redo these operations. The editor shall allow the
user to perform other editing operations including saving a diagram and saving a
diagram as.’’
As described above, the information needed by the user interface design steps
is derived from the expanded use cases produced in the actor-system interaction
modeling step of the current increment. To illustrate, Figure 12.4 shows the Edit State
Diagram expanded use case for the state diagram editor. For simplicity, it does not
show delete operations.
FIGURE 12.5 Major system displays for the Edit State Diagram use case
1. Examine the steps in the right column of each expanded use case. A major system
display is identified if
a. the step displays system processing result, in this case, the displayed infor-
mation is also identified, or
b. the step requests the user to supply input (text, selection, or other type of input).
2. Examine the steps in the left column of each expanded use case to identify user
input and user actions associated with each system display.
•
Identify system displays, the information they display, and user input and user EXAMPLE 12.1
actions for the Edit State Diagram expanded use case shown in Figure 12.4.
Solution: Applying the above rules identifies the system displays, the information
displayed, and the user input and user actions as shown in Figure 12.5.
•
Note that in many cases, the expanded use case specifications may not be as
detailed as the use case displayed in Figure 12.4. For example, the interaction steps
may not show the lower-level options. However, the expanded use case still specifies
the system displays although not all of the lower-level widgets are explicitly specified.
304 Part III Modeling and Design of Interactive Systems
In such cases, the lower-level widgets are identified from experience, similar projects,
or during the draft layout design.
•
EXAMPLE 12.2 Identify windows, dialog boxes, and their widgets from Figure 12.5.
Solution: The result is shown in Figure 12.6. The windows and dialog boxes are
already identified. But some of them can use a file chooser. A diagram canvas is
used to display a state diagram.
Two edit dialog boxes are used; one for editing a state and the other for editing
a transition. These dialog boxes contain text fields and text areas to allow the user
to edit state and transition attributes. The state and transition attributes are found
∨ from either the expanded use cases or the domain model. The solution shown in
Figure 12.6 assumes that a state has a name and a state condition and a transition
has a name and transition code. The attribute type is used to look up the widget
from Figure 12.2.
The next activity is producing a draft layout design for the windows and dialog
boxes. This is a creative activity, depending on the application on hand. As a rule
of thumb, the layout design should follow the widely used layout design in the
industry or the application domain if that standard layout exists. This reduces the
user’s learning curve. For example, there are consensus layout designs for the user
interfaces of IDEs and document editors. For some other applications, custom look
and feel is needed, taking into account the nature of the application. The design in
Figure 12.1 is an example.
FIGURE 12.7 Design of the main window for a state diagram editor
The draft design produced in this step could be a set of drawings on a piece
of paper, produced by using a slide show tool or a word processor, implemented
using a prototyping tool, or implemented in the target implementation language.
Figure 12.7 shows the Java implementation of the layout design for the Editor
Main Window. If the user double-clicks a state or transition, a dialog that lets the
user edit the state or transition appears. Figure 12.8 displays the Edit State Dialog
when the user double-clicks the State 0 state.
∨
306 Part III Modeling and Design of Interactive Systems
diagram and the expanded use cases. That is, the expanded use cases and the state
diagram should describe the same behavior.
The states may be annotated with the windows and dialog boxes they display, as
shown in Figure 12.9 for the initial state. This technique has a number of advantages,
as follows:
• It helps the developer to visualize the transition from one display to another.
• It is useful for checking the correctness of the state diagram—that is, does the state
diagram correctly model the transition from one display to another corresponding
to the user input and user action?
• It is useful for completeness checking to ensure that there is an outgoing transition
for each important user action that can be performed in the state. For example,
the Edit State Dialog has three buttons, therefore, the annotated state should have
three outgoing transitions. The state in Figure 12.9 indeed has three outgoing
transitions that correspond to these three user actions.
• Tools can be used or implemented to generate an animated prototype to demon-
strate the behavior of the GUI.
1. Static approaches generate nonexecutable prototypes. That is, the layout design
of windows and dialog boxes are depicted on paper, using a slide show tool,
or a word processor. The drawings are presented to users while the designer
explains the functionality and behavior of the system. Sophisticated slide shows
can animate the behavior to improve communication.
Static prototypes are similar to architectural models in the construction indus-
try. These scaled-down physical models are created to communicate the design
ideas for major construction projects. Static prototypes are relatively inexpensive
to construct and serve to communicate the layout design. However, they are not
effective in showing the behavioral aspect of the system. Another drawback is
that the prototype cannot evolve into the final system.
2. Dynamic approaches generate executable prototypes using a prototyping tool,
implemented in a scripting language or the implementation language. Dynamic
prototypes can demonstrate the interaction behavior at different levels of
308 Part III Modeling and Design of Interactive Systems
The state diagram constructed in the last step greatly simplifies the implementa-
tion of the prototype because the prototype shows the system display associated with
each state. When a transition takes place, it enters the destination state and shows the
system display of that state.
• User interfaces of existing systems. Users are used to the existing systems because
they have worked with the existing systems for many years. Users may not be
willing to change to the new user interface.
• The nature of the business. Some applications emphasize processing speed, such
as the retail shipping business discussed above. Mother’s Day, Valentine’s Day,
and Christmas Day are the busiest shipping seasons of the year in United States.
Fifty percent of the shipping volume of the year occurs during the Christmas
season, and the last three days are the busiest of the season. Speed is critical to
the retail shipping stores because customers go to other stores if it takes a long time
to ship a package. Some other applications emphasize accuracy, reliability, and
security. For instance, medical record management systems must ensure accuracy
and security of the medical records. These systems must also ensure that alert
messages are correctly scheduled and timely delivered to doctors and nurses.
Some applications emphasize other aspects. Only the users can tell whether a
user interface design can meet their needs.
• User psychology. User psychology is a combination of many different factors
including tradition, community culture, educational background, work experi-
ence, and gender. For example, the color red gives a striking effect and is used
as a warning color in the United States. If the price of a stock, mutual fund,
Chapter 12 User Interface Design 309
or exchange traded fund is lower than yesterday, the price of the security is
displayed in red. However, red is a fortunate color in Asia, especially in China,
Japan, Korea, and Southeast Asia. It is used to color the prices of up securities
in the stock market. These are well-known cultural conventions and are easy to
determine. Only the users can decide whether a user interface design violates,
or is inconsistent with, organization-specific conventions. For example, hospi-
tals and clinics use different colors to highlight the items in a medical record.
If a user interface design provides such a capability, then the use of color must
be consistent with the existing convention. This can only be verified by the
users.
• Personal preferences of the users. Different users have different preferences,
which influence the acceptance of the user interface design. Again, only the
users can verify this.
The above discussion indicates that it is important to evaluate the user interface
design with the users, solicit their feedback, analyze the feedback, and modify the
design according to the feedback. The following are some of the approaches to evaluate
the interface design with the users:
1. User interface presentation. This evaluation approach is used with static proto-
types. Beginning in the initial state, a developer presents the functionality of the
system by showing the windows and dialog boxes while tracing the transitions of
the state diagram. The users are encouraged to ask questions, make comments,
and provide change requests. These are noted and addressed later. This process
is iterative and uses depth-first traversal until all of the transitions of the state
diagram are traversed.
2. User interface demonstration. This approach is used with static prototypes as well
as dynamic prototypes. In this approach the developer explains and demonstrates
the features of the system using the prototype. User feedback is collected and
used to improve the design.
3. User interface experiment. This approach is used to evaluate a dynamic prototype.
The developer demonstrates the prototype and lets the users experiment with the
prototype for a period of time. The users then provide feedback and change
requests. These are addressed by the development team later. Well-written lab
manuals, user training sessions, and/or user support personnel can improve the
effectiveness of this method.
4. User interface review meeting. This approach involves user interface design ex-
perts, domain experts, user representatives, and developers. Before the review
meeting, the participants are required to attend a user interface presentation,
experiment with the prototype, or review the layout and behavior design. The
participants should answer a list of review questions (see Section 12.4.7). At
the meeting, the participants exchange their review results and discuss possible
ways to improve the design. Action items are identified and assigned to individual
developers, who are required to report how the action items are resolved.
5. User interface survey. This approach uses a survey questionnaire to solicit feed-
back from the users, user interface design experts, and domain experts. The
310 Part III Modeling and Design of Interactive Systems
questionnaire should be brief and focus on important issues of the user interface.
Review and survey questions should focus on obtaining feedback about: (1) ease
of learning and using the system, (2) overall appearance of the interface, (3) ef-
fectiveness and efficiency of carrying out business tasks with the system, (4) use
of language and terminology, (5) error handling and error messages (i.e., is error
handling effective, are the error messages helpful to the users?), and (6) help
facility and documentation (such as tutorial and user guide). The participants
should be asked to choose an answer from a relative scale such as “very good,”
“good,” “average,” “below average,” and “poor.”
converted into one-column text. Screen shots of the windows and dialogs are included
to show the system responses.
A user-friendly design of online documentation should let the user find the needed
information easily and quickly through browsing the table of contents and indices,
navigating from one place to another, and searching for a desired topic. These features
can be easily provided by the use of web pages. Context-dependent help provides help
information that is relevant to the context. For example, the user may right-click in
the State Condition text area in Figure 12.8 and select Help in the pop-up menu. The
system should display the help information that is specific to the editing of a state
condition. If the help information about the State Condition text area is not available,
then the system should display help information about the Edit State Dialog, or help
information about the State Diagram Editor.
The subsystem to provide context-dependent help consists of a hierarchy of
help request handlers, organized as a tree or lattice. Each handler is responsible for
providing help information for a given topic and knows only its parent node as its
successor. The root of the tree provides information about the software system and has
no successor. The leaf nodes of the tree provide information about the most specific
topics such as the State Condition text area. When requested, a handler returns the
help information if it has it; otherwise, it forwards the request to its successor node. In
this way, the most specific help information can be provided by the chain of handlers.
The chain of responsibility pattern presented in Part V (Applying Situation-Specific
Patterns) facilitates the implementation of this context-dependent help capability.
The design of error messages is another important task of user interface design.
Many software engineers confuse an error message with a debugging message. Error
messages such as “a bug has occurred in the script function foo() . . . ” or “illegal oper-
ation in line 429” are useful for the developer to locate the bug but are not informative
for the end user at all. Error messages should be user-oriented, not developer-oriented.
They should tell the user what goes wrong and what the user can do to move on.
One important capability of a software system is its ability to recover from an
undesired state. The most common and easy-to-achieve recovery capability is the
ability to undo and redo certain operations. This can be accomplished by using the
command pattern. A more sophisticated capability to recovery is the provision of
automatic backup of important data sets as selected by the user. This allows the data
to be restored when it is so desired. This capability can be accomplished by using the
memento pattern. Finally, the system may be designed with software fault tolerance to
provide the capability of automatic recovery from an undesired state, which is entered
for various reasons, including exceptions, erroneous operations, or software fault.
concrete advise on how to carry out a specific task. In this sense, a guideline is a
lower-level principle. For example, “keep it simple and stupid” is a design principle
because it provides general advice and requires the designer to properly apply it
in different contexts. In comparison, “windows, dialog boxes, and web pages should
have a simple and easy-to-understand look and feel” is a guideline because it provides
specific advice on the design of look and feel.
The design for change, separation of concerns, information hiding, high cohesion,
low coupling, and keep it simple and stupid software design principles are applicable
to user interface design. These principles imply that GUI objects should be decoupled
from business objects. This prevents changes to one of them from affecting the other.
An example that violates these design principles is a GUI object that is responsible
for presenting the widgets as well as handling the action events. Such a tight coupling
makes it difficult to modify the software to respond to changes in requirements. How
to decouple the GUI from the business objects was discussed in detail in Chapter 10
(Applying Responsibilities-Assignment Patterns).
As another example, the separation of concerns principle suggests that buttons
and menu items of a user interface should be grouped according to different concerns.
For example, it is a common practice to classify menu items into File, Edit, View,
Tools, Help, and other concerns. The keep it simple and stupid principle advises us
that the user interface should be easy to learn and use. In this regard, several guidelines
should be followed.
This means user interfaces should be user friendly—they should provide a user-
familiar look and feel, use user’s language and terminology, be easy to learn, under-
stand, and use, keep the user informed about what is going on, supporting undo and
redo, and support different levels of users.
This means consistency in the look and feel of windows, dialogs, and widgets,
consistency in the use of terminology, consistency in information-processing activities
and their results, and consistency with the overall system. For example, although there
is more than one way to perform a copy-and-paste operation, the requests should be
processed in the same way and produce the same result. As an example of consistency
with the overall system, consider, for example, the Study Abroad Management System
(SAMS). Its web pages should have the same look and feel as the web pages of the
Office of International Education (OIE) because OIE operates SAMS. This provides
the visitor with a consistent navigation experience.
GUIDELINE 12.8 Minimize switching between mouse mode and keyboard mode.
Frequent switching between mouse clicking and keyboard typing during the
performance of a business task makes the user busy and less productive. Therefore,
Chapter 12 User Interface Design 313
a user-friendly interface should reduce the need to switch between the two input
modes.
Software engineers have a tendency to give the users “nice features” regardless
of whether the users want them or not. This happens to functionality as well as to user
interfaces. For example, some software comes with an intelligent assistant wizard
that automatically pops up all the time to offer help. The fact is that it really did
not help much. A pop-up message that constantly reminds the user to do something
such as run an update is disturbing and counterproductive. One version of UNIX
for example, offers automatic command line correction. But 99% of the time, the
suggested correction does not make any sense. The worst thing is, there is no way for
the user to turn off this “nice” feature.
Many products are not user friendly because the designer never seriously uses
the product. This guideline suggests that the user interface designer and programmer,
or someone acting on their behalf, should seriously use the software, and have the
user interface problems corrected, before releasing it to the end users.
The user interface affects all users’ interaction with the system, as well as, the
users’ productivity and work quality. These, in turn, affect all stakeholders including
the employer of the users. Therefore, user interface design should actively involve
a variety of users. Moreover, the team should focus on users of the use cases that
implement high-priority business processes. Today, all businesses are highly compet-
itive. This means that the users may not have the time to review and experiment with
the user interface and provide feedback. Therefore, collaboration of the stakeholders
is essential. The project should seek the support of the stakeholders to allocate user
representatives to actively work with the team to design the needed user interface and
help the team collect users’ feedback. This should significantly reduce the need to
change the user interface later.
Change to the user interface requires considerable rework. This agile principle
suggests that the iteration duration must not be extended due to the rework. In-
stead, the team should negotiate with the customer and users to identify low-priority
314 Part III Modeling and Design of Interactive Systems
requirements to take out in order to make room for the rework. The 80/20 rule sug-
gests that there are always such requirements. This also illustrates the importance to
prioritize the requirements and update the priorities after each iteration.
These principles help reduce the amount of rework because the users’ needs
and the real user interface requirements can be identified early and quickly. That the
increment is small implies that the problem can be addressed easily.
GUIDELINE 12.14 A good enough user interface design is enough. Value the
working software over the design.
Applying this principle to a user interface means capturing the user interface
requirements at a high level, making them lightweight and visual. As discussed in
Guideline 12.14, the users know what they want through “seeing is believing.” There-
fore, capturing the requirements at a high level and making them lightweight is good
enough. The nature of the user interface means that it is more effective to capture
these requirements using a visual means such as sketches, user interface prototypes,
and screen shots.
SUMMARY
•
This chapter begins with an introduction to user in- gram editor. GUI design is a supplement to the actor-
terface design and the importance of a user interface system interaction modeling presented in Chapter 8.
to the success of a software project. The importance GUI prototypes are used along with expanded use
is explained with real-world stories. GUI widgets are cases to facilitate solicitation of user feedback. GUI
then presented along with their usefulness. The chap- design and actor-system interaction modeling should
ter also presents a user interface design process and be performed simultaneously for them to benefit from
guidelines. The process is explained with a case study each other.
that produces a user interface design for a state dia-
FURTHER READING
•
The book by Johnson [93] contains additional design rules Tidwell [150] presents best practices of user interface de-
and guidelines for user interface design. The Essential sign as design patterns, which are reusable for application
Guide to User Interface Design by Wilbert O. Galitz [66] development. References [83, 84] are good sources for GUI
presents user interface design from a user’s perspective and programming using Java Abstract Window Kit (AWT) and
provides more than 300 case studies as well as design guide- Swing.
lines for web-based applications and mobile devices. Jenifer
EXERCISES
•
For each of the following use cases, first produce an ex- 12.1 The Reserve a Car use case for an online car rental
panded use case description if you have not done so in application. A description of such an application is
previous chapters. Then perform the user interface de- presented in Appendix D.1.
sign steps to produce a user interface design for the use 12.2 The Login use case. When the user logs in the first
case. time, the system shall direct the user to a page to
316 Part III Modeling and Design of Interactive Systems
define authentication questions to be used when the mailed to the patron. The patron mails the returned
user wants to reset the password in the future. As- books through the mail.
sume that each user needs to define five questions 12.4 In Appendix D.4, a class diagram editor application
and provide the answers to these questions. is described. Perform a user interface design for this
12.3 The Checkout Books and Return Books use cases of application.
an online library system that allows the patrons to 12.5 Check the design of the above user interfaces using
check out and return books. The precondition for the user interface design review checklist presented
these two use cases are that the patron has logged in Section 12.4.7. Document any problems detected.
into the system. The books that are checked out are Modify the design to fix the problems.
part IV
Modeling and Design of Other
Types of Systems
Chapter 13 Object State Modeling for Event-Driven
Systems 318
Chapter 14 Activity Modeling for Transformational
Systems 349
Chapter 15 Modeling and Design of Rule-Based
Systems 367
317
13
Object State Modeling for
Event-Driven Systems
modeling and design of event-driven systems. Activity modeling (Chapter 14) is a tool
for modeling and design of transformational systems. While the design of interactive
systems is centered around use cases, the design of event-driven systems is focused
on state-dependent reactions of objects to events of interest. In this chapter, issues
addressed by OSM and the need for OSM are discussed first. Steps for OSM and
UML state diagrams are presented next. The presentation of the state pattern for the
design and implementation of state behavior concludes the chapter. After completing
this chapter, you learn the following:
• The definition of object state modeling.
• The usefulness of object state modeling.
• How to conduct object state modeling.
• How to model state behavior with a state transition table.
• The definition of UML state diagram.
• How to apply the state pattern in object state design.
• How to model and design real-time embedded systems with state behavior.
success of a software project because a team member must know the state behavior of
the objects being designed and/or implemented by other team members. Second, the
state models enable the team members to communicate and collaborate more effec-
tively because a UML state diagram is designed for modeling object state behavior.
As a unified modeling language, UML state diagrams are understood by most soft-
ware engineers. This means that a software engineer can implement state diagrams
produced by another software engineer at another location. Without using state dia-
grams, the engineers have to rely on other communication and collaboration means
that may not be as effective and widely used as UML.
Third, the object state models can be checked for desired properties, for exam-
ple, to ensure that the event-driven subsystem processes each stimulus and sends the
desired messages to the other objects or hardware devices. As another example, it is
desirable to ensure that every state of a state diagram is reachable from an initial state.
Application-specific properties can be checked by verification techniques. Finally, the
object state models can be used to generate test cases to test an implementation as
well as fault analysis to identify transitions that exhibit improper behavior. These sys-
tematic testing and fault analysis methods are more effective than casual approaches
in which the test cases are generated at will and fault analysis is carried out using a
trial-and-error approach.
For example, “ON-OFF button pressed’’ and “an element pushed’’ onto a stack
are events because they are happenings that are of interest to the cruise control sub-
system and the stack object, respectively. The definition implicitly classifies events
into two categories: (1) happenings, and (2) requests. Happenings are events that
already occurred. They often come from outside and are reported to the software
subsystem using a passive voice such as “ON-OFF button pressed’’ or “gas pedal
pressed.’’ Unlike happenings, requests are commands and actions to be performed,
or queries. As such, they are formulated using imperative phrases such as “turn on’’
an air-conditioner. Requests often come from within the event-driven subsystem, that
is, from one component or object of the subsystem to another.
In the above example, Cruise Deactivated and Cruise Activated are two states
of the cruise control subsystem because they are two conditions of the cruise control.
They are entered or exited when the “ON-OFF button pressed’’ event occurs. As for
a stack, EMPTY, FULL, and IN-BETWEEN are states because they denote three
conditions of the stack and they are entered or exited when a request to the stack is
executed.
Chapter 13 Object State Modeling for Event-Driven Systems 321
OSM
design class diagram
(previous iteration)
transition
tables
domain (3) Constructing
model state transition Deriving
tables Design
(4) Visualizing
design state Class
state behavior
diagrams Diagram
(Chapter 11)
(1) Collecting
(2) Constructing information about
a domain model state behavior
design state
(5) Reviewing diagrams
state state models
behavior
information feedback
• Events are indicated by italic font with the rule ID as the superscript, such as
“ON-OFF button Pressed E2 .”
• States are indicated by boldface with the rule ID as the superscript, such as
“Cruise Activated S2 .”
• Guard conditions, response actions, and state activities are underlined with the
rule ID as the superscript, such as “the room temperature is lower than the desired
temperatureG2 .”
•
Figure 13.3 shows the description of a thermostat with classes, attributes, and EXAMPLE 13.1
relationships identified using the rules presented in Chapter 5 (Domain Modeling),
and events, states, guard conditions, and response actions identified using the rules
presented in Figure 13.2. Figure 13.4 lists the concepts identified.
•
EXAMPLE 13.2 Figure 13.5 shows the description of a cruise control with the concepts identified.
Use the cruise control1(a) to maintain3 a constant speed without using the accelerator1(a).
Press the ON-OFF buttonE2,1(a) to activate the cruise control. Press the buttonE2 once more
to deactivateS2 the cruise control. In the activatedS2 mode, accelerate or decelerate to the
desired speed1(e) and push the lever downE2 to set the cruising speedR. To increase or decrease
the cruising speedS5, push the lever1(a) up or down and hold itE2 until the desired speed1(e) is
reached and release the leverE2. To cancelS5 the cruise control, pull the leverE2 toward you
or apply the brake1(a), E2. To resume cruisingS5 to the set speed, push the lever upE2.
Concepts Identified
Classes: Cruise Control Device, Lever, ON-OFF button, Brake, Accelerator (or Throttle), Cruise
Control Software
Attributes: desired speed (of Cruise Control software)
Associations: maintain (Cruise Control Software, throttle)
Events: ON-OFF button pressed, lever down, lever down and hold, lever up and hold, lever
released, lever pulled, brake applied, lever up
States: Activated, Deactivated, Increasing Speed, Decreasing Speed, Cruising Cancelled, Cruising
Guard conditions: NONE
Response actions: set desired speed
State activities: TBD
<<Hardware>> <<Hardware>>
Thermostat Device LCD
heat, <<Hardware>>
<<Hardware>> cool, off data Furnace Relay
Season Switch
position: (HEAT, OFF, COOL) open, status: (CLOSE, OPEN)
close
<<Hardware>> <<Hardware>>
fan, auto
Fan Switch AC Relay
position: (FAN, AUTO) Thermostat status: (CLOSE, OPEN)
open,
<<Hardware>> temp up Control close <<Hardware>>
Temp Up Button Blower Relay
<<Hardware>> temp dn status: (CLOSE, OPEN)
open,
Temp Dn Button
close
<<Hardware>> read
Temp Sensor
Season Switch State Fan Switch State Furnace Relay State AC Relay State Blower Relay State
HEAT COOL OFF FAN AUTO FR CLOSE FR OPEN AC CLOSE AC OPEN BR CLOSE BR OPEN
software to work properly, it must keep track of the states of the hardware devices.
Therefore, the software consists of a number of classes that mirror their hardware ∨
counterparts and maintain the states of the hardware devices. Note that some of
the hardware devices do not have states (e.g., Temp Up Button) or have only one
state (e.g., Temperature Sensor). Therefore, the software does not need to maintain
states for such devices.
The states of each of the hardware devices are identified in the last step.
They can also be identified from the attribute values of classes that represent the
hardware devices. For example, the position attribute of Season Switch has three
values: HEAT, OFF, and COOL. This implies that the Season Switch has three
states: HEAT, OFF, and COOL, as shown in Figure 13.6. The states of the other
devices can be derived similarly. Figure 13.6 also depicts the events going into the
software subsystem and the responses going out of the software subsystem. These
are useful for checking the consistency of the state diagrams.
•
•
EXAMPLE 13.4 Figure 13.7 shows the domain model for the cruise control system discussed in Ex-
ample 13.2. It depicts the cruise control software subsystem and its relationships to
the event sources and response destinations as well as the relationships between its
states and substates. Note that although the Throttle Sensor class has a position at-
tribute, it does not imply a state because the attribute type is double, a quantity value,
not an indication of a state. As shown in Figure 13.5, the system can be in one of two
states: Cruise Activated or Cruise Deactivated. The Cruise Activated state has
four substates. These are displayed using inheritance relationships in Figure 13.7.
The examples illustrate that there are two types of relationships between the
∨ states of an event-driven subsystem:
1. Aggregation relationship: A state is a component substate of another state
because there is an aggregation or association relationship between the corre-
sponding hardware/software components. For example, Season Switch State
is a component substate of the state of Thermostat Control because Season
Switch is a component of Thermostat Device.
2. Inheritance relationship: A state is a specialization substate of another state
because the former is a subclass or a kind of the latter. For example, in Fig-
ure 13.6, OFF, HEAT, and COOL are subclasses or a kind of Season Switch
State, therefore, they are specialization substates of Season Switch State.
The notions of a specialization substate and a component substate will be used in
the following sections when state transition tables and UML state diagrams are
presented.
•
Event
E1 E2 E3 Event stubs list the events.
State
& Substate
S4
State stubs TBD TBD TBD A single-line separates
(init) specialization substates.
show the S2
states. S5 TBD TBD TBD
S1 A double-line separates
S6
TBD TBD TBD component substates.
(init)
Component S3
substate S7 TBD TBD S6 [C] / a1; a2
S9 NA TBD TBD Transition entry, which means: if object is
S8 in S7 and E3 occurs and condition C is
Specialization SA S9 true, then actions a1 and a2 are executed in
TBD TBD
substate this order and object enters S6.
table by a special column that denotes no-event. Note that a transition entry for a
no-event may contain a guard condition and/or response actions. This means that the
no-event transition can take place and the response actions are executed only if the
guard condition is evaluated to true.
•
EXAMPLE 13.5 Construct a state transition table for the cruise control system discussed previously.
Solution: The state transition table is shown in Figure 13.9. In Figures 13.5
and 13.7, there are eight events coming into the cruise control software. These
are shown as the column headings in Figure 13.9. There are also five states, and
these are used to label the rows. In the domain model, Cruise Canceled, Cruising,
Increasing Speed, and Decreasing Speed are specialization subclasses of Cruise
Activated. These are shown in the state transition table by dividing the Cruise
Activated state into four substates and labeling them accordingly. The table also
indicates the initial states with “(init).”
The first row of the table indicates that in the Cruise Deactivated state, the
occurrence of the ON-OFF button pressed event will cause the cruise control to
enter the Cruise Activated state. Since the Cruise Canceled substate is the initial
state of the Cruise Activated state, the cruise control in effect enters the Cruise
Canceled substate. In this state, if the lever down event occurs, then the cruise
control enters the Cruising state and at the same time sets the desired speed (to the
current speed). The reader can interpret the other entries similarly. Note that the
last entry of the last column is a merged entry. It indicates that the ON-OFF button
pressed event causes a transition from the Cruise Activated state to the Cruise
Deactivated state, regardless of which substate the cruise control is in. Figure 13.10
sketches an algorithm for systematically constructing a state transition table. ∨
Chapter 13 Object State Modeling for Event-Driven Systems 329
∨ State
Event Lever Lever up Lever down Lever Lever Brake
Lever up
ON-OFF
button
down and hold and hold released pulled applied pressed
& Substate
Cruise
deactivated NA NA NA NA NA NA NA Cruise
(init) activated
C Cruising Cruising/ Increasing Decreasing
r canceled set desired speed speed NA NA NA Cruising
u
(init) speed
i
s Cruising/
e Cruising Increasing Decreasing NA Cruising Cruising NA
set desired
speed speed canceled canceled
A speed Cruise
c deactivated
t Cruising/set
Increasing NA NA NA NA NA NA
i desired
speed
v speed
a
Cruising/set
t Decreasing NA NA NA NA NA NA
e desired
speed
d speed
2. It allows automatic generation of state diagrams because the state transition table
is an equivalent, tabular representation of a state diagram.
3. It facilitates detection of the following abnormalities:
• Dead state. A dead state is a state that has no outgoing transitions. If an
object enters into a dead state then it will be in that state forever. A dead state
is present if there is a blank row that is not a final state. A dead state should
be analyzed carefully to ensure that it is intended.
• Unreachable state. All states that can be reached from the initial state are
reachable states. A state is an unreachable state if it is not a reachable state.
The transitive closure of the initial state contains the reachable states. A state
that is not in the transitive closure of the initial state is an unreachable state.
• Neglected event. A blank column indicates that the event is not accepted by
any state. It is worthwhile reviewing each entry of that column. If the review
still does not find a state that will accept that event, then it is possible that
some state is missing or the event is not needed for the state transition table.
• Impossible transitions. A transition is an impossible transition if its guard
condition can never be true.
• Nondeterministic transitions. Nondeterministic transitions exist if there is a
transition entry that contains two or more transitions that satisfy the following
conditions:
a. Their destination states are different or their response actions are different.
b. Their guard conditions are not mutually exclusive.
Nondeterministic transitions should be avoided.
• Redundant transitions. Redundant transitions exist if a transition entry con-
tains two or more transitions that differ only in their guard conditions. These
transitions can be replaced by one transition as follows:
Let S[C1]/A, S[C2]/A, . . . , S[Ck]/A be the transitions that differ only in
their guard conditions and none of Ci is always false. If C1 OR C2 OR . . . OR
Ck is always true, then replace the transitions by S/A, else replace the transi-
tions by S[C1 OR C2 OR . . . OR Ck]/A. Moreover, a condition can be dropped
if it is implied by other conditions.
• Inconsistent transitions. Inconsistent transitions exist if a transition entry
contains two or more transitions with equivalent guard conditions. These
transitions are inconsistent because the same event, under the equivalent guard
condition, can cause the object to enter into different destination states or
perform different response actions.
Definition 13.3 A UML state diagram is a behavioral diagram that shows state
behavior as a hierarchy of concurrent, communicating state machines, each of
which depicts the states, state transitions, and response actions associated with the
state transitions.
Chapter 13 Object State Modeling for Event-Driven Systems 331
Notion Notation
Simple state: A state that does not contain other states. A state
is a condition or situation of a subsystem/object.
Initial state: A pseudo state to start with.
Basic Final state: A state that indicates the completion of the state
State machine.
Diagram Transition: A transition from one state to another caused by
an event.
Transition label: It indicates that when event e occurs and the
guard condition expr is true, then the state transition takes e[expr] /a1; a2
place and the response actions a1; a2 are executed.
Composite sequential state (CSS): A state that is composed of
one region of states related by state transitions. At most one of
the states can be active at any given point in time. Specialization
substates and their parent state are visualized with CSS.
Composite concurrent state (CCS): A state that is composed of
more than one region of states related by state transitions. Two
or more states, each from a different region, can be active at
Advanced the same time. Component substates and their aggregate are
Features visualized with CCS.
Shallow history state: It indicates to return to the most recently
active substate of its containing state but not the substates of H
that substate.
Deep history state: It indicates to return to the most recent
configuration of active substates of its containing state and H*
recursively all of the substates of the containing state.
FIGURE 13.11 Commonly used UML state diagram notions and notations
The last three steps collect and classify state behavior information, construct a
domain model to show the event-driven subsystem and its context as well as relation-
ships between the states. State transition tables to document the state behavior are
also constructed. In this step, the state behavior are visualized using UML state dia-
grams. Figure 13.11 shows the commonly used notions and notations of a UML state
diagram. Converting a state transition table to a state diagram is an easy task. First,
the states and their substates are drawn. Specialization substates are placed within
the boundary of their parent state. Component substates are represented by dividing
their aggregate state into N regions separated by dashed lines, where N is the number
of component substates. Next, for each transition entry “S1[C1]/a1, S2[C2]/a2, . . . ,
Sk[Ck]/ak” at row S and column E, a transition from state S to state Si is drawn and
the transition is labeled with “E[Ci]/ai, for i=1, 2, . . . , k.” The following examples
illustrate this.
•
Convert the cruise control state transition table in Figure 13.9 to a state diagram. EXAMPLE 13.6
Solution: Figure 13.12 shows the resulting state diagram. This example illustrates
∨ the representation of specialization substates.
332 Part IV Modeling and Design of Other Types of Systems
state
name
Cruise Activated
∨
pseudo
ON-OFF initial state
button Cruising Increasing
pressed Cancelled lever up and hold Speed
Thermostat Control
Off / stopTimer;
Cool / startTimer FAN
FR open
HEAT OFF COOL auto[AC Relay is AR
Heat / startTimer Off / stopTimer; fan / CLOSE or Furnace Relay
AR open BR is FR CLOSE],
close auto [AC Relay is AR
timer off [roomTemp > setTemp]/
timer off [roomTemp > setTemp]/ OPEN and Furnace Relay
FR open,
AR close, is FR OPEN] /BR open
timer off [roomTemp < setTemp]/
timer off [roomTemp < setTemp]/
FR close
AR open
AUTO
each has its own component state. Therefore, the oval is divided into five regions
∨ separated by dashed lines. Each region in turn shows its specialization substates
and the transitions between them. Finally, the initial states are indicated.
•
Thermostat Control
and the return type, where the parameters and return type are optional, for exam-
ple, off(), cool(), and auto().
• Translate each guard condition into a conditional expression with function calls,
relational operators, and logical operators. For example, “[AC Relay is AR
CLOSE or Furnace Relay is FR CLOSE]” is translated into “[ACRelay.isClose
() || FurnaceRelay.isClose () ].”
• Translate each response action into a function call. For example, timer.stop() and
ACRelay.open().
used to represent the states of the state machine. Another, nested, switch statement
is used to represent the events. The cases of the inner switch are responsible for
implementing the state transitions, that is, evaluating the guard conditions, invoking
the response actions, and setting the state variable to the destination state. At runtime,
the value of the state variable and the incoming event are used to select the appropriate
case of the inner switch to execute.
The transition matrix approach stores the state transitions in the entries of a
two-dimensional array, which is similar to the state transition table described in this
chapter. Each array entry is either null or stores the guard condition, response actions,
and destination state. The current state is kept in a state variable, which together with
the incoming event, determines the array entry. If the array entry is not null, then the
guard condition is evaluated; if it is true, the response actions are executed and the
state variable is updated.
In the method implementation approach, the state behavior of a class is imple-
mented by member functions that denote an event in the state diagram. The current
state of the object is stored in a state variable, which is an attribute of the class. A
member function may evaluate the state variable and the guard condition and execute
the appropriate response actions and update the state variable.
The conventional approaches are associated with a number of drawbacks. First,
the nested-switch approach has high cyclomatic complexity, a measure of the number
of independent control flow paths in a program. For example, if a state machine has
five states and five events, then in the worst case, there are 5 by 5 or 25 independent
paths. The method implementation approach has the same problem, although it is
slightly better; the complexity is the number of states in the state machine. High
complexity makes the code difficult to comprehend, test, and maintain. The transition
matrix uses an interpretation approach rather than a compilation approach. Therefore,
it is not as efficient.
Second, changes are difficult to make. For example, using the nested-switch
approach, each case of the outer switch must be changed in order to add or delete an
event. If the changes are not made consistently, the system will not behave properly.
Third, it is not easy to implement in the conventional approaches state diagrams that
contain composite states. One problem is higher cyclomatic complexity introduced
by composite states. Another problem is the difficulty in implementing concurrent
state machines using the conventional approaches.
state:= state.t3(self);
if (g) {
S0 S1 // do t3 work
// do t1 work
return new S1(); t1(s:Subject):State t2(s:Subject):State return new S0();
t3(s:Subject):State }
Behavioral
: Client : Subject : State
It does work
ti(), state:= for ti and
i=1,2, ...,5 ti(self) returns the
destination state.
Roles and • State: It defines a method for each transition in the state machine and implements it as “return self.”
responsibilities • S0, S1: These represent the concrete state. There is one such concrete state for each state in the
state machine. Each concrete state implements the transitions going out of the state. The
implementation does the work for the transition and returns the destination state.
• Subject: It represents the object that possesses the state dependent behavior. It provides the
client interface and defines an operation for each transition in the state machine. It maintains
a reference to a State object, which represents the state of the Subject. It delegates the client
requests to the corresponding operations of the State object. The call automatically updates the
state of the Subject.
• Client: It represents the event sources such as window events, sensors, etc. It calls the
operations of Subject to process the events.
Benefits • It reduces the complexity of the design and implementation of the state dependent behavior.
• It is easy to add and remove states and transitions.
• It makes the state behavior easy to understand, implement, test and maintain.
• It facilitates test driven development because the behavior is easier to test and the state classes
exhibit clear dependencies.
Liabilities More classes to design and implement.
Guidelines • Apply the state pattern to objects that have nontrivial state behavior, or the state behavior
will evolve in the future.
Related Patterns • The pattern is useful for implementing use case controllers that need to maintain use case states.
• Concrete state objects are often implemented as. Singletons.
• Memento can store the state of a complex object.
• Mediators are often state dependent. State can be applied to design and implement such mediators.
Uses The pattern is useful for design and implementation of event-driven systems, especially
embedded systems.
336
Chapter 13 Object State Modeling for Event-Driven Systems 337
FIGURE 13.16 Mapping between the state pattern and a state machine
1. Define a Subject class with client interfaces to correspond to the state machine.
The interfaces are identified from the events coming into the subject or one of
its components in the domain model constructed in step 2. Each of these client
interface functions delegates the request to the State object. For example, the
domain model in Figure 13.7 shows eight events going into the Cruise Control
software; therefore, the Cruise Control subject class in Figure 13.17 has eight
functions. The functions can also be identified from the state diagram, that is,
from the events that label a transition going out of a CSS state or one of its
substates.
2. Create a root class for the hierarchy of state classes to represent the states of
the Subject. The member functions of this root class are identified from the
client interface of the Subject class, the domain model, or the state machine
338 Part IV Modeling and Design of Other Types of Systems
Figure 13.18 shows the state pattern for the Thermostat Control state diagram in
Figure 13.14. This example shows that applying the state pattern to a state diagram
containing a CCS is similar. The differences are as follows:
HEAT
FR OPEN AR CLOSE
close(t:ThermostatControl) BR CLOSE BR OPEN open(t:ThermostatControl)
open(t:ThermostatControl) close(t:ThermostatControl)
FR CLOSE AR OPEN
Fan Switch
open(t:ThermostatControl) close(t:ThermostatControl)
fan(t:ThermostatControl)
auto(t:ThermostatControl)
fanSwitch
FAN AUTO
auto(t:ThermostatControl) fan(t:ThermostatControl) br.close(t);
t.fanSwitch:=new Fan();
Control A control process, which is modeled by a Mealy type state machine and represents the
Process state dependent behavior of a system
State A state machine that is encapsulated in a control process and models the state
Machine dependent behavior of the system
Control Flow An event flow or control flow that triggers a transition of the state machine of a control
process, or a command from a control process to a transformational process
Real-Time A continuous data flow, which must be processed in real time to avoid buffer data being
Data Flow overwritten by subsequent input data
a
Conjunctive
P Both data flow a and data flow b are required to begin executing process P
Input
b
a
Disjunctive
+ P Either data flow a or data flow b is required to begin executing process P
Input
b
z x
Split Flow Two subsets of z are used by two different successor processes
y
Conjunctive x z
z is composed of two subsets provided by two different predecessor processes
Flow
y
Disjunctive z
All of z is provided by either one of two predecessor processes
Flow
1. Ordinary data flow. These are the ordinary data flows between transform pro-
cesses. For example, in a cruise control system, the ordinary data flow is the
driver-preset rotation rate data used to maintain the coasting speed.
2. Control flow. These are the flows between a transform process and a control
process. A control flow represents either an event sent to a control process or a
command from a control process to a transform process. An event may trigger one
of the transitions of the state machine. The state transition may issue a command
to control a transform process.
Chapter 13 Object State Modeling for Event-Driven Systems 341
Brake
Record
Resume
Rotation
Enable/disable Rate Rotation rate
Trigger
Cruise 2.2.2
Start/stop
Control
increase speed
2.2.1
Speed reached
Throttle
Enable/
control
disable Return to
Enable/ Previous
disable Enable/ Speed Rotation rate
disable 2.2.5
Throttle
Rotation
position
rate Throttle Maintain
Increase
control Constant
Speed
Speed Rotation rate set point
Throttle 2.2.3
2.2.4
control
Throttle Throttle
position position
Rotation rate
3. Real-time data flow. These are continuous data flows that must be processed in
real time to prevent the data in the buffer from being overwritten by incoming
data, for example, the continuous tire rotation data collected by the sensor.
Besides these, the transformational schema also provides constructs for modeling
conjunctive and disjunctive inputs as well as conjunctive and disjunctive flows (see
Figure 13.19).
•
Figure 13.20 shows the modeling of a cruise control software and the processes EXAMPLE 13.8
that interface with the hardware components. In the figure, the control process
represents the cruise control software while the transform processes represent the
interfaces to the hardware components. The figure also illustrates the use of control
flows and real-time data flows. The behavior of the control process in Figure 13.20
is modeled by a state machine, as shown in Figure 13.21. Note the correspondence
between the control flows that go into the control process and the events that trigger
the state transitions of the state diagram. For example, the resume control flow into
the control process corresponds to the state transition from the Interrupted state
to the Resume Speed state. In addition, there is a correspondence between the
responses or actions of the state transitions and the control flows from the control
process to the transform processes. These represent the commands sent from the
∨ control process to control the hardware components.
342 Part IV Modeling and Design of Other Types of Systems
Enable/trigger “Record ∨
Rotation Rate,” enable
“Maintain Constant Speed
Maintain Speed
Increase Speed
Resume Speed
•
EXAMPLE 13.9 In illustration, Figure 13.22 shows the processing of items on a pipeline. After
initialization, the system enters the Waiting state. When an item arrives, the system
engages the robot to process the item. This must not take more than 5 time units.
The robot then processes the item, which takes from 20 to 80 time units. When
the processing is done, the system dispatches the item, which must not take more
than 5 time units. ∨
Chapter 13 Object State Modeling for Event-Driven Systems 343
∨ Item arrived/
engage robot
[0, 5] Process
Init Waiting
[20, 80]
The specification of timing lower bound and upper bound allows analysis of
timing constraints, which specify the required timing lower bound and upper bound
between the occurrences of one event and another follow-up event. For example,
some types of target tracking system need to process radar returns, update the tar-
get tracks, and display the tracks of multiple targets on the screen in real time. The
constraint on the total time to complete such a sequence of operations must be spec-
ified and enforced. If the system is modeled by using a timed state machine and the
transformational schema, then the total time to complete the required sequence of
operations can be analyzed to ensure that the timing constraint is satisfied. The com-
plexity of timing constraint analysis comes from the fact that many real-time systems
are embedded systems, which involve hardware, software, and human subsystems.
Hierarchical, concurrent, communicating state machines are used to model the state
behavior of components of the system. These state machines run concurrently and
communicate with each other. It is a challenge to identify and specify the sequences
of transitions and the timing constraints on such sequences as well as the analysis to
ensure that the timing constraints are fulfilled. Due to these, timing constraint mod-
eling, specification, and analysis are special topics, which are beyond the scope of
this book.
H H*
Get Next Grade Test
Test Get Next Grade Test Get Next Grade Test
Grade Test Test
Questions Grade Grade
Display Questions Questions
Test Display Display
Result Test Test
Result Result
Compute
Update Grade Compute Compute
Database Update Grade Update Grade
Database Database
(a) No use of history state (b) Shallow history state (c) Deep history state
of the most recently active substate. That is, if the most recently active substate is
Compute Grade, then the system will not be able to resume with this state. Instead,
the system resumes with the initial state of the composite state that contains the
Compute Grade state that is, the Grade Questions state.
A deep history state solves the problem. It is indicated by an H* enclosed in
a small circle. It allows a composite state to return to its most recently active state
configuration. In Figure 13.23(c), if Compute Grade is the most recently active
substate, then when Process Tests is entered, it will resume with the Compute Grade
substate rather than the initial state of Grade Tests.
GUIDELINE 13.1 Work closely with the customer and users to identify and model
the state behavior.
GUIDELINE 13.2 Capture the state behavior at a high level, lightweight, and visual.
Chapter 13 Object State Modeling for Event-Driven Systems 345
The state behavior of an object could be modeled in great detail, or at a high level
and visual. This principle suggests that state modeling should avoid the details if a
high-level, lightweight model is sufficient. For example, error handling and exception
handling are not part of the normal state behavior. These should not be included in
the state diagram—leave them to implementation.
Not all objects with state behavior need a state diagram. A state diagram is needed
only if the state behavior is complex or if the team needs to gain a better understanding
of the state behavior. Complex behavior is due to a large number of states, complex
state transition relationships, or composite state behavior. In these cases, object state
modeling helps the team understand, communicate, and analyze the state behavior.
For many objects, the state behavior consists of only one or two states and a few
simple transitions. For example, a book is checked out or not checked out. In such
cases, constructing a state diagram is a waste of time. State modeling should also be
guided by the “good enough is enough” principle. That is, move on to implementation
when you have gained sufficient knowledge of the state behavior.
SUMMARY
•
OSM is concerned with the identification, modeling, Chapter 5. Both sets of information are used to con-
analysis, design, and specification of state-dependent struct a domain model for the event-driven subsystem.
behavior of objects. OSM is needed because it helps The domain model shows the event-driven software
the development team understand the state behavior. subsystem, its context or environment, and its states
It facilitates team communication and collaboration, and the relationships between the states. These rela-
which are crucial for project success. The state models tionships determine how to structure the states in the
produced by OSM forms the basis for verification and state diagrams that is, when to use CSS and when to
test case generation. OSM is carried out in five steps. use CCS.
In the first step, the team collects and classifies state The state transition table is presented as an aid to
behavior information using a set of rules. Each rule state diagram construction. While the domain model
specifies the phrases to look for in the relevant docu- specifies the structural aspect and the relationships
ments and the corresponding modeling concepts, that between the states, the state transition table provides
is, event, state, guard condition, and response actions. a systematic approach for specifying the state transi-
Also identified are classes, and their attributes as well tions or state behavior. The state transition table fa-
as relationships between the classes, as described in cilitates detection of abnormalities, including dead
346 Part IV Modeling and Design of Other Types of Systems
state, unreachable state, neglected event, impossi- in which the state transitions are formally specified,
ble transitions, nondeterministic transitions, redun- that is, the guard conditions, the triggering events,
dant transitions, and inconsistent transitions. and the response actions are specified using a pro-
Event-driven systems are normally associated gramming language like syntax. The state pattern is
with interrupt handling. Interrupt handling forces an a better design for complex state behavior, especially
object to exit a state and return to it after the inter- for state diagrams with composite states. The con-
rupt is processed. A deep history state can be used ventional implementation approaches and their draw-
to specify that recursively all active substates of a backs are discussed. The state pattern is applied to the
composite state must be saved so that the system can cruise control and thermostat examples to illustrate its
resume with this state configuration later. If there is no usefulness. Finally, the transformational schema and
need to remember the chain of active substates, then the timed state machine for the modeling of real-time
a shallow history can be used. This chapter presents systems are presented.
rules for converting an informal state diagram into one
FURTHER READING
•
An extension and formal treatment of state modeling in- currency, and communication between the state machines.
cluding the specification of timing is found in [135]. Davis It is a revolutionary, rather than evolutionary, extension of
[56] provides an excellent presentation of state machine in a Mealy-type state machine. Statechart forms the basis of
modeling and specification of system behavior. It also com- the UML state diagram, which is presented in [36]. The ex-
pares state machine to other modeling techniques such as tension of a data flow diagram for real-time systems using
decision tables, flowcharts, and Petri nets. Statechart was state machines is presented in [157].
invented by David Harrel [76] to support nested states, con-
EXERCISES
•
13.1 Refine the cruise control state diagram in Fig- When a train approaches the crossing from either di-
ure 13.12 with lower-level state diagrams. Check for rection at a certain distance, a sensor device senses
consistency between the external events and the trig- the train’s arrival and communicates this to the cen-
gering events of the transitions as well as the response tral control. The central control informs the traffic
actions and messages to the external entities. light control, bell control, and gate control.
13.2 Construct a domain model to explain a UML state After receiving the signal from the central con-
diagram that includes CSS and CCS. trol, the traffic light control turns on the flashing yel-
13.3 Apply the steps presented in this chapter to the low warning light for a given amount of time, which
railroad crossing system (RCS) described as the must be long enough to allow the traffic to stop before
following: the crossing. It then changes the light from flashing
An RCS includes a central control that controls yellow to flash red. The bell control turns on the bell.
the traffic light, the bell, and the gate at the crossing. After the red light begins to flash, the gate begins
Chapter 13 Object State Modeling for Event-Driven Systems 347
other error correction keys. The customer uses the the LED displays the total current amount received.
keypad to enter selections, and the operator uses When the required amount is inserted, the customer
it for programming the vending machine. presses one letter key and one digit key to enter his
g. An LED for displaying instructions and system selection. Once the selection is entered, the freezer
responses. dispatches the selected pizza into the microwave. The
The vending machine works as follows. There microwave defrosts the frozen pizza while the LED
are two modes of operation: the programming mode displays “Defrosting.” When the pizza is defrosted,
and the operating mode. The programming mode is it is dispatched into the oven. The oven heats up
entered by pressing a small button on the control while the LED displays “Heating.” The oven begins
board, which can only be reached when the door of baking and the LED displays the remaining bake
the vending machine is open. The door is usually time when the desired temperature is reached. The
locked and only the operator has the key to unlock it. pizza is baked for the predefined period of time and
In the programming mode, the operator presses one dispatched into the delivery window.
letter key and one digit key to program a selection. Apply the steps described in this chapter to
The LED displays the blinking bake temperature. The develop the pizza vending machine. Modify the
operator enters the new temperature or leaves it un- description to take care of exceptions and error
changed, and presses the Enter key. The LED dis- conditions.
plays the blinking bake time in minutes. The operator 13.8 Extend the pizza vending machine to allow online or-
enters the new bake time or leaves it unchanged, and dering and perform the development for the extended
presses the Enter key. The LED displays the blinking vending machine. The system needs a compartment
price. The operator enters the new price or leaves it as to keep the baked pizza warm and moist. To use this
it is and presses the Enter key. The operator repeats feature, the customer must open an online account
these steps to program all of the selections. The pro- with a credit card payment or online payment ser-
gramming mode is exited when the operator presses vice. The customer must login to place an order. The
and holds down the E key for five seconds, or when system displays an approximate pick-up time. The
there is no keypad activity for more than ten seconds. customer may choose if a notification message will
In the operating mode, a customer inserts the be sent when the pizza is ready. The customer must
valid bills or coins into the slots of the bill and login and use the pass code to retrieve the pizza that
coin acceptor. Each time a bill or coin is inserted, is ordered.
14
Activity Modeling for
Transformational Systems
Chapters 9 and 13 presented object interaction modeling (OIM) and object state mod-
eling (OSM). These are two of the three behavioral modeling tools of UML. OIM is
concerned with the modeling and design of interactive systems while OSM addresses
the modeling and design of event-driven systems. In this chapter, the other behavioral
modeling tool—activity modeling—is presented. Activity modeling is concerned with
the modeling and design of transformational systems that exhibit sequencing, con-
ditional branching, concurrency, and synchronous as well as asynchronous behavior.
A compiler is an example that exhibits a sequence of activities. These activities in-
clude lexical analysis, syntax analysis, code generation, and code optimization. The
lexical analysis activity analyzes the source code and produces a stream of tokens;
each is associated a token type such as identifier, reserved word, operator, and the
like. The token stream is the input to the syntax analysis activity, which checks to
ensure that the syntax of the source code is correct. This activity produces a syntax
tree, which is input to the code generation activity, which produces the executable
code and sends it to the code optimization activity. The code optimization activity
analyzes and improves the performance and efficiency of the executable code.
Another area to apply activity modeling is workflow management such as sys-
tem engineering (Chapter 3). System engineering begins with system requirements
analysis activity, which produces the system requirements specification, a system
architectural design, and an allocation of system requirements to the hardware, soft-
ware, and human subsystems. After system requirements analysis, three concurrent
activities take place. These are hardware subsystem development, software subsys-
tem development, and human subsystem development. System integration and testing
349
350 Part IV Modeling and Design of Other Types of Systems
take place when all these three development activities are completed, that is, a joining
of three threads of activities. During system integration and testing, the team may dis-
cover major requirements or design problems. If this is the case, then the team should
backtrack to a previous activity. This is called a conditional branching. If no problem
is discovered during integration and testing, then the next activity, such as system
acceptance testing, is performed—another conditional branching. After completing
this chapter, you will understand the following:
• Activity modeling.
• Usefulness of activity modeling.
• The evolution of activity modeling techniques.
• UML activity diagram.
• Steps for activity modeling.
Workflow management systems are such systems where a request may go through
several stages of processing by different departments, and may require decision mak-
ing, synchronization, and concurrent processing. Consider, for example, the process-
ing of an online application in the Study Abroad Management System (SAMS). After
an online application is submitted, a number of information processing activities take
place. These include obtaining faculty references and academic advisor approvals,
reviewing the online-application package by an advisor of the Office of International
Education (OIE), scheduling an interview with the student, contacting the overseas
program, and conducting a post-acceptance orientation seminar for the students who
will study at an overseas institution. Each of these activities takes place at a certain
Chapter 14 Activity Modeling for Transformational Systems 351
point in time and requires a certain amount of time to process. Some of these activi-
ties may take place simultaneously and some of them may need to be synchronized.
For example, obtaining faculty references and obtaining academic advisor approvals
may take place simultaneously while the post-acceptance orientation seminar needs
to synchronize with the processing of all of the applications.
14.3.1 Flowchart
Flowcharts are used to model information processing activities for a long time. A
flowchart is a graph consisting of processing nodes, decision nodes, and directed edges
between these two types of nodes. A processing node represents a computation or
information processing activity. A decision node evaluates a condition and branches
to a particular node according to the outcome of the evaluation. A directed edge
represents a control flow from one node to another. Figure 14.1 shows a flowchart
for determining if an integer n is prime, where a processing node is represented by
a round-corner rectangle, and a decision node by a diamond. The flowchart has two
special nodes to indicate the begin and end of the procedure.
Begin
i=2
i>=n n is prime
yes
no
no
i=i+1 End
p1 p1 p1 p2 p1
t1 t1 t1 t2 t1 t2
p2 p2 p3 p3 p4
p2 p3
t2 t2 t3 t3
p3 p4 p5 p6
(a) Sequencing (b) Forking or parallel threads (c) Joining or synchronization (d) Mutual exclusion
shows a Petri net, where places are represented by circles and transitions by bars.
Figure 14.2(b) assigns meaning to the places and transitions. In particular, the places
represent conditions while the transitions represent events. Tokens can be assigned to
places. If a place contains a token, then it is active and the condition is true; otherwise
it is inactive and the condition is false. A transition can fire if each of its input places
contains a token. A transition fires by removing one token from each of its input
places and places a token into each of its output places.
Petri net can model different system behavior including sequencing, parallel pro-
cessing, synchronization, and mutual exclusion, as shown in Figure 14.3. In particular,
Figure 14.3(a) means that the two transitions must fire in sequence. That is, the events
must occur in sequence. Figure 14.3(b) indicates that after t1 fires, p2 and p3 become
active; and hence, t2 and t3 can fire. That is, the two events can occur in parallel. This
is also called forking. Figure 14.3(c) means that t3 cannot fire until t1 and t2 have
fired. It merges the two concurrent threads; hence, it is called joining. Figure 14.3(d)
represents mutual exclusion because only one of t1 and t2 can fire if p1 contains only
one token.
Advisor
application is sent, through the partial application data flow, to the Obtain Support
Materials process. That process obtains the support materials and stores the (com-
pleted) application in the Applications data store. The Review Application process
retrieves and reviews the applications and provides feedback to the Student, an exter-
nal entity.
The data flow diagram modeling tool supports the divide-and-conquer software
engineering principle. That is, a process can be decomposed into or refined by a net-
work of lower-level processes. In illustration, Figure 14.4(b) shows a decomposition
of the Obtain Support Materials process. The diagram shows that the high-level pro-
cess is refined by four lower-level processes, each of which performs a specific task.
The decomposition of a process must obey consistency rules:
1. For each data flow going into the higher-level process, there must be a corre-
sponding data flow going into the lower-level data flow diagram resulting from
decomposition.
2. For each data flow going out from the higher-level process, there must be a cor-
responding data flow going out from the lower-level data flow diagram resulting
from decomposition.
Consider, for example, the decomposition in Figure 14.4(b). The higher-level
process has one input flow and one output flow. These two flows are present in
Figure 14.4(b); therefore, the decomposition is consistent with the higher-level pro-
cess. Note that the lower-level diagram introduces two new flows: “request” to Faculty
and “reference info” from Faculty. This does not violate the consistency rules because
a lower-level diagram is a refinement of a higher-level process. Refinement often re-
veals more detail including introduction of new flows.
Chapter 14 Activity Modeling for Transformational Systems 355
Create
Joining Archive Project
Proposal [else] [approved]
Account
Prepare Establish
Hiring Project
Forking
Set Up New
d: Account
Account
Object
flow
Submit Hiring Process
r: Hiring
Request Hiring
Request
Request
Proposal activity has an outgoing arrow to a final node. This means that the workflow
is terminated when the Archive Proposal activity is completed.
Now turn to the Establish Project activity. It has an outgoing edge to a forking
node. This means that after the Establish Project activity is completed, the control flow
splits into two concurrent threads. One of the threads is executing the Prepare Hiring
activity by the project team. The other thread is performing the Create Project Account
activity by the accounting department. Since these two activities are performed by
two different organizational units, they tend to finish at different times. However,
the joining node in the leftmost swim lane indicates that the project team must wait
until both of the Prepare Hiring and Create Project Account activities are completed
to perform the Submit Hiring Request activity. This is because the human resource
department requires that the hiring request to contain both a job description and an
account number to process the Hiring Request.
Step 1.
Identify information processing activities as well as their input and output. The
output of this step is the activities identified along with their input and output,
and the organizations in which the activities are performed.
Chapter 14 Activity Modeling for Transformational Systems 357
Activity
Modeling
activity
diagram Deriving
Design
(3) Introducing Class
preliminary branching, forking Diagram
activity and joining. (4) Refining
(Chapter 11)
diagram complex
activities. activity
diagrams
(1) Identifying
information
processing
(2) Sketching a activities. activity
(5) Reviewing
preliminary activity diagrams
activity
diagram. info. diagrams.
processing feedback
activities
Step 2.
Sketch a preliminary activity diagram. The output of this step is an activity
diagram showing the activities and the control flows and object flows.
Step 3.
Introduce conditional branching, forking, and joining. In this step, the preliminary
activity diagram is augmented with conditional branching, forking, and joining
to express alternating flows, concurrent processing, and synchronization. The
output of this step is an activity diagram that adequately describes the business
process.
Step 4.
Refine complex activities, if desired. In this step, activities that are too complex
to understand, design, or implement are refined by additional activity diagrams.
The output of this step is a hierarchy of activity diagrams.
Step 5.
Review the activity diagrams. In this step, the activity diagrams are reviewed to
ensure correctness and consistency.
about the business activities. In particular, the information collection process focuses
on answers to the following questions:
FIGURE 14.8 CPT description with activities, performers, and input/output highlighted
10 Determine Eligibility OIE • Current I-20 (9) [eligible]/[else] 11/ Final Node
{within 7–10 business days} • CPT Academic Advisor
Recommendation Form (9)
• CPT Student Form (9)
11 Issue New I-20 OIE [eligible] New I-20 (12) Begin CPT
6. The Next Activity column specifies the successor activity ID number. If the
completion of the current activity forks into two concurrent threads of activities,
such as activity 5 Get Internship Letter, then the concurrent successor activities
are separated by the “&&” signs. For example, the last entry of activity 5 is “6
&& 7.” This means that the completion of activity 5 forks into two threads, one
goes to activity 6 and the other goes to activity 7.
4. Submit Prospective
Employer’s Info
Office of
International : Current I20 : CPT Advisor Form : CPT Student Form :New I20
Eduction (OIE)
2. Draw the activities for the performers. If the activity table is filled while reading
a workflow description, then the activities tend to appear chronologically in the
table. In this case, draw the activities according to the order listed but place each
of them in the swim lane that the activity belongs to. Figure 14.10 is produced this
way. Number the activities if desired using the activity ID listed in the first column.
The activity ID number is useful for tracking and checking the decomposition of
complex activities.
3. Draw the control flows and object flows using the information listed in the Input,
Output, and Next Activity columns. In most cases, the Next Activity column
contains only one activity. If the Input and Output columns are blank, then draw
an arrow from the current activity to the successor activity. If there is input or
output, then the developers determine if an input or output should be shown in the
activity diagram. For example, on line 3 of Figure 14.9, the Get an Offer Letter
activity produces Offer Letter as an output. However, the Output(to) entry does
not show the activity ID number of the activity to receive the output; therefore, in
the activity diagram, the Offer Letter is not depicted. Line 5 shows that the output
is an Internship Letter, which is needed by activity 7. This is therefore shown
as an object flow from activity 5 to activity 7. Moreover, the last entry of the
line shows two conjunctive activities. This means a forking, as illustrated in the
activity diagram. Note: activity 10 needs to be performed within 7–10 business
days. This is shown in activity 10 with a pair of braces enclosing the timing
constraint. Finally, the first line shows an input without a pair of parentheses that
362 Part IV Modeling and Design of Other Types of Systems
encloses an activity ID number. This means the input is not from any activity,
but it is needed. It is shown as an object flow from nowhere in Figure 14.10.
Consider, for example, the activity diagram in Figure 14.10. The Determine
Eligibility activity is a decision-making process. The OIE may or may not approve
the student’s CPT application. Therefore, a conditional branching is used to model
the decision-making activity. If the conditional branching was not used previously
and needs to be added in this step, then additional activities may be introduced to
handle the newly introduced cases, such as, an activity to notify the student that the
CPT petition is not eligible.
The activities are examined to identify sequences of activities that can be per-
formed in parallel. This is accomplished by using domain knowledge. Forking is in-
troduced into the activity diagram to specify these parallel activities. Also identified
are activities that need synchronization, that is, two or more activities must complete
before another activity can begin. Joining is used to indicate synchronization in the
activity diagram.
1. Examining the relevant documentation that describes the activities. If the de-
scription of an activity implies that several application domain tasks need to be
performed and/or the relationships between the tasks are not trivial, then that
activity should be decomposed.
Chapter 14 Activity Modeling for Transformational Systems 363
task of the activity. On the other hand, a complex request in the sequence diagram
may require an activity diagram to model the processing of the request. For example,
a request to set up a faculty-led study-abroad program is a complex process. It needs
the approval of various administrative entities, including the development of a mem-
orandum of understanding with the host university, schedule the course, and brief the
students, to list a few. An activity diagram illustrates the activities and the workflows
can help the team understand the complex process and identify which tasks should
be computerized. An activity may exhibit state-dependent behavior. There are many
such examples. In these cases, the refinement of the activity should use state modeling
rather than decomposition of the activity into another activity diagram. On the other
hand, a state may represent a complex process. In this case, an activity diagram may
be used as a refinement of the state activity.
For each object sent from one activity to another via an object flow, its class
should appear in the design class diagram (DCD), or the domain model. If it is not
the case, then the object class should be added to the DCD or the domain model.
Additional object classes may be identified from the swim lanes. In particular, each
swim lane that represents a human role identifies an object class. The object class
should be included in the domain model, and in the DCD as well if the class must be
implemented. The activities in the swim lane may identify operations for the class. A
complex activity may decompose into lower-level activities or actions. Some of these
may be operations of the class.
If the team needs to perform activity modeling, then active involvement of the
users is required. This is because the information processing activities and workflows
of an organization is application specific, complex, and involves a lot of hidden
information. Therefore, activity modeling requires active user involvement.
Active user involvement means that the representatives of the user communities
must work with the team on a daily basis or at least several days a week. This re-
quires the customer and users to commit their precious time and resources. In today’s
Chapter 14 Activity Modeling for Transformational Systems 365
competitive business environment, the commitment is difficult to get and keep. There-
fore, a collaborative and cooperative approach is essential.
SUMMARY
•
This chapter presents the importance of activity mod- ties. Step 3 introduces conditional branching, forking,
eling. It reviews three prominent modeling tools— and joining to express complex relationships that exist
flowchart, Petri net, and data flow diagrams. These among the control flows. In step 4, complex activities
tools, among many others, contribute modeling con- are decomposed, and decomposition consistency is
cepts and constructs found in the UML activity dia- checked.
gram. It describes a UML activity diagram and the At the end of this chapter, activity modeling is
steps for activity modeling. The steps for activity compared with the other modeling and design activi-
modeling are influenced by the features of the three ties presented in previous chapters. These include how
prominent activity modeling tools and the principle to identify classes and their operations from an activ-
of separation of concerns. That is, in step 2, a pre- ity diagram and use these to update the design class
liminary activity diagram is constructed. This is basi- diagram. Moreover, the usefulness of activity model-
cally a data flow diagram. It shows the activities and ing as an aid to refinement of high-level requirements
the control flows and object flows between the activi- as well as use case identification is presented.
FURTHER READING
•
Reference [36] is a concise introduction to UML activity ments and constraints. It is accomplished by first translating
diagram. Eshuis and Wieringa [61] present a tool that can the activity diagram into a state machine, which is checked
check whether an activity diagram satisfies given require- against the requirements and constraints.
366 Part IV Modeling and Design of Other Types of Systems
EXERCISES
•
14.1 Refine the Obtain an Offer Letter activity discussed b. A claim-handling system for an insurance com-
in Section 14.5.4 to produce an activity diagram, tak- pany that issues home insurance as well as auto-
ing into consideration conditional branching, concur- mobile insurance.
rency, and synchronization. 14.3 Produce an activity diagram that describes the steps
14.2 Develop a description for each of the following ap- for activity modeling.
plications and apply the activity modeling steps to 14.4 Produce an activity diagram that describes your
each of them: academic department’s undergraduate or graduate
a. An online build-to-order application. advising.
15
Modeling and Design of
Rule-Based Systems
Previous chapters presented modeling and design of several types of systems including
interactive, event-driven, and transformational systems. Another type of system is a
rule-based system, which is used by businesses to make decisions. A software system
may contain different subsystems of different types. In particular, rule-based systems
are often used as a component of a system to help decision making. This chapter
is devoted to the modeling and design of rule-based components. As an example of
business rules, consider a point-of-sale shipping software. It has a Ship Package use
case. The corresponding ship package controller has a function to compute the charge.
The business rules for calculating a package’s shipping charges are:
The maximum limits for express packages within the U.S. are 150 lbs., and 119 inches
in length and 165 inches in length and girth.1 Packages that weigh 150 lbs. or less and
exceed 108 inches in length or 130 inches in length and girth are considered “oversize”
packages. Oversize packages are rated based on the greater of the package’s actual
rounded weight or dimensional weight.2 In addition, a charge of $45 per oversize
package applies.
Rules as such are called business rules, or decision logic. The informal speci-
fication of business rules has drawbacks. For example, an informal specification is
more likely to be ambiguous. That is, different interpretations exist. Moreover, it
does not explicitly display the relationships between the package parameters and the
367
368 Part IV Modeling and Design of Other Types of Systems
Rule numbers. The top row of the decision table shows the rule numbers. These
columns are the rule columns. Each rule column represents a business rule. For
example, the decision table in Figure 15.1 shows six rules.
Condition stubs. The first column of the upper portion of the decision table
contains the condition stubs, which specify the conditions involved in the business
rules. Figure 15.1 shows three conditions in the decision table.
Condition entries. The entries formed by the condition stub rows and the rule
columns are condition entries. They specify the condition values for the rules. A
dash in a condition entry is an “indifference.” This means that whichever value
is in the condition entry the outcome of the rule is the same. For example, rule
6 shows that if the package weight is greater than 150 pounds, the package is
rejected. The two dashes in rule 6 mean that the length and girth values do not
affect the outcome.
Action stubs. The first column of the lower portion of the table are the action
stubs. They specify the possible actions. The decision table in Figure 15.1 shows
four possible actions.
Action entries. The entries formed by the action stub rows and the rule columns
are action entries. Most of the time, an action entry is either a blank, or an X.
Chapter 15 Modeling and Design of Rule-Based Systems 369
1 2 3 4 5 6
Weight ≤150 lbs Y Y Y Y Y N
Length (inches) ≤108 >108&≤119 ≤108 >119 ≤119 –
Length plus Girth (inches) ≤130 ≤165 >130&≤165 − >165 −
Rule Count 1 2 1 3 2 9
Rate by Weight X
rule
Rate by greater of Weight and Dim. Weight X X count
Add $40 surcharge to each package X X
Reject package X X X
1. Easy to understand. Decision tables are easy to understand because they clearly
display the cause and effect relationships between the condition combinations
and the related actions.
2. Easy to check. It is easy to check the completeness, consistency, and nonre-
dundancy of a decision table. Moreover, it is easy to review a decision table to
determine whether it correctly specifies the business rules.
3. Easy to implement. It is easy to generate code from a decision table.
4. It helps test-case generation and test-driven development. The rules of a deci-
sion table are useful for generating functional test cases as well as boundary
value test cases. Since the test cases can be produced and implemented before
implementation, it helps test-driven development.
5. Rules can be updated dynamically. It is easy to apply the interpreter pattern to
implement a decision table. This is presented in Section 15.8. The pattern allows
a user to modify the business rules at runtime without needing to recompile the
program. This capability is useful for businesses that need to update the business
rules frequently and instantly.
1 2 3 4 5 6 7 8
Competitive Salary Y Y Y Y N N N N
Good Location Y Y N N Y Y N N
Nice Colleagues Y N Y N Y N Y N
Rule Count 1 1 1 1 1 1 1 1
Accept X X X
Hold X X
Reject X X X
some rules can be merged or consolidated to reduce the size of the decision table. The
consolidated decision table is easier to understand and check because the redundancy
is removed.
Input :
conditions: an array of conditions, each has an array of values
actions: an array of actions
i: current condition index; initially, i=0
r: current rule index; initially, r=1
actValue: an array of action entry values entered by the user to represent the actions for a rule, it contains string values
such as “B’’ (for blank), “X,” “1,” “2,” ...
Output :
T: a two dimensional array of condition entries
A: a two dimensional array of action entries
Algorithm :
void pdt(int i) {
for(int j=0; j<conditions[i].values.length; j++) { // do with each condition value of condition i
T[i][r]=conditions[i].values[j];
String[] actValue=getActions(); // show the partially completed decision table and obtain action entry values from the user
// actValue[i] is the action entry value foraction i
if (actValue == null) { // the condition entries are not sufficient to determine the actions, consider the next condition
pdt(i+1);
} else {// the condition entries can determine the actions, conclude the rule
for(int k=i+1; k<conditions.length; k++) T[k][r]=‘-’; // enter “-” into remaining condition entries
for(int m=0; m<actions.length; m++) A[m][r]=actValue[m];
r++;
}
if (j<conditions[i].values.length-1) // copy condition entries of the previous rule
for(int k=0; k<i; k++) T[k][r]=T[k][r-1];
}
}
1 2 3 4 5 6
Competitive Y Y Y N N N
Good Location Y N N Y Y N
Nice Colleagues -- Y N Y N --
Rule Count 2 1 1 1 1 2
Accept X X
Hold X X
Reject X X
are more condition values to be processed, then the algorithm copies the condition
entries of the previous rule up to condition i and returns.
Figure 15.2 indicates that the job seeker accepts any offer with a competitive
salary, and either good location or nice colleagues. If the pay is not competitive and
only one of the other two criteria is met, then the job seeker would reject the offer. For
the remaining cases, the job seeker would hold the offer. Under these observations, the
Chapter 15 Modeling and Design of Rule-Based Systems 373
algorithm produces the decision table in Figure 15.4. Rule 1 is concluded immediately
after filling the first two condition entries. The first condition entry of rule 1 is then
copied to create rule 2. The algorithm concludes rule 2 when it fills all three condition
entries. Rule 6 is concluded immediately after filling the first two condition entries
with an N.
Definition 15.1 A decision table is complete if the rules cover all the possible
condition combinations.
The consistency of a decision table ensures that the same condition combination
will lead to the execution of the same set of actions. If the team implements the
software according to an inconsistent decision table, then the software would produce
different results for the same input parameters, depending on which of the rules is
applied.
Consider, for example, the decision table in Figure 15.2. The decision table is
constructed using the systematic decision table construction method, which often
produces decision tables that contain redundancies. Consider rules 1 and 2, which
differ on only one condition, that is, their actions are the same and their condition
entries are the same except one. This means that regardless of whether the “Nice
Colleagues” condition is Y or N, the job seeker will take the job. Thus, the two
rules can be merged into one with the condition entry for “Nice Colleagues” set to
indifference. Similarly, rules 7 and 8 can be merged.
(a) Algorithm for decision table consolidation (b) Decision table for decision table consolidation
if (Comp. Salary)
if (Good Location)
Accept
else
if (Nice Colleagues)
Accept
else
Hold
else
if (Good Location)
if (Nice Colleagues)
Hold
else
Reject
else
Reject
return false;
Syntax Item if (right == null)
execute action, return
return left.eval(c);
use left true if successful, else
Context eval(c :Context) : boolean return left.eval(c)&&
return false
val(c: Context): int 0..1 right.eval(c);
right
return 0; Action
action: String Action List
Terminal Nonterminal eval(c:Context):boolean eval(c:Context):boolean
return value;
if (left.eval(c)) if (right==null)
return right.eval(c); return left.eval(c);
if (c.get(key)!=null) { return false; return left.eval(c)
Package p=(Package)c.get(key); && right.eval(c);
return field of p named attr;
}
// throuws object not found exception
return left.val(c) Greater Than Less Than Equal To
> right.val(c);
eval(c:Context):boolean eval(c:Context):boolean
2. eval(c: Context): boolean This method has a default “return false” implementa-
tion. A nonterminal node overrides this to implement the semantics of the node.
For example, the Greater Than nonterminal returns left.val(c) > right.val(c). In
general, these recursive calls automatically traverse the parse tree in postorder.
The left child is a Var object representing an attribute of a shipping package
object, that is, weight, length, or girth. The Var object retrieves this value from
the context and returns the value to its parent. The right child of the Greater Than
class is an INTEGER, which simply returns the int value.
:Rule
:ConditionList
:Less Than Equal To
:Var(key=”pkg”, attr=”wt”)
:INTEGER(value=150)
:ConditionList
:Less Than Equal To
:Var(key=”pkg”, attr=”length”)
:INTEGER(value=108)
:ConditionList
:Less Than Equal To
:Var(key=”pkg”, attr=”girth”)
:INTEGER(value=130)
:ActionList
:Action(action=”RateByWeight”)
Legend:
:A an object of class A
(a=b,x=y) attribute values of object
List object as its children. The Condition List object has a Less Than Equal To object
and a Condition List object as its children, and so on. There is one such tree for each
business rule.
The variable look-up context is used by the vertexes of the parse tree to retrieve
the values of the variables used by the business rules. The easiest way to implement
the context is using a hash table, which is already available as a Java API.
quickly and frequently to satisfy the business needs. The archived decision trees allow
the user to roll back to previously used business rules.
1. It is easy to extend and change the grammar. For example, if the grammar in
Figure 15.7 is extended to include arithmetic expressions, then it needs to add a
number of new classes to the class diagram and modify the parser according to
the new grammar.
2. It is easy to implement, as shown by the UML notes attached to the functions in
Figure 15.8.
3. It is easy to add interpretations. Consider, for example, a grammar that is origi-
nally defined for decimal algebra. If an interpretation for binary algebra is needed,
then an operation that evaluates expressions in binary algebra can be added to
the interface and implemented by the subclasses.
4. It allows the user to change the business rules on the fly without requiring the
user to recompile the program—changes to the rules require only parsing the
updated rules and reconstructing the parse trees.
5. It can avoid parsing if the rules are entered and updated through a dialog box,
which implements the grammar rules by careful use of the input widgets such as
text fields and selection lists.
One limitation of the interpreter pattern is that applying the pattern to a large,
complex grammar is difficult. In this case, a compiler is a better choice. Another
limitation is that interpretation runs slower than the compiled code.
Y Y Accept
N
N Hold
Y Hold
Y
N N Reject
N Reject
pounds, 1 pounds, 149 pounds, 150 pounds, and 151 pounds. For each of these cases,
the expected outcome of the CUT is specified. For example, it is expected that the
CUT should display an error message when the weight is −1, 0, and 151 pounds. In
addition to boundary values, extreme values are used to test the ability of the CUT in
handling extreme cases. Consider again the shipping decision table discussed above.
An extremely large weight, or dimension, can be used to test the CUT. The expected
outcome of this test should be an error message.
GUIDELINE 15.1 Actively involve the customer and users in gathering and ana-
lyzing the business rules.
This applies the “active user involvement is imperative” agile principle. Business
rules are the assets of a business. They are important requirements of the software
system. Unfortunately, not all business rules are documented, documented correctly,
or up to date. In many cases, the business rules are distributed among the users. Not
Chapter 15 Modeling and Design of Rule-Based Systems 381
all the users know all the business rules and interpret the rules consistently. These
are only some of the problems frequently encountered in practice. Therefore, active
user involvement is imperative. The opposite is creating the business rules for the
customer and users, based on the team’s understanding of the application domain.
Such business rules usually do not satisfy the business needs. In this regard, “the
team must be empowered to make decisions’’ agile principle must not be applied.
This principle intends to indicate that the team must be empowered to make technical
decisions, not the business decisions for the customer.
Sometimes, one set of business rules conflicts with another set of business rules.
This also requires active user involvement to resolve. Active user involvement con-
sumes time and affects productivity. Therefore, the users and their management com-
mitment to support these principles is essential to the success of the project. If the
project involves a substantial amount of effort to implement the business rules, then
a designated user representative or a group of representatives should be assigned to
the project.
GUIDELINE 15.3 Capture business rule requirements at a high level; make them
lightweight and visual. Good enough is enough.
In some sense, a decision table helps implement this principle because decision
tables are intuitive, lightweight, and capture the requirements at a high level. However,
the specification of some of the qualitative conditions may be difficult and time
consuming. In these cases, leave such requirements at a high level and refine them
during the design and implementation phases.
GUIDELINE 15.4 Testing is integrated throughout the project life cycle; test early
and often.
SUMMARY
•
This chapter presents decision tables for specifying progressive decision table construction is described.
and analyzing business rules. It describes two methods The chapter also defines completeness, consistency,
for decision table construction, that is, the systematic and nonredundancy of a decision table. It presents
method and the progressive method. An algorithm for an algorithm for decision table consolidation. It also
382 Part IV Modeling and Design of Other Types of Systems
describes how to generate code from a decision table and debugging. These activities usually take consider-
and relates a decision table to test-driven develop- able time to carry out. The interpreter pattern allows
ment. change to the business rules without needing to re-
Some businesses update their business rules fre- compile the software system. The approach presented
quently. Traditional approaches require modification in this chapter is easy to implement and use. Finally,
to the conditional statements that implement the busi- the advantages to specifying business rules using a
ness rules. This in turn requires compilation, testing, decision table are summarized.
FURTHER READING
•
In [100], algorithms for checking the completeness and decision-related requirements. These include decision ta-
consistency as well as consolidating a decision table and bles, flowcharts, state diagrams, Petri nets, and decision
decision tree are described. Reference [56] provides an trees. It also compares these techniques with respect to prac-
excellent presentation of several methods for specifying tical considerations.
EXERCISES
•
15.1 Perform the following for the business rules of the 15.3 Write an algorithm for checking the completeness of
point-of-sale shipping software presented at the be- a decision table. The algorithm must also calculate
ginning of this chapter: the rule counts from the indifferences.
a. Construct a decision table using the systematic de- 15.4 Convert your decision table completeness-checking
cision table construction method. algorithm into a decision table. Check the complete-
b. Consolidate the decision table and check the com- ness, consistency, and nonredundancy of the decision
pleteness, consistency, and nonredundancy of the table. Correct any errors.
result. Correct any errors, if any. 15.5 Construct a decision table from the admission crite-
c. Generate code from the consolidated, error-free ria described below. In addition, check the complete-
decision table. ness, consistency, and nonredundancy of the decision
15.2 Do the following for the progressive decision table table.
construction algorithm presented in this chapter: The computer science (CS) department of a
a. Construct a decision table for the progressive de- university uses a set of admission criteria to pro-
cision table construction algorithm using the pro- cess applications to its graduate program. Applica-
gressive decision table construction method. tions that clearly satisfy all the admission criteria
b. Check the completeness, consistency, and nonre- are classified as accept. Applications that do not
dundancy of the decision table. Correct any errors, satisfy, or barely satisfy, the criteria are classified
if any. as reject. The remaining applications are marked as
c. Consolidate the error-free decision table and check “pending investigation.” Applicants must have paid
the completeness, consistency, and nonredun- the application fee. The admission criteria are the
dancy of the resulting decision table.
Chapter 15 Modeling and Design of Rule-Based Systems 383
385
16
Applying Patterns to Design
a State Diagram Editor
386
Chapter 16 Applying Patterns to Design a State Diagram Editor 387
design problem
encountered
(1) Perform
(2) Search
design as
patterns.
usual.
validated patterns
design identified
result. Thus, the judgment should be whether the problem is solved by applying the
right pattern correctly. These are verification and validation of pattern application.
That is, “is the right pattern being applied,” and “is the pattern applied correctly?”
This section presents a problem-directed process for applying the situation-
specific patterns. The process is shown in Figure 16.1 and explained as follows.
The steps of the process are demonstrated throughout the rest of the chapter along
with the presentation and application of the patterns.
1. Perform design activity as usual. This step performs the design activity as usual.
If a design problem appears or some design idea is needed, then patterns are
identified and applied to solve the design problem. In most cases, patterns are
applied during the architectural design, object interaction modeling, or deriving
design class diagram. For example, during architectural design or object interac-
tion modeling, the team recognizes that letting the controller access the database
has potential problems such as tight coupling and overloading the controller
with database access functions. Thus, a design problem emerges: how to avoid
tight coupling between the controller and the physical database. Once the design
problem is identified, the process continues with the following step.
2. Search patterns to solve the design problem. This step identifies patterns to solve
the design problem. It involves the following three steps:
• First, the design problem is reformulated to suppress detail and specifics. This
helps look up the patterns. The process should result in an abstract, or general
formulation of the design problem.
• Second, the reformulated design problem is used to look up the patterns shown
in Figure 16.2, which is a summary of the design problems and the patterns
that solve the design problems.
• The third step verifies that the selected pattern is the right one to apply, that is,
the specification of the pattern is examined to ensure that it solves the design
problem.
Chapter 16 Applying Patterns to Design a State Diagram Editor 389
Abstract You need to create objects of different families and hide from the client which family of objects is
factory created.
Adapter You want to convert one interface to another.
Bridge You want to maintain a stable client interface while the implementation changes.
Builder You want to decouple process steps from processes so the processes and steps can be combined in
flexible ways to accomplish various tasks.
Chain of You need to process requests with request handlers but the exact handler to process a request
responsibility is unknown in advance.
Command You want to process requests in flexible ways including queuing, scheduling, undoing, and
redoing requests.
Composite You want a uniform approach to process objects of a complex class structure containing
recursive part-whole relationships.
Decorator You want to add/remove functionality to/from an object dynamically.
Facade You want to simplify client interface and interaction to a web of components.
Factory You want to dynamically change the products used by some steps of a
method process or algorithm.
Flyweight You want to create numerous instances of an object without severe memory and performance
penalties.
Interpreter You want to change expressions or rules without needing to change and recompile the software
system.
Iterator You want a traversal mechanism that hides the data structures traversed.
Mediator You want to simplify complex interaction relationships among objects.
Memento You want to store and restore object states, and prevent them from access by a third party.
Observer You want to decouple event handlers from an event source so handlers
can be added or removed without impacting the event source.
Prototype You want to reduce number of classes, or avoid object construction cost.
Proxy You want to control access to objects such as remote access, delayed access, role-based access,
and smart reference access.
Singleton You want to create at most one, or a limited number of globally accessible instances of a class.
State You want to implement state dependent behavior without using conditional statements.
Strategy You want to selectively apply different algorithms, which share the same functionality but differ
in other aspects such as speed or memory space.
Template You want to vary the steps of a process or algorithm without using
method conditional statements.
Visitor You need to perform type-dependent operations to objects of a class structure but you want to
avoid adding the operations to the classes.
3. Apply the selected patterns. In this step, the selected patterns are applied in the
context of the existing design. It involves the following steps:
• First, map the classes and operations in the pattern to classes and operations in
the existing design. It begins with the identification of the Client class of the
pattern in the existing design, followed by mapping the other pattern classes
to the existing design. Often, new classes must be introduced into the existing
design to correspond to classes in the pattern. These new classes are renamed
according to their functions in the design context.
390 Part V Applying Situation-Specific Patterns
• Next, construct a table to show the correspondence between the design classes
and the pattern classes. This step is optional.
• Third, modify the existing design to introduce the new classes. More specifi-
cally, the structural design and the behavioral design are modified according
to their counterparts in the pattern specification. The correspondence table
constructed in the last step facilitates this task.
• If desired, generate the skeleton code that implements the pattern in the design
context.
4. Review the resulting design. In this step, the design is checked to ensure that
the pattern is applied correctly and the design problem is solved. Moreover, the
design indeed exhibits the benefits of the pattern and the liabilities are addressed
properly.
From the overall requirement, one can derive the Edit State Diagram use case,
which allows the user to edit a new diagram as well as an existing diagram. Figure 16.3
shows a screen shot of the editor. The editor works as follows. To add a state, the user
clicks the State button, the pointer changes to a cross hair. The user clicks anywhere
in the drawing area, the editor draws a circle with a dummy state name, for example,
State 1. To draw a transition from one state to another, the user clicks the Transition
button, presses on the source state, drags to the destination state and releases. The
editor draws an arrow line with a dummy transition name from the source state to the
destination state. The user double-clicks a state or transition to launch an Edit Dialog
to change the properties of the state or transition. According to the controller pattern
presented in Chapter 10, the the sequence diagram for the Edit State Diagram use case
should contain an Edit State Diagram controller, or controller for short in subsequent
sections. The controller handles user requests such as adding, deleting, or moving a
state or transition, and updating the properties of a state or transition.
consists of subsystems and components, and a subsystem may contain other sub-
systems or components. Looking up the patterns in Figure 16.2 finds the composite
pattern. It is useful for processing complex class structures containing recursive part-
whole relationships. The specification of the pattern provided in Figure 16.4 confirms
that it is the right pattern. For example, the structural design shows that the Composite
Component is an aggregation of Component. The inheritance relationship indicates
that a Component is either a Primitive Component or a Composite Component. Thus,
if Composite Component and Primitive Component 1 and 2 are substituted with State
Diagram, State, and Transition, then a state diagram may contain states, transitions, as
well as other state diagrams. The skeleton code for the composite pattern is shown in
Figure 16.5.
Figure 16.6 shows the representation of a state diagram using the composite
pattern. The interface of a Diagram Element includes methods for adding, retrieving,
and removing Diagram Element objects. This class provides a default implementation
for these operations. The State Diagram class overrides the default implementation
according to the data structure it uses to store its components.
Figure 16.7 shows the mapping between the classes in the existing design and
the roles in the composite pattern. The Diagram Element class defines an interface
for the controller to access the elements of a state diagram. The State Diagram class
maps to the Composite Component because it consists of states and transitions as well
as other state diagrams. The inheritance and aggregation between the State Diagram
and the Diagram Element indicate that a state diagram is a diagram element and it
may contain other diagram elements including state diagrams. Thus, composite states
are supported. Figure 16.8 shows the sample code. For simplicity, the operations of
the classes are omitted because they can be identified from the pattern specification
and the design in Figure 16.7. The skeleton code for the design in Figure 16.6 could
be generated from the mapping and the skeleton code of the composite pattern. This
is accomplished by substituting the classes and operations in the design diagram in
Figure 16.6 for the corresponding classes and operations in the skeleton code for the
composite pattern.
Applying the composite pattern brings the following advantages to the design of
the editor:
1. It lets the editor store and process state diagrams, states, and transitions using
one interface. The representation supports recursive, whole-part relationships.
2. It provides a single, uniform interface for the controller to access the diagram
elements. It hides the type of the diagram element from the controller; the con-
troller does not need to know whether it is working with a primitive or composite
component.
3. It is easy to extend the editor to support other types of UML diagrams. Simply
add the diagrams as composite diagram elements and their modeling concepts as
primitive diagram elements.
The application of the composite pattern requires the controller to ensure the
integrity of a state diagram. For example, when a state is moved or removed, then all
the related transitions must be moved or removed accordingly.
Chapter 16 Applying Patterns to Design a State Diagram Editor 393
Name Composite
Type GoF/Structural
Specification
How to represent recursive part-whole relationships, and allow the client to interact with primitive as well as composite
Problem
components uniformly.
Solution Define a common interface to unify the primitive and composite components so that the client can access them uniformly.
Design
• Component: It defines an interface for the client to access the composite as well as primitive components uniformly.
It provides a default, do-nothing implementation for the add, remove and get operations.
• Composite Component: It contains primitive and composite components and overrides the add, get and remove
Roles and operations.
Responsibilities
• Primitive Components: These components do not contain other components. They implement operation() to provide
component-specific behavior.
• Client: It creates, or obtains an instance of a subclass of Component and calls its functions including the
operation() method.
• It is useful for representing and manipulating complex class structures that exhibit recursive, whole-part relationships.
• It provides a single interface for accessing the primitive as well as composite components so that the client can treat
Benefits them uniformly.
• It is easy to add a primitive or composite class. Simply add a subclass to Component.
The composite pattern requires the client to ensure that integrity constraints are not violated. For example, if the
Liabilities
client removes a primitive component, it must also remove all of its relationships to other components.
Guidelines
• Abstract Factory and Builder are useful for creating the primitive components and constructing complex composites.
• Strategy and Visitor are useful for processing the composite and primitive components.
Related Patterns • Iterator implements a traversal algorithm for a client. It hides the data structure used to store the components of
a composite
.
• Prototype and Flyweight are useful for reducing the number of classes and instances used by a composite, respectively.
Uses Applications that need to represent and process complex structures can benefit from Composite.
Diagram Element
Edit State Diagram name: String
Controller loc: Point g.drawString(name, ...);
for each c in components
draw(g: Graphics)
c.draw(g);
intersect(p: Point): boolean
add(e:DiagramElement)
This class defines a uniform interface and get (...): DiagramElement *
provides a default do-nothing implementation remove (e: DiagramElement) components
of add, get and remove methods. Its ...
subclasses implement the abstract methods
dependencies are undesirable because the strategies cannot be used to lay out other
types of diagrams. Therefore, one needs a way to access the diagram elements without
exposing the underlying data structures of the state diagram. Looking up the pattern
summary table in Figure 16.2 finds the iterator pattern. The summary says that the
pattern provides a traversal mechanism that hides the structures traversed. It matches
the design objective. Figure 16.12 provides the specification of the iterator pattern.
It is easy to apply the iterator pattern to access the elements of a state diagram.
Suppose that the implementation language is Java and myCollection is an instance of
a Collection class used to store the elements of a state diagram. The following shows
how the layout () method of a concrete layout strategy may process the elements of
the state diagram:
Iterator it=myCollection.iterator ();
while (it.hasNext ()) {
DiagramElem de=(DiagramElem)it.next ();
process (de); // process or save it
}
Chapter 16 Applying Patterns to Design a State Diagram Editor 397
Name Strategy
Type GoF/Behavioral
Specification
Problem How to provide the client an ability to select and execute one of the available algorithms.
Define an abstract class to provide a common interface to make the algorithms interchangeable.
Solution Let each subclass implement an available algorithm. The client can select a subclass object and
delegate the work to that object.
Design
strategy Strategy
Client
operation()
setContext(c: Context)
Contex
context
Structural getContextData(): Data
setContext(c)
process context, may get
Behavioral data from context
operation()
d:=getContext():Data
layoutAlgo:=a; diagram
layoutAlgo
layoutAlgo.setDiagram(self); :Edit Diagram
<<Strategy>> Controller :State Diagram a:Layout Algorithm
Layout Algorithm
beautify() setLayoutAlgo(a) compute
layout() setDiagram(self)
setDiagram(d: State Diagram) coordinates for
each diagram
element
draw(g) layout()
<<Strategy>> <<Strategy>> <<Strategy>>
Force-Based Orthogonal Hierarchical
Layout Layout Layout
for each c in components
layout() layout() layout() c.draw(g);
(a) State diagram editor strategy pattern structural design (b) Object interaction in strategy pattern
Name Iterator
Type GoF/Behavioral
Specification
Problem How to access elements of an aggregate without exposing the underlying data structure.
Define an iterator interface that a client can use to access the elements of an aggregate, and let concrete
Solution
iterators implement the traversal algorithms for the concrete aggregates.
Design
Aggregate Iterator
Client hasNext(): boolean
iterator(): Iterator
// other operations next(): Object
remove()
return new Iterator2(self);
Structural
Aggregate 1 Aggregate 2 Iterator 2 Iterator 1
traverse
iterator( ): Iterator iterator( ): Iterator hasNext( ): boolean hasNext( ): boolean
// other operations // other operations next( ): Object next( ): Object
remove( ) remove( )
traverse Iterator2(a:Aggregate) Iterator1(a:Aggregate)
Name Visitor
Type GoF/Behavioral
Specification
How to decouple type-dependent operations from a class structure to achieve high-cohesion and
Problem
designing “stupid objects.”
Implement a hierarchy of classes called visitors to provide type-dependent polymorphic operations. Let the objects
Solution
of the class structure invoke the polymorphic operations of a selected visitor by passing themselves as parameters.
Design
• Visitor: This class implements a polymorphic, do-nothing function visit(c:Cj) for each concrete component
class Cj in the class structure to be processed.
• Visitor 1–2: These represent concrete visitors. A concrete visitor overrides visit(c:Cj) if it needs to analyze
Roles and objects of Cj.
Responsibilities • CompIF: It defines an interface for all component classes of the structure to be processed.
• Class 1–2: These concrete component classes of the structure implement the accept(v: Visitor)
methods as v.visit(self). Thus, exactly one of the visit methods of the visitor v is executed.
• Client: The client creates a visitor vi and uses it to call the accept(vi) method of each object in the structure.
• High cohesion is achieved because each concrete visitor performs only one function.
• The concrete visitor classes can be reused to process other class structures.
• It is easy to add concrete visitors. The new visitor needs to implement only the polymorphic visit(c: Cj)
method for each Cj class it can analyze.
Benefits
• It is easy to add a component class Cj to the class structure. The new class needs to implement the
accept(v: visitor) method as v.visit(self). In addition, add visit(c: Cj) to the root Visitor class and implement
visit(c: Cj) in each of the concrete Visitor classes that can analyze Cj.
• Visitors can store intermediate results or states while they visit the class structure.
Liabilities
Guidelines Apply Visitor if the operations are type dependent.
• Visitor and Iterator are used together. The concrete iterator lets the concrete visitor visit each object
in the structure.
Related Patterns
• A visitor can be a singleton if it does not have nonsharable instance variables.
• Visitor can visit Composite.
Uses
* components
default do nothing <<Visitor>> check
implementations Diagram Element
Checker
check(s:State) accept(v:Visitor)
check(t:Transition) // other operations
check syntax for State s check syntax for Transition t c.check(self); c.check(self);
designing “stupid objects.” Another commonly seen approach expands the classes
of the composite in Figure 16.6 with additional syntax-checking operations. The
advantage of this approach is that it does not use conditional statements. The problem
is that the classes could be overloaded with unrelated responsibilities. Thus, the design
problem is how to decouple these type-dependent operations from the classes of a
structure. The pattern summary table suggests that the visitor pattern could be used.
The visitor pattern is described in Figure 16.13. Figure 16.14 provides the skeleton
code for the pattern.
An application of the visitor pattern to the design of the state diagram editor is
displayed in Figure 16.15. On the left of the diagram in Figure 16.15 is the visitor
402 Part V Applying Situation-Specific Patterns
hierarchy. On the right is the class structure that the visitors visit. The root Checker
class defines the polymorphic check functions with default, do-nothing implementa-
tions. Its subclasses override the functions as desired. For example, the State Checker
overrides check (s:State) to check the syntax of a state specification. Diagram Element
is the parent class of all diagram elements that the checkers check. The interface of
this class includes an abstract accept (c: Checker) method. All its subclasses have
the same implementation for the method, that is, c.check (self). The controller is the
client. It creates the desired checker and calls the accept (c: Checker) method of the
state diagram. The method of the state diagram calls the accept (c:Checker) method
of each component. The component calls the check(s: State) or check(t: Transition)
method of c, depending on the type of the component. The skeleton code for the
design is shown in Figure 16.16.
Memento
int h=pass.hashCode();
pass: int if (this.pass==h)
state=s; getState(pass: String): Diagram State return state;
this.pass=pass.hashCode(); else
setState(s: Diagram State, pass: String) throws IllegalAccessException(...);
memento
state
memento= diagram.createMemento(); Edit Controller Diagram State
// beautify diagram beautify()
state
restore()
diagram
diagram.setMemento(memento);
State Diagram
pass: String
try { Memento m=new Memento();
state=m.getState (pass); // other operations
State s= (DiagramState)state.clone();
} catch (IllegalAccessExceptione e) {...} createMemento(): Memento m.setState(s, pass);
setMemento(m: Memento) return m;
create()
beautify() memento:= s:=(DiagramState)clone()
createMemento(): Memento
setState(s: Diagram State,
pass: String)
restore()
setMemento (memento) state:=
getState(pass)
Figure 16.20, the type of the concrete product is used. The UML 1.0 and 2.0 Factories
are the concrete factories. They implement the Abstract Factory interface to produce
the concrete products for UML 1.0 and UML 2.0, respectively. The client for the
design in Figure 16.20 is Edit Diagram Controller. It has a setFactory (f: Abstract
Factory) function, which stores the concrete factory f in its factory field. The client
Chapter 16 Applying Patterns to Design a State Diagram Editor 407
calls functions of this concrete factory to create concrete products of UML 1.0 or
UML 2.0. Note that since the concrete factory is set by another object, the client does
not know which concrete factory it uses. This in turn means that the client does not
know the family of the products that it uses.
One limitation of the abstract factory pattern is that it is difficult to add products
that require a different product creation interface. For example, to extend the design
in Figure 16.20 to produce a UML use case diagram elements is difficult. It requires
changes to the Abstract Factory interface as well as the concrete factories. Moreover,
the product hierarchy has to be extended to include use case, actor, system, and so
forth. One solution to this problem is to provide a default “return null” implementation
in Abstract Factory, which now becomes a concrete class rather than an interface or an
abstract class. The concrete factories override the default implementation whenever
needed.
code from UML design diagrams. Reverse-engineering, on the other hand, recovers
the design diagrams from code. Reverse-engineering is useful in many ways. For ex-
ample, it can be used to verify that an implementation is consistent with the original
design. It is easy to compare two versions of the code to visualize the changes on
the diagrams. Reverse-engineering consists of three steps: (1) parse the source code
to extract artifacts such as classes, attributes, relationships, states, and transitions,
(2) compute diagram layout, (3) display the diagram. These activities are different
for different types of diagrams because the design artifacts to be extracted and the
notations to present them are different.
Obviously, the reverse-engineering process and the diagram beautify process
share steps. Consider, for example, the process to beautify a diagram. It may consist
of: (1) if the diagram has changed, then save the diagram for possible undo, (2)
compute layout, and (3) display the diagram. Steps (2) and (3) are the same for
both processes. Therefore, it might be worthwhile to consider a design that supports
variation in both the construction process and the construction steps. The builder
pattern as summarized in Figure 16.2 accomplishes this design objective. The pattern
is described in Figure 16.22. Applying the pattern to support a reverse-engineering
process and a diagram beautifying process is shown in Figure 16.23.
A builder can employ a concrete factory to produce the parts it uses. For example,
instead of using a State Diagram Builder and Class Diagram Builder, the design could
use just one concrete builder and an abstract factory with two concrete factories. The
concrete builder invokes the getParser (), getLayout (), and getDisplayer () functions
of the concrete factories and uses them to parse, lay out and display the diagrams.
To generate a different type of diagram, the client only needs to change the concrete
factory. On the other hand, if the manufacturing process of a product is complex, a
concrete factory can delegate the product construction responsibility to a builder. This
would reduce the complexity of the create function of the concrete factory as well as
provide the flexibility to change the construction process dynamically.
The builder pattern is useful for applications that require the flexibility to change
the construction process as well as the construction steps dynamically. For exam-
ple, it has applications in computer-aided design and computer-aided manufacturing
(CAD/CAM). The design process and the manufacturing process can change from
product to product. In addition, the design steps and manufacturing steps also dif-
fer from product to product. However, the products may also share some design
steps. The builder pattern is useful for the design and implementation of enter-
prise resource planning (ERP) frameworks. The Supervisor is an abstraction of all
possible workflow processes. The construct() method of each concrete supervisor
implements a concrete workflow. On the other hand, the Builder is an abstraction
of all possible workflow activities. The concrete builders implement the individ-
ual workflow activities. Similarly, the pattern can be applied to software process
automation to support different software processes in combination with different
methodologies that implement the processes. This lets the development organiza-
tion select the process and methodology they want to use. One final note is that
the builder pattern is not limited to product creation. In fact, it is applicable in all
situations in which the processes and the process steps need to vary independently.
Name Builder
Type Gof/Creational
Specification
How to vary the construction processes and the individual construction steps so they can be combined
Problem
in flexible ways to construct different products.
Decouple the construction processes and the construction steps into two separate hierarchies so they
Solution
can be combined in flexible ways.
Design
Supervisor Builder
Client
Supervisor(b: Builder) doX() Each builder knows
construct () builder doY() how to perform the
getProduct(): Product doZ() steps but not when
getProduct():Product to perform them.
Builder b=new Builder1(); Each supervisor knows
Structural Supervisor s=new Supervisor1(b); when to do what but
s.construct(); not how to do them.
Builder 1 Builder 2
Supervisor 1 Supervisor 2
doX( ) doX( )
Supervisor1(b:Builder) Supervisor2(b:Builder) doY( ) doY( )
construct ( ) construct ( ) doZ( ) doZ( )
create( )
create(b) doX( )
Behavioral construct( ) doY( )
doZ( )
p:=getProduct( )
p:=getProduct( )
• Supervisor, Builder: These define the common interfaces for the concrete supervisors and concrete
builders.
• Supervisor 1–2: These represent the concrete supervisors. Each implements its own concrete
construct process, which invokes the methods of a concrete builder to construct a complex object.
Roles and It then retrieves the product from the builder. The supervisors know when to do what but not how
Responsibilities to do them.
• Builder 1–2: These represent the concrete builders. Each implements the abstract methods of the
Builder interface to perform the concrete build steps.
• Client: It selects and creates the supervisor and builder, invokes the construct( ) method of the
supervisor, and retrieves the product from the supervisor.
• The builder hides the representation and internal structure of the product from the supervisor.
• It separates the product representation and construction concerns. The builder builds parts and
Benefits
keep the partial product. The supervisor controls the construction process.
• The supervisor can control the construction process at any level of detail.
Liabilities
Guidelines
• Builder can build complex objects for Abstract Factory. Abstract Factory can provide products
for Builder.
Related Patterns • If the construct process is the same, then Factory Method is adequate. Builder supports variation
of both the process and the steps but Factory Method supports only variation of steps.
• Builder can be used to build complex Composite objects.
Process automation can benefit from Builder. For example, a software engineering environment may
Uses support different software processes (e.g., waterfall and agile). The phases such as requirements,
design, etc. can be the steps of concrete builders, which implement different methodologies.
409
410 Part V Applying Situation-Specific Patterns
<<Singleton>>
flyweight Flyweight Factory
factory Hash Table
flyweights
Client getFlyweight (key: String):Object
*
<<Flyweight>>
... Image Icon
if (flyweights.get(key)==null){
State s=new State(...); ImageIcon(fn:String)
// create flyweight
ImageIcon icon = (ImageIcon) paintIcon(c: Component, g:Graphics,
flyweights.put(key, flyweight);
FlyweightFactory.
} x:int, y:int)
getInstance( ).getFlyweight
return flyweights.get(key);
(“Image-Icon”);
s.setIcon(icon);
paint the icon
...
of the object is not required. Flyweight reduces the number of instances that need to
be created. Prototype, presented in Chapter 17, reduces the number of classes needed.
Singleton also reduces the number of instances. The difference is that singleton creates
at most one globally accessible instance of a class in most cases while flyweight shares
an instance to improve efficiency and resource utilization.
Name Observer
Type GoF/Behavioral
Specification
How to decouple change and related responses so that such dependencies can be added or removed
Problem
freely and dynamically.
Provide a mechanism to add or remove many-to-one dependencies between objects so when one
Solution
object changes states, all its dependents are notified and updated automatically.
Design
operation( )
:Observable o: Observer
add(o:Observer) add(o:Observer)
Behavioral setChange( ) notifyObservers(arg)
• Observable: This class defines functions for adding, removing, and notifying observers.
• Concrete Observable: These classes extend the Observable class to add their own behavior such as
Roles and
operation( ). They inherit the functions of the Observable class.
Responsibilities
• Observer: It defines an interface for all concrete observers.
• Concrete Observer: These classes implement the update method to respond to the change.
• Observers can be added to, or removed from the observer list of an observable without
affecting the observable.
Benefits • The Observable and the Observer classes can be reused independently.
• It supports multicast and broadcast communication. The broadcast mechanism is inherited from
the Observable class.
Liabilities Unwanted concurrent update to a concrete observable may occur.
Guidelines
Related Patterns • Protection Proxy can be used to prevent unwanted concurrent update to a concrete observable.
Uses • Observable and Observer are also Java APIs. The Java ActionLister API is a special case of Observer.
Observable
Opt 1 Opt 2 Opt 3
add(o:Observer)
Market Share 50 30 20 for each observer remove(o:Observer)
Profit Margin 20 30 50 observer.update notifyObservers(arg:Object)
(self, arg) setChange()
Op. Cost 40 40 20
Data Table
// specific behavior here
(a) An intuitive model of a real-world application (b) Applying observer to the real-world application
However, the Java Action Listener interface is used more often in GUI programming.
It is a special case of the observer pattern.
Figure 16.29 shows the Java code that uses the Action Listener interface; and
hence, it is an application of the observer pattern. The code does three things, among
others. First, it creates the buttons. Second, it adds the Editor GUI object to the
action listeners of the buttons to receive the action events. Third, it processes the
action events in the actionPerformed (ActionEvent e) method. The approach shown
in Figure 16.29 has a potential problem. That is, if there are many editing events, then
the complexity of the code will be high because it relies on conditional statements
to determine the event source. A solution is to use separate action listeners, one
for each type of event and listen to the corresponding event source. This eliminates
the conditional statements. The relationship between an observable and the list of
observers resembles the relationship between a publisher (of a newsletter) and the
subscribers (of the newsletter). Therefore, the observer pattern is also called the
publisher-subscriber pattern. The observable is the publisher, and each observer is a
subscriber.
Ideally, the runtime environment should call these functions because it knows which
event takes place. Unfortunately, the runtime environment does not know which of
these functions to call because they are application specific. It can only deliver the
event to a callback function. In Java, this is the actionPerformed (ActionEvent e)
function of the registered Action Lister object. Thus, the design problem to be solved
is how to convert one interface to another. Checking the pattern summary table finds
the adapter pattern, which is detailed in Figure 16.30.
There are two types of adapters, shown in Figure 16.30(a) and Figure 16.30(b),
respectively. Figure 16.31 compares these adapters. The class adapter uses inheritance
while the object adapter uses object composition, which is preferred. The use of
inheritance by the class adapter implies static binding and dependence of the adapter
on the adaptee class. Static binding prevents the adapter to adapt to other classes.
The dependence of the adapter class on the adaptee class means change impact may
ripple from the adaptee class or its ancestor classes to the adapter class, which may
require change to the adapter class. Moreover, if the adaptee class is a final class then
the class adapter pattern cannot be used. Unlike the class adapter, the object adapter
uses object composition and dynamic binding. These allow the adapter to dynamically
adapt any other adaptee objects. This implies that the behavior of the adapter can
change during the execution time by changing the adaptee object. The object adapter
can also override the behavior of the adaptee class. To do this, one defines a subclass
of the adaptee class and overrides the behavior of the adaptee class in this subclass.
The adapter then adapts to an object of the subclass. One disadvantage of the object
416 Part V Applying Situation-Specific Patterns
Name Adapter
Type GoF/Structural
Specification
Problem How to convert one interface to another.
Define an interface to match the one expected and let the implementing subclass adapt it to the existing
Solution
interface.
Design
Client Client
Structural
Class Adapter Object Adapter Adaptee 1 Adaptee 2
request( ) request( ) existIntface(...) existIntface(...)
adapter is that it requires the creation of at least the adapter object and the adaptee
object.
Figure 16.32 shows an application of the object adapter pattern to convert the
Edit Diagram Controller interface into the actionPerformed (ActionEvent e) interface.
The design uses multiple action listeners, that is, one for each action event source.
The action listeners serve as the adapters that convert the Controller interface to the
interface that the system expects. Of course, the listeners are added to the listener
lists of the event sources to be able to receive the action events. The design works
Chapter 16 Applying Patterns to Design a State Diagram Editor 417
as follows. When the user clicks the State button of the Editor GUI, the State button
object calls the actionPerformed (ActionEvent e) function of the State Button Listener
object. That function in turn calls the stateBtnClicked () function of the Edit Diagram
Controller. The stateBtnClicked () function changes the cursor to cross hair, and enters
a state indicating that the State button is clicked. Next, when the user clicks in the
canvas area, the actionPerformed (ActionEvent e) function of the Mouse Clicked
Listener object (not shown in Figure 16.32) is called. The function in turn calls the
mouseClicked (p: Point2D) method of the Edit Diagram Controller. The controller
remembers that the State button is clicked previously; therefore, it creates a State
object and adds it to the State Diagram composite (see Figure 16.6). The system then
repaints the state diagram including the newly created state shape. In this example,
the action listeners are both adapters and observers at the same time. This is common
when applying patterns. For simplicity, Figure 16.32 does not show that the listeners
are observers.
The adapter pattern is often used as an after-fact remedy to fix the mismatch
between two interfaces. It is useful when one wants to reuse an existing, or third-
party, component, but its interface does not match the interface that the client expects.
Use the class adapter when it needs to adapt only one adaptee class and this will not
change in the future. Use the object adapter if there are more than one adaptee class,
or the adapter needs to vary its behavior dynamically.
418 Part V Applying Situation-Specific Patterns
ActionListener
actionPerformed(e:ActionEvent)
controller
JButton JButton controller
.stateBtnClicked( ) .transBtnClicked(e)
stateButton transButton
Editor GUI
is to define a handler for each type of request and chain the handlers in the desired
order; pass each request down the chain of handlers until one that handles the request.
To illustrate, Figure 16.33 shows the application of the pattern to provide context-
dependent help for the state diagram editor. It is assumed that different widgets provide
the help differently, that is, they have different behavior. If their behavior is the same,
then one helper class is enough. Figure 16.33(a) shows the structural design. The
Helper class defines and implements methods that the subclasses can also use. In
particular, each helper has a successor helper. The constructor of the Helper class
takes in a successor helper and the help information, which could be null. The help()
method calls the next helper if it exists, or calls its showHelp() to display “no help info”
if the next helper does not exist. The subclasses of the Helper class overrides the help()
and showHelp() methods. In particular, the help() methods of the subclasses have the
same implementation. It is shown for the Dialog Helper. That is, if the concrete helper
has help information, then the helper displays it, else the helper calls the help() method
of the parent class. That is, the help() method of the Helper class is called. This results
in calling the help() method of the successor or the last helper. The showHelp() method
of each subclass implements the display mechanism for the widget.
Figure 16.33(b) illustrates how the helpers are linked together to provide
context-dependent help. The diagram is an object diagram. It shows four specific
helper objects, that is, Button Helper, Condition Helper, Dialog Helper and Editor
Helper objects. The Button Helper object and the Condition Helper object have Dialog
Helper object as the successor. This is because the Edit State Dialog in Figure 16.3
(a) Context-dependent help with chain of responsibility (b) Object diagram showing part of a chain
contains the OK button and State Condition text box. The Dialog Helper object has
the Editor Helper object as the successor because the latter contains the former. The
Menu Item objects represent the Help selections of the pop-up menus. Each of these
calls the related Helper object. This could have been accomplished by using the ob-
server pattern or the Action Listener API. For simplicity, the design in Figure 16.33
does not show this.
Suppose that the user wants help on the State Condition text box. He or she right-
clicks in the text box and selects Help. The pop-up menu item invokes the help()
method of the Condition Helper object. If the helper has help, it shows it, or else it
invokes the help() method of the Helper class. Since the Condition Helper object has
a successor, the help() method of the successor is invoked. That is, the help() method
of the Dialog Helper object is invoked. If it has help, then the help information about
the dialog is displayed. If it does not have help, then the process continues with the
parent’s help() method, and so forth. The end of the chain is a Helper object; it displays
“no help info” if its help() method is invoked.
The chain of responsibility pattern has other applications. Consider, for example,
a purchase-order handling subsystem that processes purchase orders placed by em-
ployees. The purchase orders must be approved by a manager at some level. A manager
may approve or disapprove a purchase order, or forward the request to the next higher
level, until the request is handled. The chain of responsibility pattern differs from the
other patterns presented so far. That is, the handler is one of a list of handlers, but the
exact handler cannot be determined in advance. Each request needs to go through a
chain of handlers until it is processed.
The chain of responsibility pattern results in “stupid objects” because each han-
dler implements only its responsibility and knows only its successor. Moreover, no
handler knows the responsibilities of other handlers. The chain of handlers can be up-
dated dynamically to respond to changes in the workflow. In comparison, the approach
that uses conditional statements cannot provide such a flexibility.
Chain of Responsibility and Observer deal with event handlers. In Observer,
which handler to handle which event is known in advance and all registered observers
are notified when the event occurs. In Chain of Responsibility, the exact handler for
an event is not known in advance. Moreover, an event may not be handled.
Name Decorator
Type GoF/Structural
Specification
Problem How to add/remove functionality to/from existing objects freely and dynamically.
Define an aggregate class of the existing class to provide the additional functionality. Define a
Solution
common interface to hide the difference of the two classes.
Design
component
Component
operation()
<<Decorator>> c:Concrete
client: d:Decorator 1 Component
<<new component>> create( )
Behavioral <<add decorator>> create(c)
<<do operation>> operation( ) operation( )
added( ) added functionality
super.draw(g); <<Decoroator>>
drawNote (g); UML Note
*
draw(g: Graphics) State Transition State Diagram
draw note drawNote (g:Graphics) *
<<Decorator>> <<Composite>>
client: n: UML Note s: State d: State Diagram
<<new state>> create( )
save note
<<add note>> create(s) to diagram
add(n)
<<repaint>> draw(g)
drawNote(g)
Suppose that the state diagram editor allows the user to show or hide UML
notes attached to diagram elements. Figure 16.35 illustrates how the decorator pattern
accomplishes this. The figure illustrates how a state with a UML note is created and
painted. First, the client creates a state and a UML note that decorates the state. The
note is added to the state diagram composite. During repaint, the client calls the draw
(g) method of the state diagram. The state diagram calls the draw (g) method of the
UML note. The UML note calls the draw (g) method of the state and then calls its
own drawNote (g) method. In this way, the state with a UML note is painted.
Encryption, decryption, compression, and decompression of communication
streams are other applications of the decorator pattern. That is, they add function-
ality to the communication streams. In Java, the pattern is applied to add functionality
to an input stream or an output stream. Figure 16.36 shows the Filter Input Stream
decorator. The Input Stream is the superclass of all classes that represent an input
stream of bytes. The Filter Input Stream class adds functionality to facilitate the
processing of the input stream. Its subclasses are the concrete decorators. For ex-
ample, the Buffered Input Stream provides the ability to buffer the input stream and
set and reset marks in the input stream. The Checked Input Stream computes the
checksum so that the client can use it to verify the integrity of the input data. The
Cipher Input Stream adds cryptographic functions to the Input Stream. The Progress
Monitor Input Stream decorator allows the user to monitor the progress when read-
ing a large file. It displays a progress dialog if the input stream requires a while to
Chapter 16 Applying Patterns to Design a State Diagram Editor 423
InputStream
FilterInputStream FileInputStream
import java.io.*;
import java.util.zip.*;
import javax.crypto.*;
import java.security.*;
...
try {
// 1. Create a filter input stream from a file
FilterInputStream fis = new BufferedInputStream (
new FileInputStream ("somefile.txt"));
// 2. Create an encryption cipher
Cipher cipher=Cipher.getInstance ("DES/CBC/PKCS5Padding");
// 3. Add encryption
FilterInputStream efis = new CipherInputStream (fis, cipher);
// 4. do something, e.g., send it over the Internet
// ...
} catch (IOException e) {
e.printStackTrace ( );
} catch (NoSuchAlgorithmException e1) {
e1.printStackTrace ( );
} catch (NoSuchPaddingException e2) {
e2.printStackTrace ( );
}
...
read. The program in Figure 16.37 illustrates the use of the Cipher Input Stream
decorators.
Patterns improve productivity and quality. Therefore, the team members should
be trained, encouraged, and empowered to apply patterns. However, patterns must
not be misused or abused (see the “good enough is enough” guideline below).
Patterns must not be applied just for the sake of documentation. Patterns should
be applied to improve quality of the working software and productivity of the team.
This requires that the team knows how to apply the right pattern, at the right time, to
solve the right problem, in the right way.
Patterns should be applied to solve design problems, not for the sake of deco-
rating the design with patterns. Patterns must not be applied to solve trivial design
problems, or problems that are not worth applying a pattern to. This is because in
most cases, patterns required to design, implement, and manage more classes and
relationships between the classes. For trivial problems, the application of patterns
probably introduces more complexity than not applying them. Consider, for example,
the drawing of a transition in the state diagram editor. It is true that sometimes a
transition may consists of line segments plus an arrow line. These are easy to draw
using Java Graphics2D. If the builder pattern is applied to draw the line segments,
the arrow line, and the transition label, then the pattern is misused. Good enough is
enough means that patterns should be applied when they are needed, not when they
are wanted. It is not the case that the more patterns the better.
SUMMARY
•
This chapter presents situation-specific patterns, each are applied during the design process when design
of which solves a class of design problems. Pattern problems are encountered. Patterns are identified and
application is a challenge for beginners. Therefore, applied to solve the design problem. How to generate
this chapter describes a problem-directed approach skeleton code from the design and the pattern is also
for applying patterns. It demonstrates the process with described in the chapter.
the design of a state diagram editor. That is, patterns
FURTHER READING
•
Gamma, Helm, Johnson, and Vlissides were the first to pro- this book). In addition, Larman’s book includes application
vide a systematic presentation of the 23 patterns described of patterns to the design and construction of a few frame-
in this book. Their book [67] provides a detailed and thor- works, including the persistence framework described in the
ough treatment of the 23 patterns. Larman [104] presents the next chapter.
patterns as well as nine GRASP patterns (see Chapter 10 of
Chapter 16 Applying Patterns to Design a State Diagram Editor 425
EXERCISES
•
16.1 Produce the skeleton code for the design in Fig- 16.5 The interpreter pattern (see Chapter 15) executes the
ure 16.11 from the skeleton code for the strategy val (c:Context):int function of each node of the parse
pattern. Hint: Substitute the classes and operations tree during a postorder traversal. Design and imple-
in the existing design for the classes and operations ment a postorder traversal algorithm as a postorder
in the strategy pattern. iterator and apply it to evaluate the following busi-
16.2 What are the advantages of applying the visitor pat- ness rule:
tern to the state diagram editor as shown in Fig-
ure 16.15? Order.getAmout() >= $250.00
16.3 Discuss the similarities and differences of the two ==> Order.setDiscountRate(0.10)
patterns in each of the following pairs of patterns.
Moreover, give two situations that are not in the text- It states “if the order amount is greater than or equal
book or the lecture notes in which each pattern can to $250.00 then set the discount rate to 10%.”
be exclusively applied to exactly one situation. De- In addition, discuss the pros and cons to use the
scribe how each pattern is applied and why the other iterator pattern to implement the traversal algorithm.
is not applicable. 16.6 Design, implement, and test the subsystem for pur-
a. Decorator and visitor chase order processing described in Section 16.5.4.
b. Memento and state Assume that there are three levels of approval au-
c. Abstract factory and builder thorities: project manager, engineering director, and
d. Strategy and visitor cooperate finance. They can approve each purchase
e. Flyweight and singleton that is within $10,000, $100,000, and $1 million, and
f. Observer and controller not to exceed a total of $100,000, $1 million, and $10
g. Abstract factory and creator million per year, respectively.
16.4 The preorder traversal processes the node visited 16.7 Which other patterns can be applied to simplify the
first, and then visits the left child and the right child of design and implementation of the purchase-order
the node. Write an algorithm to implement an iterator processing subsystem? How can this be accom-
for the preorder traversal. plished? What assumptions must be made?
17
Applying Patterns to
Design a Persistence
Framework
Chapter 16 presented a pattern application process and patterns for solving various
design problems. The patterns are applied to the design of a state diagram editor.
The state diagram editor needs to store the diagrams in a database. In procedural
programming, the functions access the database directly, resulting in the so-called
embedded code. It means that database queries are embedded in the procedural pro-
grams such as C code to access the database. Influenced by procedural programming,
some programmers design and implement object-oriented systems the same way. That
is, the object-oriented program lets business objects access the database directly. This
approach has several problems. In this chapter, the problems are discussed and the
design of a persistence framework is described. During this design process, several
patterns are applied. The design of the framework is illustrated for the state diagram
editor case study. However, the result is applicable to all application systems that
need to store and retrieve objects with a database. In this chapter, you will learn the
following:
426
Chapter 17 Applying Patterns to Design a Persistence Framework 427
saveX(x:X) DB-1
insert into TableX ...
saveX(x:X) saveX(x: X) saveX(x:X) query
(a) Tight coupling between controller and database (b) Hiding the databases with a DB manager
Name Bride
Type GoF/Structural
Specification
Problem How does one maintain a stable client interface while the implementation changes.
Solution Decouple the implementation from the client interface so they can change independently.
Design
Structural
imp.operation1( )
operation1()
Behavioral operation1()
• Client Interface: A class that defines the client interface. It maintains a reference to a Concrete Implementation object and
Roles and delegates the client requests to the Concrete Implementation object. By changing the reference, the implementation changes.
Responsibilities • Implementation Interface: An interface or abstract class that defines a common interface for the Concrete Implementation
classes.
• Concrete Implementation classes: These classes implement the Implementation Interface with varying behavior.
• It decouples the Concrete Implementations from the Client Interface.
• It maintains a stable Client Interface while allowing the implementation to change.
Benefits • The Client does not know which Concrete Implementation is used.
• It is easy to introduce additional Concrete Implementations.
• The Client is not affected by changes to the Concrete Implementations.
Liabilities More classes to implement but the benefits are worth the extra effort.
• Apply the bridge pattern in cases where change of implementation is anticipated.
Guidelines • The Client Interface and the Implementation Interface may be different. That is, their function signatures don’t need to be the
same.
• Similar to Object Adapter. However, Bridge is used “before the fact” while Adapter is used “after the fact.”
Related Patterns • Bridge is often confused with Strategy. In both patterns, the concrete subclasses differ only in implementation, not in
functionality. However, Strategy requires the Client to select the strategy while in Bridge the Client does not know which
Concrete Implementation it uses; and hence, it does not select the implementation.
Uses Persistence framework and desktop applications to support different window operating systems.
are difficult and costly. A better design should separate the database access respon-
sibilities from the controller and assign them to a Database (DB) manager (denoted
DBMgr), as shown in Figure 17.1(b). In this design, the controller is responsible for
handling actor requests while the DBMgr handles database access. In this way, the
DBMgr hides the database access from the business objects. Changes to the database
will have little impact on the business objects. In most cases, the DBMgr delegates
the requests from the controller to other objects, which access the database.
The bridge pattern can be used to accomplish the goals of the DB manager. The
specification of the pattern is given in Figure 17.2. The main idea behind the bridge
pattern is decoupling the client interface from the implementation so that each of them
can change independently. It solves the problems discussed in Section 17.1 because
the controller as the client is decoupled from the database access implementation.
Therefore, change to the database implementation has little impact on the controller.
Figure 17.3 shows the skeleton code for the bridge pattern.
The bridge pattern can be applied to eliminate the problems associated with direct
database access. As an example, consider the design of a graphical editor for a state
diagram. One of the requirements for the editor is that the editor should be able to
store and retrieve state diagrams with a database. Figure 17.4 shows the application
of the bridge pattern to provide these capabilities. In the figure, LDAP stands for
lightweight directory access protocol, a hierarchical database management system.
The mapping of the classes and operations between the design and the bridge pattern
is shown in Figure 17.5.
The DBMgr decouples the client from the database access implementation to
provide a stable interface for the client. The DBImpl Interface allows different
implementations to realize the database access functionality. The DBMgr maintains
a reference to a concrete database access implementation. When the client invokes an
430 Part V Applying Situation-Specific Patterns
Edit Controller
invoke <<Bridge>>
DBImpl Interface
return <<Bridge>> getDiagram(name:String):
imp.getDiagram(name); DBMgr imp State Diagram
getDiagram(name:String): saveDiagram(d: State Diagram)
State Diagram connectDB( )
saveDiagram(d: State Diagram) disconnectDB( )
1. connectDB( )
2. get state diagram
information from a RDB Impl LDAP Impl
relational DB getDiagram(name: getDiagram(name:
3. create and populate a String): State Diagram
String): State Diagram
State Diagram object saveDiagram(d: State
saveDiagram(d: State
4. disconnectDB( )
Diagram) Diagram)
5. return State Diagram
connectDB( ) connectDB( )
object
disconnectDB( ) disconnectDB( )
operation of the DBMgr, the DBMgr delegates the request to the concrete database
access implementation. In this way, the client is decoupled from the concrete imple-
mentation. The client is not affected by changes in the implementation so long as the
DBMgr interface remains the same.
In Figure 17.4, the DBMgr and the DBImpl Interface contain the same set of op-
erations. But it need not be the case. The two may contain different sets of operations.
Chapter 17 Applying Patterns to Design a Persistence Framework 431
To save space, only two operations are shown in Figure 17.4. In general, if an ap-
plication needs to store objects of N different classes, then the DBMgr will have at
least N × 2 operations, that is, for each class X, there are two operations, getX(. . .):X
and saveX(x:X). In addition, the DBMgr may have other operations to search objects
and generate statistical reports. Figure 17.6 shows the generated skeleton code for the
design.
Name Command
Type GoF/Behavioral
Specification
Problem How to decouple the operations of an object class so that their execution can be arranged dynamically.
Solution Define a uniform command interface and let the concrete commands implement the decoupled operations of the object class.
Design
Structural
Command Interface
Client
* result: Object
execute()
implements one of the getResult():Object
decoupled operations of
the original class
Behavioral
client: c:Concrete Command K
create(parameters)
execute()
o:=getResult():Object
Roles and • Client: It creates the desired command objects, invokes their execute() operations and gets the results in whichever order
Responsibilities it wants. It may also queue the commands and execute them at a later time.
• Command Interface: It defines a uniform interface for the Concrete Command classes so that the client may not know
which command it is executing.
• Concrete Command: Each Concrete Command class implements one operation of the original object class.
Benefits • It encapsulates operations as command objects, allowing the operations to be executed in flexible ways.
• Commands can be composed to form composite commands using the composite pattern.
• It is easy to add new commands.
• It supports undo and redo operations.
Liabilities More classes to implement.
Guidelines
Related Patterns Command is often confused with Bridge. The Concrete Commands differ in functionality but in Bridge the Concrete
Implementations differ in implementation, not functionality. In Bridge, the Client does not create or invoke the Concrete
Implementation objects; in Command, the client creates and invokes the Concrete Command objects. Command is different
from Strategy in that the Concrete Strategies usually differ only in implementation, not functionality.
Uses Persistence framework, agent-oriented systems to implement planned actions, undo and redo database operations, etc.
additional operations:
1. undo(): This method simply reverses the execute() operation of the previous
command.
2. redo(): This method simply reverses the last undo command.
3. reversible(): boolean: This method returns true if the command can be undone,
else it returns false.
Chapter 17 Applying Patterns to Design a Persistence Framework 433
• The application needs to queue the requests and execute them at a different time.
For example, JUnit stores test cases in a composite and executes them when the
test runner is invoked. A rational agent generates plans of actions and executes
them at appropriate times. Updates to a database can be queued and committed at
a later time. The command pattern lets the application store the command objects
and execute them as scheduled.
• The application needs to change the execution sequence of actions dynamically.
For example, a rational agent needs to generate and update plans at runtime to
adapt itself to the changing world. The command pattern makes it easy to support
such design objectives.
• The application needs to support undoing and redoing operations. Many ap-
plications need such capabilities. For example, all editor applications require
these functions. Certain software fault-tolerant systems can recover from soft-
ware faults. When the system recovers, it may need to undo some of the operations
performed previously. The command pattern is useful for such applications.
• The application needs to log changes and redo them during system recovery.
Some approaches to software fault tolerance periodically save the system states.
During recovery, the system returns to the previous state, and performs the logged
operations. The command pattern and the memento pattern are useful for the
design and implementation of such systems.
Figure 17.9 shows an application of the command pattern to the design of the
persistence framework. The mapping between the design and the command pattern
1. connect to database
2. save the State Diagram
object to the database
3. disconnect from database
is shown in Figure 17.10. The DBCmd defines a uniform interface for the Con-
crete Commands, which implement the database operations. There is a one-to-one
correspondence between the database operations and the Concrete Commands. For
example, the Get Diagram class implements the getDiagram(. . .) operation of the
RDB Impl class. The data needed by the operation are passed as parameters to the
Concrete Command constructor. For example, the diagram name string is passed
to the constructor of the Get Diagram class to be used by the execute() method
to retrieve the state diagram. In Figure 17.9, the RDB Impl class is the Client. Its
operations create the Concrete Command objects and call their execute() methods to
carry out the database operations. For example, the saveDiagram(d:State Diagram)
method creates a Save Diagram object and calls its execute() function to save the state
diagram.
The skeleton code for the design could be generated from the command pattern
code and the mapping specified in Figure 17.10. That is, the mapping is used to
substitute the design classes and operations for the pattern classes and operations.
This is largely a mechanical process and can be accomplished by a simple program.
The generated code is displayed in Figure 17.11.
public abstract class DBCmd { // New public class DisconnectDB extends DBCmd { // New
Object result; ...
public abstract void execute(); }
public Object getResult() { return result; } public class RDBImpl implements DBImplInterface {
} // Existing
public class GetDiagram extends DBCmd { // New public StateDiagram getDiagram(String name) {
String name; GetDiagram getDiagram=new GetDiagram(name);
public GetDiagram(String name) { getDiagram.execute();
super(); return (StateDiagram)getDiagram.getResult();
this.name=name; }
} public void saveDiagram(StateDiagram d) {
public void execute() { SaveDiagram saveDiagram
/* get diagram from DB */ =new SaveDiagram(StateDiagram d);
} saveDiagram.execute();
} }
public class SaveDiagram extends DBCmd { // New public void connectDB() {
StateDiagram d; ConnectDB connectDB=new ConnectDB();
public SaveDiagram(StateDiagram d) { connectDB.execut();
super(); ...
this.d=d; }
} public void disconnectDB() {
public void execute() { DisconnectDB disconnectDB=new DisconnectDB();
/* save diagram to DB */ disconnectDB.execute();
} }
} }
public class ConnectDB extends DBCmd { // New
...
}
using a communication protocol. These add functionality to the database access imple-
mentation. Previously, the implementation accesses a local database. Now the imple-
mentation needs to handle network communication, marshalling and unmarshalling.
On the other hand, a remote component accesses the database instead of the local
counterpart. These change the role of the implementation. It becomes a placeholder
or proxy for the remote component. This is the idea of the proxy pattern, described
in Figure 17.12. Figure 17.13 illustrates the four types of commonly used proxies.
An application of a virtual proxy is delaying the loading of a large image until
a request to display the image is received. At that time, the image is actually loaded.
If no request to display the image is ever received, then the image is not loaded.
In this sense, it improves performance and reduces memory consumption because
images take time to load and memory space to store. An example of a protection
proxy is access control, where the right to read, write or execute a resource is granted
to the resource owner, a group of members, or the public. Another example is role-
based access control (RBAC), where the right to read, write, or execute a resource is
granted according to the role played by the user. Smart reference proxies implement
mechanisms to make smart use of an object including:
1. Counting the number of references to the object so that memory space can be
released when the count drops to zero. This reduces memory consumption, which
is critical for mobile applications.
Chapter 17 Applying Patterns to Design a Persistence Framework 437
Name Proxy
Type GoF/Structural
Specification
Problem How does one provide a substitute for an object to control access to it?
Solution Define a Proxy class with the same interface as the substituted object. The proxy implements the control,
and hides the substituted object.
Design
Common Interface
Client
request()
...
real.request( );
...
Structural
Proxy Substituted
request( ) request( )
real
request( )
request( )
Behavioral
Common Common
Interface Interface
Keep track of access to
request() the Substituted object so request()
if (validAccess()) that resources are
real.request() released when no other
object accesses it.
FIGURE 17.13 The proxy pattern, remote proxy, and virtual proxy
4. Loading a persistent object into the memory when it is first referenced. For
example, an Integrated Development Environment (IDE) may delay the loading
of the various analysis and design diagrams until they are accessed. This improves
performance and resource utilization because not all of the diagrams will be
viewed during a given session.
5. Locking and unlocking a shared object to avoid inconsistent update. For example,
observers may update an observable object concurrently. In this case, a proxy can
be used to lock and unlock the observable object to prevent concurrent update.
Figure 17.14 shows the application of a remote proxy to the design of the per-
sistence framework. It assumes that the RDB database is a remote database. Thus, a
remote proxy is used. Figure 17.15 specifies the correspondence between the classes
and operations in the design in Figure 17.14 and the proxy pattern. The RDB Impl
Proxy communicates with the remote RDB database. The proxy acts on behalf of
its remote counterpart and hides the network from the DBMgr. The design works as
follows. The DBMgr object creates an instance of RDB Impl Proxy. Requests from
the Edit Controller are delegated by the DBMgr to the proxy. The proxy handles
network communication, marshalling and unmarshalling operations to communi-
cate with its remote counterpart. The remote counterpart actually accesses the re-
mote database. The design hides the remote database access component from the
DBMgr. As a consequence, the DBMgr is not aware that the database locates at
a remote site.
Chapter 17 Applying Patterns to Design a Persistence Framework 439
Edit Controller
<<Bridge>>
invoke DBImpl Interface
<<Remote Proxy>>
Net Interface
openSocket()
This class handles This class resides on a
network communication,
closeSocket() remote machine and
marshalling, and send(...) accesses a remote
unmarshalling. receive(...) database.
The concrete command classes for doing the database operations differ only in
steps (2) and (4). The other steps are the same for all database access operations
for a DBMS. These steps are duplicated in the command classes. The programmer
needs to write duplicate code in many command classes. This extra effort invites
440 Part V Applying Situation-Specific Patterns
more work when the shared steps are changed. This may cause inconsistent updates
to the command classes. Many software engineers recognize these problems and use
refactoring. That is, an abstract parent class is introduced. It implements the common
steps and a template method to perform the four steps above. The database access
command classes inherit the common steps and the template method from the parent
class and implement only the steps that differ. This idea is captured in the template
method pattern, described in Figure 17.16.
The template method pattern can be applied to improve the database access com-
mands in the persistence framework. Figure 17.17 shows how to accomplish this. The
RDB Impl Cmd class defines a template method—execute(). The hook methods are
queryDB() and processResult() because they are different for different database access
commands. The Get Diagram and Save Diagram subclasses implement these hook
methods to retrieve and save a diagram, respectively. The client of the template method
in Figure 17.17 is the RDB Impl class. The UML note of its saveDiagram(d: State
Diagram) method illustrates how the pattern is used. That is, it creates a Save Diagram
Chapter 17 Applying Patterns to Design a Persistence Framework 441
create( )
Behavioral templateMethod( )
hookMethod( )
• Client: It creates the desired Concrete Class K object and invokes its templateMethod( ).
Roles and • Abstract Class: It implements a template method in which the steps to vary are calls to abstract methods
Responsibilities implemented by the Concrete Classes.
• Concrete Class: Each Concrete Class implements the hook methods according to its own behavior.
• It requires less effort to add concrete subclasses because duplicate code is eliminated.
• It facilitates code change because change is needed at only one place.
Benefits • The behavior of the template method can be changed dynamically by changing the reference to an
object of a different Concrete Class.
<<Bridge>> <<Bridge>>
Edit DBMgr DBImpl Interface
Controller imp
getDiagram(name:String): State Diagram getDiagram(name:String): State Diagram
saveDiagram(d: State Diagram) saveDiagram(d: State Diagram)
// a template method
<<Template Method>>
try {
RDB Impl Cmd RDB Impl
connectDB();
queryDB(); execute() getDiagram(name:String): State Diagram
disconnectDB(); connectDB() saveDiagram(d: State Diagram)
processResult(); disconnectDB()
} catch (SQLException e) { getResult(): Object
disconnect( ); queryDB() 1..* delegate
} processResult() RDBImplCmd sd=
new SaveDiagram(d);
sd.execute( );
Query the database to
retrieve the diagram data <<Template Method>> <<Template Method>>
Get Diagram Save Diagram
save diagram to
GetDiagram(name: String) SaveDiagram(d:State Diagram) database
queryDB() queryDB()
Create a state diagram and processResult() processResult() do nothing
populate it with query result
object and calls the object’s execute() method. Since Save Diagram inherits the exe-
cute() method from RDB Impl Cmd, the call in effect executes the template method.
That is, it calls the connectDB() of RDB Impl Cmd, the queryDB() of Save Diagram,
disconnectDB() of RDB Impl Cmd, and then processResult() of Save Diagram. In
Figure 17.17, each of the RDB Impl Cmd, Get Diagram, and Save Diagram classes
applies two patterns—the command pattern and the template method pattern. For
simplicity, the figure only shows “<<Template Method>>.”
One variation of the template method lets the parent class provide a default im-
plementation for the hook methods. A subclass overrides the hook methods to provide
its own behavior. Another variation lets the subclasses override the concrete methods
as well. A special case of the template method is the factory method, presented in the
next section.
...
Product p=factoryMethod( );
...
Abstract Class
return new Product
algorithmMethod( ) ConcreteProductN( );
Client factoryMethod():Product
Structural
create( )
Behavioral algorithmMethod( )
p=factroyMethod( ):
Product
• Client: It creates an object of the desired Concrete Class and invokes its algorithmMethod( ).
• Abstract Class: It implements a skeleton of an algorithm that uses objects of varying classes returned
by calls to an abstract factory method. It lets the subclasses implement the factory method to determine
Roles and the type of product to create.
Responsibilities • Concrete Classes: Each Concrete Class implements the factory method to return a product of a certain
type.
• Product: It defines a common interface for the Concrete Product classes.
• Concrete Products: These are concrete product types used by the template algorithm.
Benefits Same as Template Method.
Liabilities A few more classes to implement.
Guidelines
• Factory Method is a special case of Template Method. It is Template Method applied to object creation.
Related Patterns • Factory Method is often used to implement the functions of a concrete factory in Abstract Factory.
• Factory methods are often called from a template method.
Uses Similar to Template Method.
<<Factory Method>>
RDB Impl Cmd RDB Impl
try { name: String saveClassDiagram(d: Diagram
1..*
connectDB( ); diagram: Diagram saveStateDiagram(d: Diagram)
queryDB( ); resultSet: ResultSet getClassDiagram(name:String): Diagram
disconnectDB();
RDBImplCmd(name:String) getStateDiagram(name:String): Diagram
diagram=processResult( );
} catch (SQLException e) { execute( )
disconnect( ); queryDB() GetStateDiagram g=new
} processResult():Diagram factory GetStateDiagram(name);
connectDB( ) method g.execute( );
disconnectDB( ) return g.getDiagram( );
<<Factory Method>> <<Factory Method>> << Factory Method>> << Factory Method>>
Get Class Diagram Get State Diagram Save Class Diagram Save State Diagram
GetClassDiagram(name: String) GetStateDiagram(name: String) SaveClassDiagram(name: String) SaveStateDiagram(name: String)
queryDB( ) queryDB( ) queryDB( ) queryDB( )
processResult( ): Diagram processResult( ): Diagram
Figure 17.19 shows an application of the factory method to the persistence frame-
work. It is assumed that the UML diagram editor needs to store and retrieve class
diagrams and state diagrams. In the figure, the processResult(): Diagram method is
the factory method, which is called by the execute() method of RDB Impl Cmd.
The subclasses of Get Diagram implement the processResult(): Diagram method to
return a class diagram and a state diagram, respectively. In this example, there is no
real benefit compared with the design in Figure 17.17. The example only serves to
illustrate how the factory method is used.
resultSet: ResultSet query result for a class diagram query result for a state diagram
diagram: Diagram stores the resulting Class Diagram object stores the resulting State Diagram object
name: String name of the class diagram to be retrieved name of the state diagram to be retrieved
queryDB() String qStr= “SELECT * FROM ClassDiagram”+ String qStr=“SELECT * FROM StateDiagram ”+
“WHERE name = \””+ name+“\””; “WHERE name = \””+ name+ “\””;
Statement stmt=con.createStatement(); Statement stmt=con.createStatement();
resultSet=stmt.executeQuery(qStr); resultSet=stmt.executeQuery(qStr);
processResult() diagram=new ClassDiagram(name); diagram=new StateDiagram(name);
diagram.attrA=resultSet.getTA(attrA); diagram.attrX=resultSet.getTX(attrX);
diagram.attrB=resultSet.getTB(attrB); diagram.attrY=resultSet.getTY(attrY);
diagram.attrC=resultSet.getTC(attrC); diagram.attrZ=resultSet.getTZ(attrZ);
... ...
connectDB() (same for both classes)
disconnectDB()
Legend: attrA=attribute name TA=type of attrA Bold face font shows the differences between the two classes
FIGURE 17.20 Get Class Diagram and Get State Diagram compared
to retrieve the desired diagram. This is the idea of the prototype pattern, specified in
Figure 17.21.
Figure 17.22 illustrates how the prototype pattern is used to reduce the number
of command classes needed to access a database. The Get Diagram class extends
the RDB Impl Cmd command class and implements the Prototype interface. It can
retrieve any type of UML diagram from the database. Its processResult() method uses
Java reflection to process the query result and populate the attributes of the diagram
object. The implicit assumption is that the attribute names and types of the classes
and the database tables that store the instances of the classes must match with each
other. This allows the design to use Java reflection to fill the attributes of the diagram
object with the corresponding data in the resultSet. This assumption may be dropped
by using the Properties application programming interface (API). This API lets the
programmer specify the mapping in a text file. The mapping is loaded into a hash table,
which can be used with Java reflection to fill the attributes of the diagram objects.
Figure 17.22(b) shows how a client retrieves a class diagram and a state diagram,
respectively. The client retrieves the desired diagram prototype from the prototype
manager, makes a copy of the prototype, and casts the copy to the appropriate class
type. The client sets the diagram name, table name, and the diagram object. These
are used by the queryDB() and processResult() methods to query the database and
populate the diagram object. In particular, the diagram object is used to identify
the diagram class and obtain its attribute names and types. The attribute names and
types are used to query the resultSet and fill the attributes of the diagram object. The
prototype pattern is very useful if the number of classes that can be prototyped is
large. For example, for car-related businesses such as car rental, new car, and used
car dealerships, prototype can reduce the number of car classes. This is because all
446 Part V Applying Situation-Specific Patterns
Name Prototype
Type GoF/Creational
Specification
Problem How does one reduce the number of classes that share similar behavior and relationships?
Define a class to replace all the classes that share similar behavior and relationships. Save instances,
Solution called prototypes, of this class. To create an instance of any of the classes replaced, simply clone the
desired prototype and modify its attributes.
Design
...
<<Singleton>>
Prototype p=PrototypeMgr.
getInstance( ).get(key); PrototypeMgr
if (p==null) { get(key): Prototype
create prototype p;
add(key, Prototype)
add to prototype pool; Class 1 Class N
} remove(key)
Structural attribute1 attributeN
Class1 c1=(Class1)p.clone( );
c1.setAttribute1(value1); maintain operation1( ) operationN( )
c1.operation1( ); clone( ) clone( )
...
pool *
Prototype
Client
clone(): Prototype
• Client: It retrieves the desired prototype from the PrototypeMgr, clones the prototype and
changes the attributes of the clone. It then uses the clone.
Roles and • PrototypeMgr: It manages the prototypes.
Responsibilities • Prototype: It defines an interface containing a clone( ) method for all types of concrete prototypes.
• Class 1-N: Types of prototypes. These classes implement the clone( ) method of Prototype.
• It supports dynamically loaded classes (DLC), which cannot be referenced at compile time.
The class loader creates and registers an instance of the DLC at runtime when the DLC is loaded.
• It is easy to add or remove prototypes at runtime.
Benefits
• It improves the efficiency of complex object creation because cloning may be more efficient than
constructing the object.
• It reduces the number of classes.
• The subclasses of Prototype must implement the clone( ) method. This requires deep-copying
Liabilities if the instances and the original must be independent; otherwise, shallow-copying is sufficient.
• Implementing clone() may be difficult or impossible if the class is final or there are circular references.
Apply prototype to classes that share the same behavior, same set of relationships, and differ
Guidelines
only in attribute values.
• Abstract Factory may use Prototype to create the products.
Related Patterns • Flyweight reduces the number of instances of a class while Prototype reduces the number
of classes. They can be used together to accomplish both objectives in some applications.
Uses See Benefits
SUMMARY
•
This chapter presents several situation-specific pat- sign a UML diagram storage subsystem for a diagram
terns. These are bridge, command, factory method, editor such as part of an integrated development envi-
prototype, proxy, and template method. It also ronment (IDE). First, problems with direct database
presents how to apply these patterns to the design of access are identified. Patterns are then applied to solve
a data storage subsystem called a persistence frame- the problems and improve the design. This pattern ap-
work. In particular, the chapter explains how to de- plication process is iterative during the design process.
448 Part V Applying Situation-Specific Patterns
FURTHER READING
•
Gamma, Helm, Johnson, and Vlissides [67] are the first to struction of a few frameworks, including the persistence
provide a systematic presentation of the situation-specific framework. Reference [64] is an excellent introduction to
patterns. Larman [104] presents the situation-specific pat- more than a dozen commonly used situation-specific pat-
terns as well as nine GRASP patterns. In addition, Larman’s terns including the command, proxy, and template method
book includes application of patterns to the design and con- patterns presented in this chapter.
EXERCISES
•
17.1 Discuss the similarities and differences of the two has the correct pass code. Moreover, only one client
patterns in each of the following pairs of patterns. can access the object at any time.
Moreover, give two situations that are not in the text- 17.4 Design and implement a persistence framework for
book or the lecture notes in which each pattern can accessing a local database using only the bridge and
be exclusively applied to exactly one situation. De- command patterns. The design does not need to con-
scribe how each pattern is applied and why the other sider that the database management system (DBMS)
pattern cannot be applied. may change in the future. As tests, store and re-
a. Bridge and command trieve Book and Patron objects with the persistence
b. Flyweight and prototype framework. Choose your implementation language
c. Singleton and prototype and DBMS, or as directed by your instructor.
d. Abstract factory and factory method 17.5 Modify the design and implementation in exer-
e. Adapter and proxy cise 17.4 to allow undo and redo database operations.
f. Bridge and strategy
17.6 Design and implement a persistence framework to
g. Adapter and bridge
access a local database. The design should consider
h. Decorator and proxy
that the local DBMS may be replaced in the future.
17.2 Design and implement a prototype management sys- Choose your implementation language and DBMS,
tem as shown in Figure 17.21, that is, the Prototype or as directed by the instructor.
interface and the PrototypeMgr. Use the system to
17.7 Change the design and implementation of the persis-
create cars of different makes and models, and doc-
tence framework in exercise 17.6 to take into account
uments of different types such as books, periodicals,
that the persistence framework needs to support local
and conference proceedings. Demonstrate how the
as well as remote databases.
system works using sample data.
17.8 Describe two situations in which the prototype pat-
17.3 Design and implement a protection proxy that allows
tern can be applied to reduce the number of classes
a client to access a protected object only if the client
in one, but not the other situation.
part VI
Implementation and
Quality Assurance
Chapter 18 Implementation Considerations 450
Chapter 19 Software Quality Assurance 469
Chapter 20 Software Testing 501
449
18
Implementation
Considerations
Previous chapters presented object-oriented analysis and design. The design activity
produces the sequence diagrams, state diagrams, activity diagrams, and the design
class diagram (DCD). Moreover, the classes are logically organized into packages.
In this chapter, the design is converted into source code, which is compiled into
executable programs. During this process, the team must consider several factors
that affect the implementation. These include coding standards, how to organize the
classes and web pages, how to translate the design into object-oriented programs,
and how to assign the implementation work to the team members. Throughout this
chapter, you will learn the following:
• What are coding standards, and how do you implement them in your teamwork?
• How do you organize the source files and executable programs?
• How do you convert the design diagrams to code skeletons?
• How do you assign the implementation work to team members?
• How do you conduct test-driven development, pair programming, and ping-pong
programming?
450
Chapter 18 Implementation Considerations 451
On the other hand, a good practice of coding standards improves software productivity
and quality while reducing cost and time to market. Therefore, most companies de-
velop and require programmers to comply with company-specific coding standards.
Good practices of coding standards require an understanding of the following, which
are the focuses of this section:
1. What are coding standards?
2. Why use coding standards?
3. What are the guidelines for practicing coding standards?
Item Description
File name full path name of the file that contains the program including the name of the hard drive
Version number the version number and release number (useful for versioning, maintenance, and software reuse)
Author name name of the programmer who creates the program file and writes the first version of the program
Project name full name of the project for which the program is initially written
Organization full name of the organization
Copyright copyright information
Related Requirements a list of requirements implemented by the program
List of classes* a list of the names of the classes contained in the program file
Related documents a list of related documents, and their URLs if available
a list of updates, each specifies the date of the update, who performs the update, what is updated,
Update history why the update, and possibly the impact, risks, and resolution measurements
Reviewers* a list of reviewers and what each of them reviews
Test cases* a list of test scripts along with their URLs if available
Functional an overall description of the functionality and behavior of the program—that is, what the
Description program does and how it interacts with its client.
a list of error messages that the program may generate along with a brief description of each
Error messages
of them
Assumptions a list of conditions that must be satisfied, or may affect the operation of the program
a list of restrictions on the use of the program including restrictions on the input, environment,
Constraints
and various other variables
*optional item
The coding standards should specify the language and format that should be used
to describe the items. For example, the sentences used to specify the items should be
in third person and simple present tense. Figure 18.2 illustrates an example format.
The coding standards should specify the coding requirements and conventions. The
difference is that requirements are compulsory and conventions leave the decision
to the programmer. The organization and the project manager decide which rules
are coding requirements and which are coding conventions. For convenience, no
distinction is made between the two in the following presentation. Coding conventions
include:
1. Naming conventions. These conventions specify rules for naming packages, mod-
ules, paths, files, classes, attributes, functions, constants, and the like. Naming
conventions should help program understanding and maintenance. The names
that are selected for the classes, attributes, functions, and variables should con-
vey their functionality and semantics, and facilitate understanding of the program.
Moreover, the names should be the same, or easily relate to the names in the de-
sign. Meaningless names such as “flag,” “temp,” “x,” “y,” “z,” and the like, must
not be used. In addition, names must not contain space, control characters, or
special letters.
Chapter 18 Implementation Considerations 453
/**
* File Name : Rectangle.java
*
* The University of Texas at Arlington
* Software Engineering Center for Telecommunications
* Object Oriented Testing Project
*
* (c) Copyright 1998 University of Texas at Arlington
* ALL RIGHTS RESERVED
*
* Input : This class is constructed from input passed by the Layout
class. This class is constructed by invoking the super class
constructor. Refer to Shape.java for information on Input.
* Output : A Rectangle class to represent sequential statements is
constructed and is used to draw a rectangle of the Flowgraph.
* Supported Requirements : BBD_R19, BBD-R20, BBD-R23, BBD-R25, BBD-R26.
* Constraints : The text associated with the Shape is printed in the Shape
only when the zoomRatio is above 3.
* Assumptions : It is assumed that the text will not be visible when the
zoomRatio is less than 4 and hence it is not displayed.
*
**/
In Java, classes are stored in .java files with the same name as the class
except inner classes. Class names have a capital initial. If the class name consists
of several words, then each word has a capital initial and the words are lumped
together like UndergraduateStudent. Attribute names, function names, and local
variable names are like class names except that the first letter is not capitalized.
Names for constants are all capital, like MAX.
2. Formatting conventions. Formatting conventions specify formatting rules used
to arrange program statements. These include line break, indentation, alignment,
and spacing. Most integrated development environments (IDE) define a default
format, which can be changed according to the needs of the software development
organization. In Figure 18.3, the formatting conventions are illustrated.
3. In-code comment conventions. If it is written properly, in-code comments facili-
tate program understanding and maintenance. Thus, the coding standards should
454 Part VI Implementation and Quality Assurance
package bbd.display;
import java.io.*;
import java.awt.*;
/**
*
* Purpose : This class is used for drawing a Rectangle Shape of the FlowGraph.
*
* Usage Instructions :
*
* @author Withheld
* @Version Original
* @see java.awt.Graphics
* @see http://java.sun.com/products/jdk/1.1/docs/api/
* java.awt.Graphics.html#_top_
**/
/**
*
* Method Name : Rectangle
* Purpose : Constructor of the Rectangle class. It calls the super class
constructor to initialize the class variables.
*
**/
public Rectangle( String id, int Type, String shape, int number,
String code )
{
/**
*
* Method Name : setCoordinates
* Purpose : It finalizes the coordinates of the Rectangle class at a zoomRatio
= 5 and stores them in attributes.
* Miscellaneous : The attributes are initialized as follows. attributes[0] stores the
x coordinate of the top left corner. attributes[1] stores the y
coordinate of the top left corner. attribute[2] stores the width,
whereas attribute[3] stores the height of the Rectangle.
*
**/
attributes[0] = x - WIDTH/2;
attributes[1] = y - HEIGHT/2;
attributes[2] = WIDTH;
attributes[3] = HEIGHT;
}
...
define the requirements and guidelines including the locations where in-code
comments must, or should be provided, and the formats to write the comments
so that tools can process them.
Finally, rules and responsibilities for creating and implementing the coding stan-
dards as well as reviewing and improving the practice must be defined. For example,
should the standards be applied to all the programs created, or just to some of the
programs created? Should the coding standards be applied to test case scripts, or test
case programs? Should the test case programs use the same coding standards? Who
should be responsible for defining the coding standards, and who should be responsi-
ble for educating the programmers to follow, or comply with the standards? Answers
to these questions require a definition of rules and responsibilities.
5. Are programming constructs used correctly and properly? For example, improper
uses include using an array to store a large number of elements, loops without
proper termination conditions, and uncontrolled update to shared variables.
6. Does the program correctly implement the algorithms and data structures?
7. Are there any errors or anomalies in the definition and use of variables such
as memory is allocated but not released, variables are defined but not used, or
variables are incorrectly initialized?
8. Are there any incorrect uses of logical, arithmetic, or relational operators, incor-
rect invocation of functions, incorrect interfacing to devices, or incorrect handling
of device interrupts?
9. Are there any potential performance bottlenecks, or an inability to fulfill timing
constraints?
Coding standards should include only the most needed items. Barely enough
coding standards are enough to reap the benefits while keeping the effort to a minimum.
Barely enough coding standards should be determined by the stakeholders including
the developers. This is because different domains, organizations, and projects should
have different coding standards. For example, if the developers are familiar with the
application domain, then the coding standards should require less. If the application
is new, or difficult to understand for the developers, then the coding standards should
require more descriptive information to be included in the program file.
GUIDELINE 18.2 The coding standards should be easy to understand and practice.
To reap the benefits of coding standards, developer support is essential. That is,
the developers follow the coding standards when they write programs. This means that
the standards should be easy to understand and practice; otherwise, the developers will
give up sooner or later. Therefore, it is important to involve the developers. Moreover,
the drafts of the coding standards should be reviewed and practiced by the developers,
and modified according to feedback.
GUIDELINE 18.3 The coding standards should be documented and should include
examples.
and optional items. This does not mean that the document should be a lengthy one.
On the contrary, it should focus on what to do and how to do it.
GUIDELINE 18.5 The coding standards, once defined and published, should be
practiced, enforced, and checked for compliance regularly.
If the coding standards are defined but not practiced, then they are useless. There-
fore, it is important to put the standards into practice and check for their compliance
regularly. Since the developers know that there will be a compliance check, they tend
to comply. As time goes by, complying to the standards would become a part of the
culture in the organization.
The software architecture suggests the logical organization of the software artifacts,
that is, grouping of the software artifacts into packages using UML package diagrams.
Chapter 11 presented three approaches to organize the classes:
1. Architectural-style organization. This approach organizes the classes according
to the building blocks of the software architecture. For example, Figure 11.12
shows the correspondence between the N-tier architecture and the packages for
the library information system discussed in Chapter 11.
2. Functional subsystem organization. This approach organizes the classes accord-
ing to the functional subsystems of the software system. Figure 11.11 shows the
correspondence for the library information system.
3. Hybrid organization. This approach combines the architectural-style organi-
zation and the functional subsystem organization. Two approaches exist: the
architectural-style functional subsystem organization and the functional subsys-
tem architectural-style organization. Using the former, the classes in each of the
architectural packages are organized according to the functional subsystems of
the software system. This would organize the classes in the GUI package in Fig-
ure 11.12 into several subpackages of the GUI package, including gui.circulation,
gui.cataloguing, gui.purchasing, gui.usersvc, and gui.interlibraryloan. The func-
tional subsystem architectural-style organization does the opposite.
The package structure is useful for deriving the directory structure used to store
the source files and executable programs. For example, an interactive system typically
has sequence diagrams like the one in Figure 18.4(a), where the Use Case GUI and
Use Case Controller objects represent use case-specific GUI and controller. The GUI
lis
:Use Case : Use Case : Business : DB : Net classes
GUI Controller Object Mgr Mgr src
businessobjects
cataloguing
circulation
purchasing
usersvc
controller
(a) Sequence diagram showing layers of a system
database
ldap
Database oracle
Connec- sqlserver
tivity gui
Business
GUI Controller cataloguing
Objects
Network circulation
purchasing
usersvc
network
util
includes window-based, web-based, and other types of user interfaces. The Business
Object represents one or more business objects that participate in the business pro-
cess of the use case. As discussed in Chapter 17, the DBMgr is a part of a persistence
framework that includes a DB Proxy and DB commands to access a database, which
may locate at a remote site. The Net Mgr is responsible for handling network com-
munication and marshaling. It is a part of a network communication framework. The
layers of an N-tier architecture are in one-to-one correspondence to the layers in the
sequence diagram, as illustrated in Figure 18.4(b). The layers represent subsystems or
components and are implemented as modules or packages. For example, the database
layer includes the DBMgr class, the proxy classes, and the database access command
classes. These classes belong to the database package and are stored in the database
directory as shown in Figure 18.4(c).
The directory structure shown in Figure 18.4(c) is the result of applying the
architectural-style functional subsystem organization. It assumes that the software
system supports multiple database management systems (DBMS). Therefore, the
proxy classes and the database-access command classes are grouped into DBMS-
specific subsystems such as Oracle, SQL Server, and LDAP subsystems. These are
subsystems of the database subsystem. Accordingly, the classes in these subsystems
have DBMS specific package names such as “database.oracle,” “database.sqlserver,”
and “database.ldap.” They are stored in the corresponding subdirectories under the
database directory. The business objects form business-specific subsystems that often
resemble their counterparts in the real world. For example, the business objects of a
library information system can form circulation, cataloguing, purchasing, and user
service subsystems. Therefore, classes belonging to these subsystems are stored in
the circulation, cataloguing, purchasing, and usersvc subdirectories of the business
objects directory. Similarly, the graphical user interface classes are stored in their
respective subsystem’s directories as shown in Figure 18.4(c). Organizing the classes
into different subsystems, packages, and directories facilitates software reuse. For
example, to reuse the database subsystem or one of its DBMS-specific components,
one only needs to include the corresponding directory.
programming concepts nicely. Moreover, many IDEs can generate the classes and in-
terfaces from UML class diagrams. It is therefore, not elaborated further in this book.
simulate A. The class is called a test stub. The use of test stubs has several draw-
backs. It consumes time and effort. If the behavior of A is complex, the construction
of the test stub could be difficult, if not impossible. The test stub is not the class it
simulates. Therefore, testing with stubs has limitations. Retesting is always required
when A is implemented. Therefore, the classes of a DCD should be implemented and
tested according to their dependencies. In general, classes that other classes depend
on should be assigned to team members who can complete the implementation fast.
This allows the team to proceed with the implementation work without needing to
wait for the completion of the other classes.
1. It reduces pressure and brings fun to programming because there is always some-
one with whom to share the stress and joy of success.
2. It enhances team communication because the partners exchange ideas during pair
programming. Moreover, pair-switching helps the team members gain insight into
the components of the system. This improves productivity and quality.
3. It enhances mutual understanding and collaboration because pair programming
lets the team members understand each other and learn from each other in various
ways and aspects.
Chapter 18 Implementation Considerations 463
4. It tends to produce simpler and more efficient solutions faster because discussions
stimulate creative thinking and help in problem solving.
Pair programming has a number of limitations:
1. It is not for everyone—there are programmers who prefer to work alone.
2. If it is not handled properly, the discussion between the partners can take a lot of
time. Therefore, the discussions should focus on solving the problem and getting
the work done.
3. It could be slow to start due to the need to adapt to the differences of the partners
in education, experience, problem-solving approach, and coding style.
4. Other limitations are: (1) the partners have to be at the same location, (2) it may be
difficult for the partners to find a meeting time due to conflicting schedules, and
(3) it might not be as effective as systematic review methods in detecting defects.
A programming practice that is similar to pair programming is ping-pong pro-
gramming. With ping-pong programming, one developer writes the tests and the other
developer implements the functionality. Ping-pong programming goes along very well
with test-driven development, presented in the next section. Ping-pong programming
is an iterative process. First, the basic tests and functionality are implemented. The
boundary or extreme cases are added incrementally until the functionality and tests
are complete.
3. Implement and test the features. In this step, the programmer implements the
features and runs the tests to ensure that the features are correctly implemented.
4. Repeat until all features are correctly implemented. Steps 2 and 3 are repeated
until all the features are implemented and pass all the tests.
5. Accomplish test coverage. In this step, the programmer checks the test coverage,
adds more tests, and modifies existing tests to ensure that the test-coverage ob-
jective is accomplished. The programmer may need to modify the program to
pass the modified tests.
Step 1. Prepare for test-driven development.
Before TDD, the skeleton code for the class to be implemented is produced. It
has all the functions including the get and set functions. Each function has an
empty body, or returns a default value (null for returning an object). The class
skeleton can be generated from the design class diagram (DCD). As a good
software engineering practice, the skeleton code should include a file header that
complies to adopted coding standards. In addition, the test coverage criteria are
determined. Branch coverage is commonly used. It means that all branches of
the class must be tested at least once. For example, if a program contains only
one if-then-else statement, then there are two branches because the condition has
two outcomes. To achieve branch coverage, at least two tests are required. They
must ensure that the program executes each branch correctly.
Step 2. Select features and write tests for the features.
In this step, the programmer selects the features to be implemented next. Of-
ten, features that realize high-priority requirements should be implemented first.
Chapter 18 Implementation Considerations 465
2. TDD constantly validates the implementation with respect to the tests. It helps
the team detect and remove defects. As a result, TDD produces high-quality code.
3. TDD focuses on the desired functionality first but also addresses the other quality
aspects such as program structure and readability through refactoring.
4. TDD facilitates debugging because incremental implementation of the features
makes it easy to locate and fix errors.
GUIDELINE 18.8 Develop small, incremental releases and iterate; focus on fre-
quent delivery of software products.
GUIDELINE 18.9 Complete each feature before moving onto the next.
It is important to complete each feature before moving onto the next because
agile development values working software. Implementing this principle means only
completed features are counted, not partially completed features because the latter
are not working software.
Testing early and often allows the team to detect errors early and correct them
much more easily. Test early and often applies to unit testing, as well as integration
testing and acceptance testing. Modern tools such as IDEs and JUnit make it easy to im-
plement this principle. For example, hundreds of tests can be run easily with such tools
in just a few seconds. Frequent testings greatly improve the quality of the software.
SUMMARY
•
This chapter presents implementation considerations. programming, and ping-pong programming. The
These include coding standards, organization of im- chapter also discusses applying agile principles dur-
plementation artifacts, converting design to programs, ing the implementation phase and tool support to
assigning implementation work to team members, implementation and test-driven development.
and how to conduct test-driven development, pair
FURTHER READING
•
For more information on pair programming, the reader is gramming, and test-driven development, see for exam-
referred to [162]. Pair programming also works for ex- ple, [14, 19, 20, 21, 97]. The agile alliance website at
treme programming, an emerging software development www.agilealliance.org contains many articles on these ag-
paradigm. There are many good books on extreme pro- ile development topics. Many good books on various
468 Part VI Implementation and Quality Assurance
object-oriented programming languages exist in the mar- ware download. The implementation and test order for the
ket. These include [13, 83, 84, 138, 141, 142, 152]. Ap- classes in the DCD was first proposed in [99, 101]. Other
pendix B provides an introduction to Java, Java database algorithms on computing an optimal order are found in
connectivity (JDBC), Swing, and Java server pages (JSPs). [37, 38, 103, 147, 151]. However, the problem of finding an
More detail about these Java technologies are available from optimal order remains an open research problem although
Oracle’s website, which is also a good source for other a good enough algorithm is practically good enough.
useful information such as Java coding standards and soft-
EXERCISES
•
Chapter 16 describes the design of a state diagram editor. Document(cn: String, title: String, author: String,
It produces a number of design diagrams. The following publisher: String, ISBN: String, year: String,
three exercises are related to the design of the editor. Each duration: String)
program file must include the file header and description of Loan(patron: Patron, document: Document, date:
classes using the format in Figures 18.2 and 18.3. String, dueDate: String), the date has the format
18.1 Produce a directory structure for the state diagram as “MM/DD/YYYY.”
editor and assign the editor-related classes presented Patron(id: String, name: String, address: String,
in Chapter 16 to the directories and subdirectories. tel: String)
18.2 Implement the classes in Figure 16.6 using test- 18.5 Implement the design of the business rules class di-
driven development. Use JUnit to write and run the agram you produced in exercise 15.7.
test cases, and Cobertura to ensure that 100% branch 18.6 Implement the design of the lawn mowing agent you
coverage is accomplished. produced in exercise 13.6.
18.3 Implement the classes in Figure 16.26 using test- 18.7 Implement the graphical user interface for the state
driven development and pair programming. Form the diagram editor presented in Chapter 16.
pair yourselves or according to the instructions given
18.8 Design and implement a web page or two that allows
by the instructor. Use JUnit to write and run the test
the user to search for documents in a library informa-
cases, and Cobertura to ensure that 100% branch cov-
tion system. Do this exercise based on the persistence
erage is accomplished.
framework you produced in the above exercise. Use
18.4 Implement the persistence framework presented in JSP or a technology as instructed by your instructor.
Chapter 17. Assume that the application is a li- An introduction to JSP is given in Appendix B. Hint:
brary information system and the database is a local You need to design and implement a search use case
database. Do this exercise using test-driven develop- controller that interacts with the DBMgr. You also
ment, pair programming, and JDBC, or as instructed need to extend the persistence framework to provide
by the instructor. In addition, assume that the classes the search capability.
in Figure 11.10 have the following attributes:
19
Software Quality Assurance
The analysis, design, and implementation activities begin with a problem statement
and lead to the production of an executable software system. The software process
used to produce the software system, and how the process is carried out affect the
quality of the software system. Therefore, it is important to pay attention to the
process quality. Moreover, during this process, many software artifacts are produced.
The quality of these software artifacts affects the quality of the software system.
Therefore, it is important to ensure that these software artifacts are correct and satisfy
other quality criteria, such as easy to understand and complete. These mean that
parallel to the development activities, there must be quality assurance activities to
set the quality standards, perform the quality assurance activities, and check that the
quality standards are met. These activities are collectively referred to as the software
quality assurance (SQA) activities and the focus of this chapter. After you have read
this chapter, you will understand the following:
• Benefits of software quality assurance.
• Software quality attributes, metrics, and indicators.
• Software validation and verification techniques.
• Software validation and verification in the life cycle.
• Software quality assurance functions.
469
470 Part VI Implementation and Quality Assurance
therapy machine to deliver approximately 100 times the intended dose of radiation to
patients from 1985 to 1987. Two of the patients died later from the accidents. Another
software bug–related accident took place on June 4, 1996—an Ariane 5 rocket was
destroyed 37 seconds after launching, due to an error in the 64–bit floating-point to
16–bit signed integer conversion code used by the flight computer, resulting in a loss
of more than US$370 million [59]. Although it is practically impossible to avoid all
software-related accidents, effective SQA effort could prevent some of the accidents.
Reliability. The ability of the software to perform its required functions under
stated conditions and produce correct and consistent results.
Robustness. The ability of the software to perform its required functions under
rough or exceptional conditions.
Efficiency. The ability of the software to perform its functions and produce
desired results with minimum expenditure of time and resources.
Chapter 19 Software Quality Assurance 471
(a) ISO 9126 quality model (b) IEEE Standard 1061 quality model
For example, there are at least three objective and quantitative ways to measure
the size of a module. One could measure the size of a module by the number of
bytes of the module. Another measurement may count the number of lines of the
source code. The third approach measures the size by the number of statements in
the source code. Clearly, different measurement methods produce different results.
Despite their differences, each of these approaches represents a way to measure the
size of a module. With these measurements, it is possible to compare the sizes of two
modules. For example, if the sizes of modules M1 and M2 are s1 and s2, then M1
is larger if s1 > s2, provided that they are measured by using the same approach.
A potential problem is comparing s1 and s2 without knowing that the sizes of M1
and M2 are measured by different approaches. This could happen if s1 and s2 are
just two integer numbers provided by two different parties. The same problem exists
for other attributes. For example, there are at least two complexity measurements.
One is the cyclomatic complexity proposed by McCabe, which computes the number
of independent paths in a program. The other is the computational complexity or
the big oh notation, which is a theoretical measure of the amount of time required
to execute an algorithm. Therefore, it is necessary to standardize the measurements.
This leads to:
The difference between metrics and measurements is that metrics are adopted
as standard measurements. However, many software engineering publications do not
distinguish metrics and measurements. This is because there is no officially declared
“standard measurements.” The metrics in use today become standard measurements
because many authors refer to them as metrics. The literature has published numerous
software metrics, which measure a wide variety of software attributes. For example,
there are process metrics, project metrics, and product metrics. These are further
decomposed into subcategories. That is, product metrics include quality metrics and
other types of metric such as size metric. The quality metrics include the conventional
Chapter 19 Software Quality Assurance 473
quality metrics and object-oriented quality metrics. Some of the conventional metrics
are applicable to object-oriented software. The object-oriented metrics are meaningful
for object-oriented software only. It is the intention of this textbook to focus on a small
number of the most discussed quality metrics. This is because even the quality metrics
alone deserve a book of their own.
One advantage of software measurements and metrics is the ability to assess
software in levels. For example, a module or class is considered big if it has more
than a thousand lines of code. A big module or class is difficult to comprehend, test,
and maintain. In this case, a thousand lines of code is an indicator of a big module.
This leads to the following:
investigation is desirable to find out why. This applies to systems and other
metrics.
4. Quantitative assessment of improvement. After training or using a methodology,
the organization may want to find out the extent of improvement. Measurements
and metrics play an important role in such assessments.
5. Quantitative assessment of technology. Are agile processes better than plan-
driven approaches? How do agile methods compare with each other? Which
of the UML-based tools should be used? Answers to these questions could be
determined by experiments to quantitatively assess the technologies.
6. Quantitative assessment of process improvement. Many organizations adopt the
capability maturity model integration (CMMI) or ISO 9001 to improve their
software processes. Quantitative measurements are required by these models.
Measurements and metrics allow the organization to define process improvement
goals and measure the progress toward the goals.
The usefulness of the measurements, metrics, and indicators might not be obvious
if one considers these without putting them in perspective. For any project of a certain
size, the number of software artifacts produced is large. For example, many projects
have hundreds of classes. It is impossible for the team members to examine the classes
to find out which one is big, or complex. A tool, however, can quickly compute the
metrics and highlight the warning spots. The team can examine these classes and take
appropriate measures. This greatly saves time and effort.
Requirements Metrics
The requirements unambiguity metric is based on the observation that a software
requirements specification (SRS) is unambiguous if and only if each requirement
stated in the SRS has only one interpretation. It is measured by the percentage of
the requirements that are interpreted in a unique manner by all the reviewers. The
requirements completeness metric is based on the assumption that the states of the
system and the stimuli to the system as specified in the SRS are complete. That is,
the SRS has included all possible states of, and all possible stimuli to, the system.
To derive the metric, the system is viewed as a state transition machine, which maps
each pair of a state and a stimulus to a state and produces a response:
f (state, stimulus) → (state, response)
The SRS is considered complete if the f function is complete. If the SRS specifies
n s states and n i stimuli, then the total number of possible mappings is n s ×n i . Thus, by
counting the number of unique functions (n u ) specified in the SRS, the completeness
of the SRS can be measured. That is, if n u = n s × n i then there is a function for each
Chapter 19 Software Quality Assurance 475
possible state and stimulus combination. In this case, the SRS is 100% complete. The
requirements correctness metric is based on the observation that one would not know
if a requirement is correct. One could only validate the correctness of a requirement or
could not validate it yet. Therefore, the formula uses the number of not-yet-validated
requirements (n nv ) in the denominator. The requirements consistency metric counts
the number of requirements that are conflicting with each other. For example, if the
SRS has 100 requirements r1, r2, . . . , r100 and ri and rj, 1 <= i, j <= 100, are
conflicting, that is, they cannot be satisfied at the same time, then the consistency
is (100 − 2)/100 = 98%. If none of the requirements are conflicting, then SRS is
100% consistent. An example of inconsistent requirements is that one requirement
says “users shall be able to set the session logout time” while another requirement
says “the webmaster shall set the session logout time for all users.”
Design Metrics
The eight design metrics in Figure 19.2 are defined with a structure chart such as the
one in Figure 19.3. In the structure chart, M0 − M7 are modules, the arrows represent
Chapter 19 Software Quality Assurance 477
S0 = 11
M0
mdc = 2
Legend:
Rectangle: a module
S0 = 3 S0 = 3 S0 = 3
M1 M2 M3 Arrow: a call to a module
mdc = 1 mdc = 2 mdc = 2
Diamond: a decision to call a module
M4 M5 M6 M7
S0 = 1 S0 = 1 S0 = 1 S0 = 1
module invocations, and the diamonds represent conditional calls. The module design
complexity mdc(M) is calculated by:
mdc( M) = d + 1
where d is the number of diamonds that M has, and each diamond is a binary decision.
The mdc is d plus one because a binary decision adds one integration test. This is
explained as follows. Suppose M calls A and B. If there is no diamond, then one
integration test is adequate to integrate M with A and B—that is, M calls A then
calls B. Now suppose that a conditional call is added to M. Then there are three
cases:
1. M calls A, then optionally calls B. This requires two tests. One tests M calls A
then calls B, and the other tests M calls A and does not call B.
2. M calls either A or B conditionally. That is, if the condition is evaluated to true,
then M calls A but not B. If the condition is evaluated to false, then M calls B
but not A. Two tests are needed. One integrates M and A, and the other integrates
M and B.
3. M calls A optionally and then calls B. This is similar to the first case.
Thus, each diamond or binary decision to call adds one. Therefore, mdc = d + 1.
If the decision to call is not an atomic binary decision but an N -ary decision, then
replace it with N − 1 binary decisions. In this case, the mcd = N − 1 + 1 = N . An
atomic decision is one that does not contain AND or OR connectives.
The design complexity S0 is computed by:
•
EXAMPLE 19.1 Compute the design complexity for the structure chart in Figure 19.3.
Solution: The design complexity S0 of the modules are computed as follows:
S0( M4) = S0( M5) = S0( M6) = S0( M7) = 1
because they are leaf nodes.
S0( M1) = S0( M4) + S0( M5) + mdc( M1) = 1 + 1 + 1 = 3
because M1 does not have decisions so mdc( M1) = 1.
S0( M2) = S0( M6) + mdc( M2) = 1 + 2 = 3
because M5 has been used and not distinct, and M2 has one decision so
mdc( M2) = 2.
S0( M3) = S0( M7) + mdc( M3) = 1 + 2 = 3
because M3 has one decision so mdc( M3) = 2.
S0( M0) = S0( M1) + S0( M2) + S0( M3) + mdc( M0) = 3 + 3 + 3 + 2 = 11
•
A simpler formula to use is:
S0( M) = Ndm + Nabd
where Ndm = number of distinct modules, that is, each is counted only once, and
Nabd = number of atomic binary decisions to call a subordinate module. Using this
formula, the design complexity of M0 in Figure 19.3 is:
S0( M0) = 8 + 3 = 11
because the chart has 8 modules and 3 binary decisions.
The integration complexity metric computes the minimal number of integration
tests required to integrate the modules. The formula to use is:
S1( M) = S0( M) − n + 1
where n is the number of modules in the structure chart.
•
EXAMPLE 19.2 Compute the integration complexity for the design in Figure 19.3.
Solution: The integration complexity is:
S1( M0) = S0( M0) − Ndm + 1 = 11 − 8 + 1 = 4
That is, at least four tests are required. These test the following four subtrees
created by the conditional calls:
11- M0M1M4M5M2M5
10- M0M1M4M5M2M6
0-0 M0M1M4M5M3
0-1 M0M1M4M5M3M7
∨
Chapter 19 Software Quality Assurance 479
where 11- means the decisions in M0 and M2 are true and the decision in M3 is
∨ immaterial. 10- means the decision in M0 is true, in M2 is false, and in M3 is
immaterial.
•
•
Suppose that MTTR = 0. That is, it requires no time to fix any failure; of course, EXAMPLE 19.3
this is practically impossible, but this assumption makes it easy to understand the
formula. Suppose that during a 300-day period 10 failures occur to system A and
20 failures occur to system B. These result in
MTBF(A) = 300 days/10 = 30 days
MTBF(B) = 300 days/20 = 15 days
Since MTBF(A) > MTBF(B), A has a higher reliability than B. Now consider the
case that it takes time to repair a failure. However, regardless of how long it takes
to repair a failure, the time must be taken from the 30-day time for system A
and the 15-day time for system B. That is, the MTTF is revised to MTTF(S) =
MTBF(S) − MTTR(S). If it takes one day to repair each failure for system A, then
the revised MTTF for A is MTTF(A) = MTBF(A) − 1 = 30 − 1 = 29. This does
∨ not affect the MTBF.
480 Part VI Implementation and Quality Assurance
Now the repair time is important because the longer the repair time, the shorter
the MTTF. Moreover, the ratio of MTTF to MTTF + MTTR is smaller.
•
•
EXAMPLE 19.4 Compute the availability for system A for two cases, one assumes one day and the
other three days to repair a failure, respectively.
Solution: The availability metric for one day to repair a failure is:
MTTF(A) = 30 − 3 = 27
availability = MTTF/(MTTF + MTTR) = 27/30 = 90.00%
That is, the longer it takes to fix the problems, the lower the availability of the
system. This shows the importance to make the system easy to maintain.
•
Weighted Methods per Class (WMC). The WMC for a class C is the sum of the com-
plexity metrics of the methods of a class. It is computed as
•
Consider, for example, a Stack class implemented with a fix size array and six EXAMPLE 19.5
methods: push(int x), pop(), top(), isEmpty(), isFull(), and Stack() as its methods.
The push(int x) and pop() methods need to check if the stack is empty and full,
respectively. Each of these has cyclomatic complexity of 2. The other methods
have complexity 1. Thus, the cyclomatic complexity of the Stack class is 8.
The time and effort required to test and maintain a class increases with the
WMC of the class. This is because there are more independent paths in its methods.
It is likely that the conditional statements are introduced to test application-specific
conditions. This means that it could be more difficult to use the class in other
projects.
•
Depth of Inheritance Tree (DIT). The DIT for a class C is the longest inheritance
path from a root to the class. Note that there could be more than one root. DIT is
computed as:
•
Figure 19.4 shows the class diagram of a software component. The DITs for some EXAMPLE 19.6
of the classes are:
The ancestors of a class may reimplement some of the methods that the class
∨ uses; in such cases, the behavior of the class is affected and difficult to predict.
482 Part VI Implementation and Quality Assurance
∨
EditCmd GraphElem
Edge Path
FIGURE 19.4 Class diagram for some classes of a state diagram editor
Therefore, the greater the DIT the more likely the class will inherit and use such
methods. The behavior of the class could be more difficult to predict.
•
Number of Children (NOC). The NOC of a class C is the number of immediate children
of C in an inheritance hierarchy:
•
EXAMPLE 19.7 The NOCs for some of the classes in Figure 19.4 are:
NOC = 0: Empty, InitNode, Even, TestModel, etc. because these are the leaf nodes.
NOC = 2: EditCmd
NOC = 3: GraphElem
NOC = 4: Edge
NOC = 5: Node
•
Generally speaking, the greater the NOC the greater the likelihood of reusing
features of C. If C is changed, then its children are affected. Since the children may
use the inherited features, their behavior is affected by the behavior of the class and
changes to the class.
Chapter 19 Software Quality Assurance 483
Coupling Between Object Classes (CBO). The CBO of a class C is the number of classes
it depends on:
CBO(C) = |{C’: C depends on C’}|
where the depends-on relationships include inheritance and aggregation relationships
such as a subclass depends on its parent class, and an aggregate class depends on its
component classes. Moreover, a class may call or use other classes, creating depen-
dencies on the other classes.
•
The CBO for some of the classes in Figure 19.4 are: EXAMPLE 19.8
CBO = 0: EditCmd and GraphElem because they do not depend on other classes.
CBO = 1: The children of Edge and the children of Node.
CBO = 2: Edge because it depends on EditCmd and GraphElem.
CBO = 3: TestModel, which depends on Node, Edge and EditCmd, Node, which
depends on EditCmd, Edge and GraphElem, and Path, which depends
on Edge, Node and GraphElem.
•
The more classes that C depends on, the more difficult to test C. If the classes
that C depends are not implemented or tested, then test stubs must be implemented to
simulate their behavior. Since C depends on these classes, to understand C requires
understanding of these classes. For example, to understand TestModel, one must
understand EditCmd, Edge, and Node. To test TestModel, one needs to construct test
stubs for EditCmd, Edge, and Node if they are not implemented and tested. Therefore,
the greater the CBO the more difficult to understand, test, maintain, and reuse the class.
Response for a Class (RFC). The RFC is the number of methods of a class plus the
number of methods called by a method of the class:
RFC(C) = |{m: m is a method of C or m is called by a method of C}|
The larger the RFC the more difficult to test and debug the class due to more
complex interaction relationships and more effort required to understand the methods
and prepare test cases and test stubs.
Lack of Cohesion in Methods (LCOM). The LCOM for a class C is the number of pairs
of methods of C that do not share an attribute of C. Let n be the number of methods
of C. The LCOM of C is computed as follows:
LCOM(C) = n ∗ (n − 1)/2 − 2 ∗ |{(mi,mj) : mi and mj share an attribute of C}|
product right?” and “Are we building the right product?” That is, verification ensures
that the process is carried out correctly, and validation ensures that the correct product
is built. Validation is further divided into static validation and dynamic validation.
Static approaches check the correctness of the product without executing the product
while dynamic validation executes the product or a prototype. Software testing is a
dynamic validation method that executes the system or its components. Software test-
ing and static approaches are complementary. Each of them plays an important role
in SQA. Inspection, walkthrough, and peer review are widely used static verification
and validation techniques. These techniques are performed manually without execut-
ing the software. Therefore, they are referred to as static verification and validation
techniques.
Software verification and validation are important because software is used in
all sectors of our society. Today’s software systems are extremely large and complex
and process billions of transactions a day in the financial, retailing, manufacturing,
transportation, telecommunications fields and many other sectors. Many software
systems are embedded systems, real-time systems, or mission-critical systems. Fail-
ures of these software systems are financially very costly and politically unacceptable
because the failures may incur recall of products, property damages, injury to human
body, or even loss of human life. Therefore, the importance of software verification,
validation, and testing cannot be overstated.
19.4.1 Inspection
Inspection checks the product against a list of common errors, anomalies, and non-
compliances to standards and conventions. It is similar to car inspection that is required
in many countries. Car inspection checks the car against an inspection list of prob-
lems in a number of components. Each item is “mechanically” inspected to make
sure that it works well. For example, turn on the headlight switch and check that the
headlights are on. Similarly, code inspection aims at detecting commonly encountered
programming errors such as:
• Use of uninitialized variables, objects, references, or pointers.
• Calling the wrong polymorphic function.
• Incorrect function invocation, for example, incorrect parameters are passed to
the function, or the parameters are misplaced.
• Nonterminating loops or incorrect loop termination conditions.
• Mismatch in array dimensions, causing an array index out-of-bounds exception.
• Uncaught/unhandled runtime exceptions.
• Problems in the use of pointers, for example, memory is allocated but not released,
leading to memory leak.
• Data flow anomalies, for example, objects are created but not used.
• Omitted reimplementation of a feature of the parent class, resulting in the invo-
cation of the default implementation of the parent class.
• Incorrect, inconsistent, or incomplete business logic, for example:
1. incorrect business logic: An if-condition is stated incorrectly.
Chapter 19 Software Quality Assurance 485
2. inconsistent business logic: The same condition should produce the same
result but it does not, for example, an applicant with GPA = 3.0 is admitted
at one place and rejected at another place.
3. incomplete business logic: An if-condition without an else part when there
should be one.
• Incorrect reference to data structures or data elements such as using the wrong
data elements in computation.
• Errors in arithmetic, relational, or logical expressions such as mistyping “+” for
“−”, “>=” for “>”, and “&&” for “||”.
• Incorrect I/O statements such as reading the wrong file, or processing the file
format incorrectly.
• Incorrect invocation of library functions.
• Incorrect use of call by value and call by reference.
Applicability. All software artifacts, including requirements specification, domain
model, use case specification, various design diagrams, program source code, static
and dynamic pages, user interface design, test plan, and test cases.
Effectiveness. Effective in detecting common errors, anomalies, and noncompliance
to standards and conventions.
Participants. One to three technical staff members.
Procedure. Similar to peer review (see Section 19.4.3).
Duration. Inspection meeting is usually not needed.
19.4.2 Walkthrough
Walkthrough manually executes the product using simple test data. Usually, the de-
veloper who produces the product leads the team to perform the walkthrough. The
team checks the product step by step while reading aloud. It is designed to stimulate
doubt and discussions. Walkthrough is similar to buying a car at the dealership. The
sales rep shows and explains the features of a car to the buyer while the buyer asks
questions to clear doubt and stimulate discussion.
Applicability. Expanded use case specification, various design diagrams, program
source code, dynamic pages, user interface design, test cases.
Effectiveness. Useful to gain understanding or insight of complex functionality and
behavior, especially products that involve complex algorithms, new algorithms, re-
cursion, multithreading, real-time behavior, or concurrent update to shared resources.
Participants. Three to five technical staff members including the developer.
Procedure.
1. A product overview is presented to the participants if desired.
2. The developer loudly reads through the product and provides necessary expla-
nations. The other team members ask questions and raise doubts. The developer
486 Part VI Implementation and Quality Assurance
answers the questions and provides justification. Action items are identified and
recorded. A deadline for the developer to fix the problems is set.
3. The developer fixes the problems, produces a summary list, and obtains approval
from the participants.
Effectiveness. Peer reviews are effective in detecting problems that require human
judgment concerning the correctness, efficiency, user-friendliness, and other software
quality attributes.
Procedure.
1. A product overview is presented to the reviewers if desired. Each workable unit
of product is assigned to a couple of reviewers to review. Each unit should require
no more than one half of a day to evaluate. A review meeting is scheduled to take
place one to two weeks later.
2. Guided by a review checklist, the reviewers evaluate the product and answer the
review questions independently.
3. At the review meeting, the reviewers present their comments and suggestions
and the developer answers questions and clarifies doubt. The participants also
discuss ways to improve the product. Action items are identified and recorded.
Most of the action items require the developer to fix the problems identified by
the reviewers. However, in some cases, other developers may need to change
their components to coordinate with the program under review. A deadline for
completing the action items is set.
4. The developer fixes the problems and produces a list of responses that summarizes
the solution of each problem. The reviewers may accept the changes or request
additional improvements.
5. In some cases, a second review meeting is required. In these cases, the above
steps are repeated.
GUIDELINE 19.1 If the product requires a lot of effort to review, assign different
parts of the product to different reviewers. Avoid having all reviewers review all
parts of the product.
GUIDELINE 19.2 The aspect of the product reviewed by a reviewer should match
the reviewer’s experience and expertise. New graduates should not serve as re-
viewers, though they can be observers.
GUIDELINE 19.3 Avoid giving the reviewers too much to review in too little time.
GUIDELINE 19.5 Ensure that the reviewers understand the product goals, con-
straints, and assumptions.
GUIDELINE 19.6 The reviewers are required to identify merits and strengths of
the product and provide improvement suggestions, not just point out defects.
GUIDELINE 19.7 Avoid review sessions with many participants or longer than
two hours.
GUIDELINE 19.8 The developer should inform the reviewers of any places of the
product where feedback is sought because the developer is uncertain whether the
solution is correct, appropriate, or adequate.
domain model and use case diagrams. The techniques used include requirements re-
view, inspection, walkthrough, and prototyping. There are three types of requirements
review: technical review, customer review, and expert review. These review activities
are aimed at detecting different types of problems in the requirements specification.
Technical review is an internal review, performed by technical staff such as the de-
velopers. It may combine inspection and peer review and check the requirements,
constraints, use cases and domain model for completeness, consistency, unambiguity,
traceability, and feasibility:
• Completeness. The completeness checks ensure that important application and
domain-specific concepts are defined, the customer’s business needs are ad-
dressed, important business cases, events and states are included, and the speci-
fication of the business rules is complete.
• Consistency. The consistency checks ensure that the application and domain
concepts are defined and used consistently, and the specification of the business
rules is consistent.
• Unambiguity. The unambiguity checks ensure that the application and domain
concepts and business rules are described clearly and accurately.
• Traceability. The traceability checks ensure that the lower-level requirements
correspond to the higher level requirements, and the requirements–use case trace-
ability matrix correctly describes the correspondence.
• Feasibility. The feasibility checks ensure that the team can deliver the system
that satisfies the requirements and constraints under the budget and schedule
constraints. Prototyping is often used in feasibility study to clear uncertainties.
checklists at the end of Chapters 5 and 7 are useful for checking the domain model
and use cases in the requirements phase.
Software
Development Conventional Process SQA Activities Agile Process QA Techniques
Activities
1. Requirements specification reviews 1. User stories, use case driven development,
2. Evaluating requirements related metrics feature-driven development, system metaphor
Software and indicators (XP)
requirements 3. Prototyping 2. Active user involvement, early customer feedback
analysis 4. Model validation 3. Iterative and small increments
5. Planning for software acceptance testing 4. Feasibility study and prototyping (DSDM)
5. Release planning (XP)
1. Software design review, inspection and 6. Design for change
walkthrough 7. Brainstorming
2. Evaluating design related metrics and 8. Teamwork—value individuals and interaction,
Software design indicators team decision making, frequent exchange
3. Use case based validation
4. Model checking
5. Planning for software integration testing
1. Code review, inspection and walkthrough 1. Test-driven development
2. Static analysis checking 2. Refactoring
Software 3. Evaluating code based metrics and 3. Pair programming (as on-the-fly code review)
implementation indicators 4. Ping-pong programming
4. Coding standards 5. Stand-up meetings
6. Coding standards (XP)
phase of the process should produce, and quality assurance standards and procedures
to ensure the quality of the artifacts.
Sometimes, a specific project may require the use of a process or methodology
that is not in the framework. This may be due to various reasons including techni-
cal reasons and political reasons. For example, the type of software to be developed
requires a certain process or methodology. The customer demands the use of a cer-
tain process or methodology. Therefore, flexibility should be provided for the project
to select a process or methodology. In this case, the standards should specify the
requirements that the project-selected process or methodology should satisfy. For
example, the standards may require that the development process selected must in-
clude configuration management or version control, formal reviews, and test-driven
development.
The product standards define the requirements on the software artifacts produced
during the life cycle. These include requirements on the structure, representation,
format, checklists, and verification and validation activities. For example, the coding
standards presented in Chapter 18 define the structure and format for all program
files and the in-code documentation requirements. The review checklists and the
verification and validation techniques presented earlier provide the basis for defining
the requirements on the software artifacts.
The SQA standards are derived from the organization’s software engineering
goals including long-term and short-term goals and quality goals. Moreover, the or-
ganizational SQA standards should be defined based on one of the quality models
such as the ISO 9001 or IEEE quality models. Software quality interplays with soft-
ware productivity, cost, and time to market. Poor software quality incurs a lot of
rework and bug fixing; and hence, it reduces productivity and increases cost and time
to market. On the other hand, quality requires time and effort, but in the long run
it increases productivity and reduces cost and time to market. Studies show that the
delivered defects per thousand lines of code for CMMI level 1 to level 5 are 7.5,
6.24, 4.73, 2.28, and 1.05, respectively. That is, the improvement from CMMI level
1 to level 5 is 614%. Assume that the average cost to fix a field detect defect is
$30,000. The savings are $193,500 per thousand lines of code. If the software system
has 1 million lines of code, then the total savings are $193.50 million. Experience
shows that it takes an average of two years to advance from one CMMI level to the
next level. This means that a level-1 organization would take eight years to move
from level 1 to level 5. If it invests $5 million per year in SQA to reach that goal,
then the total costs are $40 million. Compared with the savings, the investment is
worthwhile.
The SQA component also defines the procedures, policies, and guidelines for
carrying out the SQA activities. For example, software verification and validation
procedures and software configuration management procedures must be defined and
clearly documented. The SQA component must also specify the policies and guide-
lines for applying the procedures. The policies answer questions such as “Who is
responsible for selecting the reviewers to review a program?” or “How many review-
ers are required to review a program?” Finally, the SQA component should develop
and document a process improvement process for the organization.
494 Part VI Implementation and Quality Assurance
Quality Planning
Quality planning is performed at the beginning of each software project. Guided by the
quality framework, this task produces a quality plan for, and according to the needs of,
the software project. In most cases, the quality plan must comply with the standards
defined in the organizationwide quality framework. The quality planning task defines
the quality goals for the project and artifacts including the software system, identifies
the applicable processes, methodologies, standards, procedures, and metrics to be
used by the project, and produces a quality plan for the project. The plan should
include at least the following sections:
1. Purpose. It specifies the purpose and scope of the plan as well as the product or
system and its use.
2. Management. It specifies the project organization and team structure (see Chap-
ter 23), including the team members, their roles and responsibilities. Most im-
portantly, who will be responsible for the SQA functions and activities, and what
are the roles and responsibilities of these team members.
Chapter 19 Software Quality Assurance 495
SQA Control
This SQA function ensures that the SQA plan is carried out correctly. SQA training
could be one of the important activities of this function. The training is aimed to
educate the developers of the importance of SQA, the organization’s SQA standards
and procedures, the available SQA tools as well as how to use the tools to perform SQA
activities. Another responsibility of the SQA component is assisting the developers in
performing the SQA activities. For example, in addition to training the walkthrough,
inspection, and review techniques, the SQA component can help in the development
of the inspection and review checklists.
This SQA function also collects SQA-related data and manages these data using
an SQA database. Many different categories of SQA data need to be gathered, pro-
cessed, and analyzed. At the minimum, information about field-detect defects must
be collected and entered into the database for root cause analysis. It is intended to
identify the software development activity that causes a software defect or problem.
Root cause analysis helps the software development organization identify weaknesses
in the software development life cycle. The result enables the organization to focus
the improvement effort in those areas that improvement is most needed. The SQA
component provides such process improvement recommendations to the manage-
ment, and ensures that the accepted recommendations are properly implemented and
incorporated into the process.
SQA encompasses many activities, components, and concepts. Figure 19.6 sum-
marizes all these in an SQA domain model. For simplicity, the diagram does not show
the attributes and methods. Explanation of the domain model is omitted because this
section has described each of the classes and their relationships.
Derived from
the process but all aspects of the development process. In other words, it means im-
proving everything. Although agile development values individual and interaction
over processes and tools, this does not mean that agile processes do not need process
improvement. As a matter of fact, agile methods are improving from one version to
another. Practices of agile methods in organizations are improving as well. That is, or-
ganizations are discovering better ways to adopt agile methods into their development
environments.
The main focus of this function of the SQA component is the definition and exe-
cution of a process improvement process (PIP). The process should run continuously
and iterate regularly, such as, every year or every two years. It should include at least
the following activities:
1. Defining metrics and data collection methods. This phase defines the process as-
pects to be improved, the metrics to measure, the indicators to assess the improve-
ment, and the data-collection mechanisms needed for computing the metrics. It
should also specify: who, what, where, when, and how. That is, who should col-
lect which pieces, where the data should be collected, when the data should be
collected, and how to collect the data. For example, the reviewers should collect
the lines of code and defects detected. The data should be entered into the SQA
database.
Different organizations have different priorities. Therefore, the aspects of
the process to improve are different. Moreover, the mechanisms used to collect
the data are organization and project dependent. All these need to be defined
according to the organization’s business objectives and environment. In addition,
Chapter 19 Software Quality Assurance 497
SQA is good, but it is not the more the better. The organizational SQA framework
should take into account the business goals and needs of the organization. For example,
a CMMI level 1 organization would not be able to satisfy CMMI level 5 standards. If
the organization’s goal is to move to level 2, then the framework should specify level
2 standards and require all projects to comply.
Good enough is enough also means that the framework should not include every-
thing. It should include only the items that are needed and contribute to the organi-
zation’s business and quality goals. Moreover, SQA costs time and effort and affects
productivity. Therefore, it is important to achieve the quality goals with the minimal
effort. This means focusing on the quality aspects that have the biggest impact on
quality and require the minimal amount of effort.
Requiring software projects to comply to the quality standards is not an easy task.
Collaboration of the project managers and developers is the key. This requires that
the framework and the practices should be easy to understand and easy to comply. So
keeping things simple and easy to do is important.
498 Part VI Implementation and Quality Assurance
The development of the quality framework, quality planning, and quality control
are not the sole responsibilities of the SQA component. Quality is everybody’s busi-
ness. Therefore, it is important to involve all stakeholders that are affected in all of
the SQA activities. That is, seeking input from the stakeholders, keeping the stake-
holders informed, and soliciting feedback from the stakeholders. In particular, the
SQA activities need support from the development teams. This means empowering
the teams to make SQA decisions is the key to success.
SUMMARY
•
This chapter presents software quality attributes, soft- sible for the SQA functions, which include defini-
ware quality metrics, and static verification and val- tion of processes and standards, quality management,
idation techniques such as peer review, inspection, and software process improvement. This chapter de-
and walkthrough. It also presents verification and val- scribes these functions and summarizes them in an
idation in the life cycle. The SQA components of SQA domain model. At the end of the chapter, how
many software development organizations are respon- to apply agile principles to SQA is discussed.
Chapter 19 Software Quality Assurance 499
FURTHER READING
•
The general software quality metrics are found in [27, 56, defects are found in [55, 106]. Basili et al. present a valida-
109]. The object-oriented software metrics are presented in tion of object-oriented design metrics as a quality indicator
[45]. Two recent papers on a comparison of quality pre- [17]. The metrics studied include the object-oriented met-
diction models and the impact of design flaws on software rics presented in this chapter.
EXERCISES
•
19.1 What is the cyclomatic complexity of the flowchart results are identical. If not, explain why they are not
in Figure 18.5? Apply the three approaches to com- identical.
pute the cyclomatic complexity, that is, counting the 19.2 Test-driven development (TDD) requires “write tests
number of regions plus one, counting the number first, then write code.” This is not always easy be-
of atomic binary decision plus one, and counting cause the function of a class may be too complex
the number of nodes and edges. Check that these and difficult to decompose. However, test cases can
500 Part VI Implementation and Quality Assurance
be generated from a flowchart rather than a flow determine the number of atomic binary decisions of
graph. A flowchart is a detailed design produced be- a method, or sketch a flowchart to describe the de-
fore coding. A flow graph represents an implemen- tailed design for the method. For methods that call
tation, which is not available before coding. This ex- other methods of other classes, check the sequence
ercise requires you to produce the test cases from diagram to find out.
the flowchart in Figure 18.5. Check that the correct 19.5 Practice peer review, inspection, and walkthrough on
number of test cases are generated. a number of sample requirements specifications, de-
19.3 Compute the conventional design metrics shown in sign specifications including diagrams, and source
Figure 19.2 for the design class diagram in Fig- code. For the review and inspection, try to use the
ure 11.10. Hint: Section 19.3.3 describes how this checklists presented in the previous chapters.
can be done. For conditional calls, check the design 19.6 Exercise 4.2 produces the software requirements
sequence diagram, where conditional calls may be specification (SRS) for each of a telephone answer-
indicated. ing system, a vending machine, and a web-based
19.4 For the design class diagram in Figure 11.10, only email system. Perform the three types of re-
compute the object-oriented quality metrics pre- quirements review to these SRSs using the review
sented in Section 19.3.4. Hint: Since the metrics checklists presented in Section 4.5.6. Write a review
are computed before coding; therefore, implemen- report for each of the SRSs.
tation data are not available. Use your best guess to
20
Software Testing
During the software development process, static checking such as inspection and code
review are performed. These are useful for detecting certain types of error. However,
static checking does not run the program; and hence, they cannot detect other types
of errors that require execution of the program. This is similar to test driving a car in
addition to just visually checking it. A casual buyer would test drive the car with rather
arbitrary driving scenarios. A cautious buyer would prepare test cases to assess the
different aspects of the car, for example, acceleration, high-speed driving, and brake
effectiveness. These test cases are intended to establish a certain degree of confidence
in the car—that is, that the car would perform to the expectation of the buyer. Software
testing is similar and aims to check the correctness of the software and detect errors.
It is complementary to static checks. Unlike casual testing as performed by some
programmers, software testing aims to apply well-established testing methods and
techniques to validate the software and detect errors. The following story may motivate
the study of this topic.
Many years ago, I worked in a software company where I met a young, talented
software engineer. Due to common interest, we quickly became good friends. We
visited each other’s office everyday, sometimes just to say hello. One day, he came to
tell me that he would leave for a vacation because he finished testing his component.
I was curious about how he tested his software. “Oh, that’s easy,” my friend said,
“I tested to show that it works.” I asked if he had used any test methods. He said
that he did not. The answer did not surprise me because even today many computer
science programs do not offer a course on software testing. Many software engineers
perform unit tests like my friend. I suggested that he apply some of the test meth-
ods described in this chapter. Two weeks later, my friend showed up in my office.
His face was pale and his hands were shaking. I asked what happened. “It was very
scary,” my friend said. “I found hundreds of bugs with the test methods you told me
501
502 Part VI Implementation and Quality Assurance
about the other day. If I had left for vacation, I would have been in big trouble if
the bugs were detected during integration testing.” This story illustrates how impor-
tant it is to perform testing using an effective test method. In this chapter, several
effective test methods are described. In particular, you will learn the following in
this chapter:
This definition indicates that testing serves two purposes. First, it aims to demon-
strate that the software satisfies its requirements. These include functional as well as
nonfunctional requirements. Second, testing is aimed at detecting errors and unde-
sired behavior. The errors include semantic errors, logical errors, and computation
errors, among many others. The undesired behavior refers to the behavior of the sys-
tem that is not stated in the requirements and could be exploited to compromise the
effectiveness, or security, of the system. Consider, for example, a web application
that requires each user to login. Software testing of the login use case is to ensure
that legitimate users with a valid password are able to login and the other cases are be
rejected. Moreover, if the requirements state that the account shall be made inactive
after three fail attempts, then the test must also ensure that this is indeed the case.
More specifically, software testing generates and executes tests, and analyzes the test
results to ensure that the web application indeed satisfies these requirements. Clearly,
the test generation process must take into account the various login scenarios, in-
cluding valid and invalid login scenarios, and scenarios that represent three or more
failed login attempts. The challenges are how to generate such tests, how to determine
that the tests are effective in detecting errors, and when the test process should stop.
Software testing as a discipline answers these questions and more.
Chapter 20 Software Testing 503
1. Knowing that all software must be tested and will be tested, the developers will
be more conscious for developing error-free software.
2. Adopting cost-effective software testing methods and tools will significantly
improve software quality. The story at the beginning of this chapter about the
young software engineer applying these methods and detecting hundreds of bugs
illustrates this.
3. Software testing adds another layer of quality assurance in addition to inspection,
walkthrough, and peer review. This is similar to the benefits of test driving the
car in addition to checking the car without driving it.
4. If a bug database is used to record the bugs detected during testing and field
operation, then the information can be used to produce bug statistics and root
cause analysis reports. These reports are very valuable for process improvement.
504 Part VI Implementation and Quality Assurance
tests are specified using tables. Some authors use tuples to represent these. Since table
rows and tuples are equivalent, these two representations are not different.
In the example, the output condition omits several cases that should be considered.
For example, the elements in the resulting list must have the same order as in the input
list. Moreover, every element in the resulting list must be an element in the original
list, and vice versa. For simplicity, these conditions are not included. One important
activity of software testing is implementing and running the tests to ensure that the
CUT indeed passes the tests. These tasks can be accomplished by using a test tool.
JUnit is widely used for implementing and running the tests for Java programs. How
to use JUnit to accomplish these tasks is presented in Appendix C.
•
EXAMPLE 20.1 Apply equivalence partition test to the purge function discussed in Section 20.3.1.
Solution: The input to the purge program is an integer list. The purge program
must process all such lists. Therefore, the input domain of the purge program is
the set of all such lists. Applying an equivalence partition test is to partition this set
into disjoint subsets and select one test case from each of the subsets. According to
the functionality of the purge program, the input set is partitioned into two disjoint
subsets, one of which consists of lists with duplicate elements while the other
contains lists without duplicate elements.
•
Chapter 20 Software Testing 507
•
One of the graduate admission criteria of a computer science department is EXAMPLE 20.2
GPA >= 3.0. However, if the student’s undergraduate major is not computer
science, then the student must take deficiency courses. Apply an equivalence par-
tition test to this application.
Solution: The problem given above indicates that applications with an undergrad-
uate degree in computer science and GPA >= 3.0 are admitted unconditionally.
Applications with GPA < 3.0 are rejected. Applications with GPA >= 3.0 but an
undergraduate degree that is not computer science must take deficiency courses.
Applying an equivalence partition test is to divide all the applications into four
disjoint subsets:
1. Partition 1 (GPA >= 3.0 and major == “CS”): This subset consists of appli-
cations with GPA >= 3.0 and an undergraduate degree in computer science.
This partition results in unconditional admissions.
2. Partition 2 (GPA >= 3.0 and major!=“CS”): This subset consists of applica-
tions with GPA >= 3.0 but the undergraduate degree is not computer science.
This results in admissions that require the student to take deficiency courses.
3. Partition 3 (GPA < 3.0 and major==“CS”): This subset consists of applica-
tions with GPA < 3.0 and an undergraduate degree in computer science. This
results in rejection.
4. Partition 4 (GPA < 3.0 and major!=“CS”): This subset consists of applications
with GPA < 3.0 and an undergraduate degree not in computer science. This
also results in reject.
•
Case Input/Output
Test Cases
# Type Domain
Numeric A range of values [n1, n2] n1–1, n, n1+1, n2–1, n2, n2+1
1 Nonnumeric A range of consecutive S1, S2, null string, empty string, very long string
strings S1–S2
Numeric Ranges of values [n1, n2], Same as 1 but for each range
[n3, n4], ni<ni+1
2
Nonnumeric Ranges of consecutive S1, S2, S3, S4, null string, empty string, very long string
strings S1–S2, S3–S4
Numeric A single value n n–1, n, n+1
3
Nonnumeric A single string S S, null string, empty string, very long string
Numeric An enumeration of discrete nj–1, nj, nj+1, j=1, 2, ..., k
values {n1, ..., nk}
4 Nonnumeric An enumeration of strings S1, ..., Sn, null string, empty string, very long string
{S1, ..., Sn}
A set of strings Null string, empty string, one-char string, very long string
5 Boolean {True, False} {True}, {False}
Container Instances of Container (1) A null container reference, (2) an empty container, (3) a one element
container, (4) one less than the maximum size of the container, (5)
6
maximum number of elements, (6) if possible, one more element than the
maximum size of container, (7) boundary test cases for container elements.
element, lists with only two elements, . . . , and lists with a very large number of
elements. Thus, the boundary value tests are: (1) an empty list, (2) a list with only ∨
one element, (3) a list with two elements, (4) a list of N elements with N equals to
the specified upper limit of the length of any list, (5) a list with N-1 elements, and
(6) a list of N + 1 element. Since the list is a container, a test for a null reference
should be included.
•
•
EXAMPLE 20.4 Apply a boundary value test to the graduate admission example described in
Example 20.2.
Solution: First, the ranges of values for each of the partitions obtained in Example
20.2 are determined. That is, for GPA >= 3.0, the range of values is 3.0–4.0 assum-
ing that the maximal GPA is 4.0. For the degree major, the values are “CS” or “not
CS.” Next, the test cases are selected at the boundaries of the partitions as follows:
1. For Partition 1 (GPA >= 3.0 and major==“CS”), the test cases are the ele-
ments of the Cartesian product:
{GPA == 2.99, GPA == 3.0, GPA == 3.01, GPA == 3.99,
GPA == 4.00, GPA == 4.01} × {major == null,
major == empty string, major == “C S”, major == a very long string}
∨
Chapter 20 Software Testing 509
2. For Partition 2 (GPA >= 3.0 and major!=“CS”), the major!=“CS” condition
∨ implies a set of any strings not including “CS.” Thus, the test cases are:
{GPA == 2.99, GPA == 3.0, GPA == 3.01, GPA == 3.99, GPA == 4.00,
GPA == 4.01} × {major == null, major == empty string,
major == a one-char string, major == a very long string}
3. For Partition 3 (GPA < 3.0 and major==“CS”), the test cases are:
{GPA == −0.99, GPA == 0.00, GPA == 0.01, GPA == 2.99,
GPA == 3.0, GPA == 3.01} × {major == null, major == empty string,
major == “C S”, major == a very long string}
4. For Partition 4 (GPA < 3.0 and major!=“CS”), the test cases are:
{GPA == −0.99, GPA == 0.00, GPA == 0.01, GPA == 2.99,
GPA == 3.0, GPA == 3.01} × {major == null, major == empty string,
major == a one-char string, major == a very long string}
•
1 2 3 4
Stack reference null not null not null not null
Stack size (max=n) – 0 n k<n
Rule count 3 1 1 1
Resulting stack size 1 N/A k+1
Stack.top() a N/A a
Exception Null pointer exception Stack full exception
From the decision table, four test cases are derived, which correspond to the four
rules in the decision table. For example, the first test case is a null stack reference,
corresponding to the first rule in the decision table. The second test case is an empty
stack, corresponding to the second rule in the decision table, and so forth.
Definition 20.2 A basis path is a path from the B node to the E node and exercises
a directed cycle at most once.
This definition produces four basis paths for the purge program using its flow
graph:
1. B,1,2,E
2. B,1,2,3,4,9,10,2,E
3. B,1,2,3,4,5,6,8,4,9,10,2,E
4. B,1,2,3,4,5,7,8,4,9,10,2,E
These basis paths are the test cases. To test the CUT, the test data required to
exercise each of these paths are generated and used to execute the CUT. For example,
to exercise these paths, the following test data are generated:
1. Number of closed regions plus one. This approach obtains the cyclomatic com-
plexity by adding one to the number of closed regions in the flow graph. In
Figure 20.6(b), there are three such regions; therefore, the cyclomatic complex-
ity is 4.
2. Number of nodes and edges. In this approach, the cyclomatic complexity is the
number of edges minus the number of nodes plus 2. In Figure 20.6(b), there are
14 edges and 12 nodes; therefore, the cyclomatic complexity is 14 − 12 + 2 = 4.
1
public void purge(LinkedList list) {
Item p, q; 2 10
(1) p=(Item)list.getFirst( );
(2) while (p != null) {
(3) q=(Item)p.getNext( ); E 3
(4) while (q !=null) {
(5) if (p.compareTo(q)==0)
(6) list.remove (q); 4 9
(7) else q=(Item)q. getNext( );
(8) }
(9) p=(Item)p. getNext( ); 5
(10) }
(11) }
6 7
(a) The purge function (b) Flow graph for the purge program
(a) Simple loops (b) Nested loops (c) Concatenated loops (d) Unstructured loops
Testing Simple Loops Boundary value analysis is applied to test a simple loop as
follows:
1. Skip the loop.
2. One pass through the loop.
3. Two passes through the loop.
4. A typical number of iterations if not already done above.
5. One less than the maximum number of iterations.
6. The maximum number of iterations.
7. Attempt one more than the maximum number of iterations.
Testing Nested Loops
1. Begin with the innermost loop. Set all the outer loops to their minimum values.
2. Test the innermost loop for each of the following five cases: (1) minimum number
of iterations, (2) minimum number of iterations plus one, (3) a typical number of
iterations, (4) maximum number of iterations minus one, (5) maximum number
of iterations. If possible, attempt out-of-range values such as minimum number
of iterations minus one and maximum number of iterations plus one.
3. Work outward, conducting tests for the next outer loop as follows:
• Set all outer loops at their minimum values.
• Exercise all nested loops with their typical values.
4. Repeat the above steps until all loops are tested.
Testing Concatenated Loops Two cases are considered when testing concatenated
loops. If the loops are independent, then test them as simple loops. If the loop variable
of one loop directly or indirectly depends on the loop variable of the other loop and
the dependency occurs on the same path, then test them as nested loops.
514 Part VI Implementation and Quality Assurance
Testing Unstructured Loops Unstructured loops are difficult to understand and test.
The code should be rewritten to eliminate unstructured loops.
B def(offSet,B), def(list,B)
P-Use. For p-use, the define-use paths are the paths from the node containing the
definition to each of the immediate successors of the node containing the predicate
use. The p-use column of Figure 20.9 shows the p-use for the variables used in
the program, where (1, (2,3)) means that the variable is defined at statement 1
and p-used at statement 2 and the result leads to executing statement 3.
Data flow testing is to ensure that the CUT is correct with respect to each of the
c-use and p-use chains. For example, the c-use chain (1, 7) means generating test
data that will cause the program to execute statement 1 and statement 7. The result
produced by the CUT is checked for correctness. To achieve this, using offSet=1 will
cause the CUT to execute these two statements. The result should be the value of the
first element in the list. Of course, one can use offSet=2, and the result should be the
average of the first two elements in the list. These tests ensure that the variable n is
defined and c-used correctly. The other use chains are similar.
(a) Program with an interprocedural call (b) Interprocedural data flow graph
Other definitions exist in the literature. From a practical point of view, test cov-
erage is both a quality goal and a measurement of the accomplishment of the quality
goal. For instance, many software development organizations require a 100% branch
coverage. This specifies a quality goal. It is a quality goal because 100% branch cov-
erage may not be achievable for some programs. For example, no test set can exercise
the false branch of the nested if-condition of the following hypothetic program. The
tests can cover only three out of the four branches created by the two conditions,
therefore, the coverage accomplished is 0.75 or 75%, which is a measurement or
actual test coverage.
if (x > 1) {
if (2 * x >= 1)
foo();
Chapter 20 Software Testing 517
else
bar();
}
test cases
run component
under test (CUT)
test results
[coverage achieved]
Halt
Input
Type Value Specification Valid Invalid Exceptional Cases
Element
Login ID String Length must be between Login ID Login ID does • Strings with length=0, 1, or
8 and 20 characters satisfies value not satisfy value a very large number; or
specification specification or • Strings with one or more
and is not used already exists spaces, control characters,
by another user in system or special characters
Password Password Length must be between Password Password not satisfies • Passwords with length=0, 1,
8 and 12 characters, and satisfies the the password rule or a very large number;
contain at least one password rule • Passwords contain one or
alphabet, numeric, and on the left more spaces or control
special character characters
Retyped Password Same as password Match with Retyped password does
password password not match password, or
is entered using copy-
and-paste
Test Retyped
Login ID Password Expected Outcome
Case Password
1 Valid Valid Valid show Registration Successful page
2 Valid Valid Invalid show Error Message
3 Valid Invalid Valid show Error Message
4 Valid Invalid Invalid
5 Valid Exceptional Valid show Error Message
6 Valid Exceptional Invalid
7 Invalid Valid Valid show Error Message
8 Invalid Valid Invalid
9 Invalid Invalid Valid
10 Invalid Invalid Invalid
11 Invalid Exceptional Valid
12 Invalid Exceptional Invalid
13 Exceptional Valid Valid show Error Message
14 Exceptional Valid Invalid
15 Exceptional Invalid Valid
16 Exceptional Invalid Invalid
17 Exceptional Exceptional Valid
18 Exceptional Exceptional Invalid
Test
Login ID Password Retyped Password Expected Result
Case
1 “newuser@hmail.com” “xft123%PLM” “xft123%PLM” show Registration Successful page
2 “newuser@hmail.com” “xft123%PLM” “yyyyyyyyy” show Error Message
3 “newuser@hmail.com” “zzzzzz” “xft123%PLM” show Error Message
5 “newuser@hmail.com” “x” “xft123%PLM” show Error Message
7 “olduser@hmail.com” “xft123%PLM” “xft123%PLM” show Error Message
13 “new user@hmail.com” “xft123%PLM” “xft123%PLM” show Error Message
a stack full exception, depending on the state of the stack. Testing object state behav-
ior is an important aspect of object-oriented software testing. This section presents
the ClassBench approach proposed by D. Hoffman and P. Strooper for object state
testing [81]. As the running example, an integer set called IntSet is used. IntSet has a
fixed size and five operations: add(int x), remove(int x), removeAll(), isMember(int
x):boolean, and size(): int. The add operation throws duplicate exception and full
exception and the remove operation throws not found exception.
The ClassBench approach has five steps, as depicted in Figure 20.11. Each of
these steps is detailed in the following sections.
522 Part VI Implementation and Quality Assurance
{0, 2, 4, 6, ...}
Even
clear delete-odd
TC1: Empty, add-all, All, delete-
add-all odd, Even, clear, Empty
{} Empty All {0, 1, 2, ...,
MAXSIZE}
TC2: Empty, add-all, All, delete-
clear delete-even
Odd even, Odd, clear, Empty
{1, 3, 5, 7,...}
(a) A test model for the IntSet class (b) A test case is a path from
an initial state
executed according to the semantics of the transition. Consider, for example, TC1:
Empty, add-all, All, delete-odd, Even, clear, Empty. When the Empty state is visited,
the size of the IntSet instance is checked to ensure that it is equal to zero. When the
add-all transition is visited, the integers 0, 1, 2, . . . , MAX-1, MAX are added to the
IntSet instance. When the All state is visited, the size of the IntSet instance is checked
to ensure that it is MAX. Moreover, the CUT should contain the integers added.
for determining which test cases to reuse and which new test cases need to be
generated.
Let B be a subclass of class A. When testing class B, the following guidelines
are applied:
1. New test cases are required for testing new features introduced by class B in-
cluding specification-based and/or program-based test cases.
2. Inherited features should be retested in the subclass context. That is, the relevant
test cases must be rerun when testing B.
3. Program-based test cases must be generated to test each redefined feature because
the implementation has changed. Specification-based test cases from the parent
class should be rerun in the subclass context to reveal an undesired side effect.
(a) Testing for CUT throws an exception (b) Testing for CUT that can throw an
exception but not explicitly specified
propagate to the upper level; in this case, an error is detected. Figure 20.18(b)
shows how to test these cases.
redirect to
Web Page
link to
LoadToFrame *
0..1 Client Page Server Page
frame: f
produce use: {var}
* * *
* Frame Script Form 0..1
input: {var}
contain
*
process
register.html
logon
appl-confirmation.html
home
sear for
program
progsearch: Form personal appl-online.jsp
search.html
input: {criteria} homepage.html use: {appl-info}
apply
online
progsearch.jsp program appl-online:Form
appl-online.html
use: {criteria} list.html apply input: {appl-info}
online
2% of the system’s resources are actually used at any given time, then most of the
investment in the resources is wasted. Stress testing is aimed at assessing the system’s
ability to withstand and process an extremely heavy workload, usually a magnitude
that is multiple times of the workload that the system is designed to handle.
Performance testing and stress testing can be performed in many ways. The per-
formance aspects of the system may be measured for a period of time while it is
used by the users in the target environment. This approach is used for assessing the
system’s performance in the normal usage situation. For some applications such as
telecommunication systems, special equipment, called test equipment, is used to con-
duct performance testing. Another approach to performance testing uses simulation.
There are many simulation tools for performance testings.
Simulation-based performance testing involves a number of steps. The steps
are different for different simulation approaches. An approach that uses profiling is
described here. First, a user model is constructed. For example, a usage profile that
describes the distribution of the different types of transactions can be produced from
existing transaction logs. Next, a prototype transaction for each of the transaction
types is constructed and used to produce the transaction instances. Finally, a random
number generator is employed to generate the required workload to test the system
according to the usage profile. Performance testing of web applications may use
multiple client machines as well as simulated virtual machines to create the required
volume of requests to test the performance of the web application.
validation, such as testing activities along the right leg using integration testing, ac-
ceptance testing, and system testing.
A test plan generally specifies the following items:
1. Test objectives. The test objectives specify what the tests will accomplish. For
example, the overall objective of system testing is to ensure that the system
satisfies the system requirements and constraints. However, in practice, due to
budget and schedule constraints, not all requirements and constraints could be
tested. In such cases, the objectives should include a list of the requirements and
constraints to be tested.
2. Types of test. The types of tests used specify the aspects of the system to be tested.
These include functional testing, structural testing, state testing, performance
testing, stress testing, and testing for security, among others.
3. Test methods and techniques. These specify the test methods and test techniques
to be used to perform the tests. For example, “functional testing will use cause
effect testing, equivalence partitioning, and boundary value analysis.”
4. Test cases. These specify the test cases that must be performed during the testing
phase. Typically, test cases for high-priority use cases and critical functionality
of the system should be included. Refinements of the test cases may be needed
during the testing phase to reflect the as-built functionality and behavior.
Chapter 20 Software Testing 531
5. Test coverage criteria. These specify the test coverage criteria to be accom-
plished. For example, requirements coverage means that each requirement must
be tested. Often, more than one type of coverage criteria is specified, for exam-
ple, in addition to requirement coverage, many companies also require branch
coverage.
6. Documents needed. The documents or artifacts that are needed for preparing the
test cases, executing the tests, and analyzing the test results.
7. Required resources. These include human resources, hardware equipment, and
software components and software tools.
8. Effort estimation and schedule. The estimated effort required to perform the tests
and a tentative test schedule.
If the functions and interfaces of the individual components are implemented ac-
cording to the design specification, then integration testing should proceed relatively
smoothly. Unfortunately, many projects experience the so-called integration night-
mare, meaning that the components do not work with each other, and debugging is
difficult due to complex interdependencies and runtime effect. The most likely cause
is inconsistencies in component interfacing and interaction. Inspection, code review,
and integration testing are meant to detect such errors.
During the implementation and unit testing phase, the software components are
implemented and tested by the individual developers. Test-driven development is
increasingly popular during recent years. Test-driven development means “write tests
before writing the production code.” It requires the programmer to understand the
functionality prior to implementing the functionality. The combination of test-driven
development and a code coverage tool ensures that the required functionality and code
coverage criteria are satisfied. Chapter 18 (Implementation Considerations) describes
the details.
After system testing, the product is installed and tested in the target environment.
The tests are carried out by executing a subset of the test cases used during system
testing. The test cases are selected according to changes to the environment parameters
such as system setup, run conditions, and network configuration. It is to ensure that
the system operates correctly in the customer environment.
or its components still satisfy the functional, performance, and security requirements.
This type of testing is called regression testing. Often, regression testing executes all
the existing test cases or a selected subset to ensure that the software system or its
components pass the tests. Selecting a subset of the existing test cases can save time
and effort. Test cases are selected according to the components that are changed or
affected by the changes. Tools for selecting regression test cases have been developed.
Some of the tools instrument and execute the software before making changes. This
allows the tool to collect information about which test cases exercise which classes
and methods. This information along with the changed and affected classes are used to
select the test cases that need to be rerun. If XUnit has been used during development
testing, then regression testing simply reruns the XUnit test cases. However, XUnit
test cases usually do not include system testing and user interface testing. In these
cases, other regression testing tools, such as WinRunner and UI Gestures Collector
(a plug-in of NetBeans) should be used. These tools record the user actions and play
back the recorded test scripts during regression testing.
1. The projected average number of field detect failures Nf, or number of field
detect failures per thousand lines of code. For the above example, Nf = 1, or
1/33K = 0.03 field detect failures per thousand lines of code.
2. The total number of failures detected so far during testing, denoted Nd. For the
above example, Nd = 15.
3. The total test-execution hours up to the detection of the last failure Ht. For the
above example, Ht = 450.
The zero-failure test hours Hz, measured from the detection of the last failure, is
computed by:
! "#! " ! "#! "
Nf 0.5 + Nf 1 1.5
Hz = Ht ∗ ln ln = 450 ∗ ln ln = 77
0.5 + Nf Nd + Nf 1.5 16
534 Part VI Implementation and Quality Assurance
Because 50 zero-failure hours has passed since the detection of the last failure,
it needs 27 additional zero-failure hours of test execution time. During this period,
testing continues as usual and no failure can occur; otherwise, the zero-failure hours
must be calculated again and the testing continues.
GUIDELINE 20.1 Integrate testing throughout the life cycle; test early and often.
Agile practices develop small, incremental releases iteratively. During the iterative
process, unit testing, integration testing, and acceptance testing are repeatedly per-
formed. For example, in extreme programming, unit testing is performed continually.
All tests must run flawlessly for the development to continue. Customers write tests
to demonstrate that the features are finished. In addition, extreme programming sug-
gests continuous integration. That is, integrate and build the system many times a day,
every time a task is completed. Continuous and frequent testings greatly improve the
quality of the code.
SUMMARY
•
This chapter presents software testing and its impor- also describes how to test an inheritance hierarchy,
tance. It describes a generic test process and differ- exception-handling, and nonfunctional requirements.
ent test methods and techniques, including white- Static testing and dynamic testing in the life cycle are
box, black-box, use case–based, state-dependent, described.
and web application testing techniques. The chapter
FURTHER READING
•
Books on software testing include [3, 10, 22, 28, 53], among and Harrold describe a method for selecting regression tests
many others. The ClassBench approach for object state test- for object-oriented software. Testing of exception handling
ing is found in [81]. Testing class inheritance hierarchy is constructs is addressed by Sinha and Harrold in [137].
presented in [77], which led to the extension of ClassBench The implementation and test order concept was originally
to testing subclasses [112]. The web application test method proposed by the author and his colleagues [101]. The al-
was described in [128]. Numerous papers on software test- gorithm has since been improved by several other authors
ing and testing object-oriented software are published. Here [37, 38, 103, 147, 151]. Eleven test adequacy axioms were
are a few of them. Testing polymorphic relationships is ad- proposed by Weyuker in [158, 159]. An application of these
dressed by Alexander and Offutt [8]. In [130] Rothermel axioms to testing object-oriented software is found in [122].
EXERCISES
•
20.1 For the average function presented in Figure 20.8 do d. Generate boundary value test cases.
the following: e. Implement the average function in a class; also im-
plement the test cases using JUnit or any other test
a. Write a brief functional description for the tool as designated by the instructor.
function. f. Compile and run the test cases. Record any failures
b. Generate functional test cases based on the func- and errors that are reported. Analyze and briefly
tional description. explain why each of the failures and errors occurs
c. Identify and specify the partitions and generate and how to fix them. Correct the failures and errors
partition test cases. until the CUT passes all the test cases.
536 Part VI Implementation and Quality Assurance
20.2 Perform basis path testing to the average function tool as determined by the instructor. Your test cases
shown in Figure 20.8. Implement the CUT in Java must achieve 100% branch coverage. Cobertura is
and the test cases in JUnit, or according to instruc- described in Appendix C.
tions given by the instructor. Run the test cases and 20.5 Design equivalence partitioning and boundary value
analyze the test results. Correct any problems and analysis test cases to test the singly linked list and
write a brief test report about the problems; include implement them in JUnit. Your test cases must
why they occur and how they are fixed. achieve 100% branch coverage as measured by
20.3 Perform test-driven development to implement a Cobertura or other coverage tool as determined by the
singly-linked list that provides at least the follow- instructor.
ing functions. Note: You are not allowed to use any 20.6 Repeat the last exercise, but instead of using equiv-
Java API such as ArrayList and LinkedList as a re- alence partitioning and boundary value analysis, use
placement for the singly linked list—i.e., you must basis path testing.
implement the singly linked list. Moreover, you are 20.7 Repeat the last exercise, but instead of using basis
not allowed to implement a doubly linked list. path testing, apply the ClassBench state testing as
• public void insert(Object o1, Object o2): insert
described in Section 20.7.2.
object o1 in front of object o2 in the linked list.
• public Object find(String attrName, String attr-
20.8 Draw and fill the entries of a table that summarizes
the test methods presented in this chapter. The table
Value): Returns the object with the given attribute
has one row for each of the test methods: equivalence
name attrName with the given attribute value
partition, boundary value analysis, cause-effect, ba-
attrValue. If more than one such object is found,
sis path, data flow (intraprocedural only), use case–
the first such object is returned. If not found, it
based, ClassBench, web testing. The columns are:
returns null. You need to use Java reflection to
a. Method, which shows the test methods presented
do this. This function is, in fact, a polymorphic
in this chapter.
function, that is, the attrValue could be int, dou-
b. Test Model, which briefly describes what the test
ble, etc. But for this homework, you can assume
model is for the test method.
that the attribute value is string type.
• public Object remove(Object obj): Removes the
c. Test Case Generation, which briefly describes how
the test cases are derived.
object referred to by the object reference obj from
d. Test Coverage(s), which briefly specifies the ap-
the linked list.
• public int size(): Returns the size of the linked
plicable test coverage criteria.
list. 20.9 Prove that the three approaches to compute the cy-
clomatic complexity are equivalent. Hint: Use math-
20.4 Apply cause-effect testing to test the singly linked
ematical induction. In addition, proof by contradic-
list. Implement the test cases in JUnit and measure
tion can be used.
the code coverage using Cobertura or other coverage
part VII
Maintenance and
Configuration Management
Chapter 21 Software Maintenance 538
Chapter 22 Software Configuration Management 562
537
21
Software Maintenance
Previous chapters present the software development activities that lead to the re-
lease and installation of a software system in its operational environment. Often, the
software system undergoes a beta testing phase, during which the users test run the
system and report bugs and deficiencies. The development team removes the bugs
and deficiencies. This period may take a few weeks or several months, depending on
the nature of the application, complexity, and size of the software system. After beta
test, the software system enters into its maintenance phase. The system is stabilizing
in the first several months during which the users exercise more and more functions
and become familiar with the system’s behavior. Removal of bugs and deficiencies
continues, but the rate should reduce significantly. This period is sometimes called the
system aging period. As the world evolves, the system’s functionality, performance,
quality of service, or security can no longer satisfy the business needs. Enhancement
to the system is required. In this case, a new project is established to identify new
capabilities, and design and implement the new capabilities to enhance the software
system. The new project will go through the steps as described in the previous chap-
ters. In this way, the system evolves during the prolonged maintenance period. Various
surveys show that software maintenance consumes 60%–80% of the total life-cycle
costs; 75% or more of the costs are due to enhancements [94]. Therefore, software
maintenance is an important area of software engineering and deserves an entire book
[73]. This chapter serves as an introduction to the topic. After studying this chapter,
you will learn the following:
538
Chapter 21 Software Maintenance 539
1. Bug fixes. Although the software system has been tested to achieve a desired test
coverage, some vital bugs may occur during the operational phase. These require
bug removal and regression testing to ensure that the modified software passes
selected tests performed previously.
2. Change in operating environment. Changes in the hardware, platform, and system
configuration may require modification to the software.
3. Change in government policies and regulations. Changes in government policies
and regulations may require changes to the software system to comply with the
new policies and regulations.
540 Part VII Maintenance and Configuration Management
1. Law of continuing change (1974). After the system is released, changes to the
system are required, and these continue until the system is replaced. Changes are
due to reasons described in Section 21.2.
2. Law of increasing entropy or complexity (1974). The structure of the software
system deteriorates as changes are made. This is because changes introduce
errors, which require more changes. Changes often introduce conditional state-
ments to handle erroneous situations, or check for invocation of new features.
These increase the complexity of the system and coupling between the compo-
nents. The result is that the system becomes more and more difficult to understand
and maintain. Restructuring or reengineering is required to improve the structure
of the system to reduce the maintenance cost.
3. Law of self-regulation (1974). The system evolution process is a self-regulating
process. Many system attributes such as maintainability, release interval, error
rate, and the like may appear to be stochastic from release to release. However,
their long-term trends exhibit observable regularities. In fact, this law is univer-
sal. That is, it is not limited to system evolution. It is applicable to everything
because everything is a system. Consider, for example, the stock chart for a pub-
lic company. The daily prices may fluctuate, sometimes drastically. However,
the long-term movements exhibit an upward, downward, or flat trend. This law
is due to the eighth law—that is, the law of feedback systems. Indeed, the reg-
ularity is the result of the feedback loops, or interaction of factors that cancel
each other as well as enhance each other during a long period of maintenance
activities. This law is also a generalization of the next three laws—law of con-
servation of organizational stability, law of conservation of familiarity, and law
Chapter 21 Software Maintenance 541
of continuing growth. These three laws state the regularities of three specific
aspects.
4. Law of conservation of organizational stability (1978). The maintenance process
for an E-type system tends to exhibit a constant average work rate over the
system’s lifetime.
5. Law of conservation of familiarity (1978). The average incremental growth of
the system remains a constant during the system’s lifetime.
6. Law of continuing growth (1991). E-type systems must continue its functional
growth to satisfy its users.
7. Law of declining quality (1996). The quality of E-type systems will appear to
be declining unless they are rigorously adapted to the changes in the operating
environment.
8. Law of feedback systems (1996). The evolution process consists of multilevel,
multiloop, and multiagent feedback systems that play a role in all the laws. That
is, the other laws are due to the feedback behavior.
As stated in Lehman and Belady’s article, the law of increasing entropy implies
that the system would be replaced because the cost to maintain it would exceed the
cost of building a new system. This was true for operating systems, which were
studied by Lehman and Belady. However, many organizations find that replacing a
legacy application system is not an option because numerous business processes and
business rules have been implemented in the legacy system during the prolonged
maintenance process. Moreover, millions of records are stored in the databases. Due
to inadequate documentation and the complexity of the system, no one really knows
what is implemented and how to port the data records. Therefore, many legacy systems
are still in use and companies spend hundreds of millions of dollars maintaining them
each year.
(a) Quick fix model (b) Iterative enhancement model (c) Full reuse model
Software retirement
Acceptance Regression/
Testing System Testing
to reap the benefits of reuse. The model requires that there must be a repository of
reusable components, and support for selecting and tailoring the reusable components
must be available. The IEEE-1219 model shown in Figure 21.1(d) and the the ISO-
12207 model are similar to the iterative enhancement model. Figure 21.2 shows the
correspondence between the models.
Total no. of classes changed: 57; total affected: 857.76; average affected: 15.05.
Note 1: Average over 20 cases; a number of classesare randomly selected and changed.
Note 2: One randomly selected class is deleted.
Note 3: Two randomly selected classes are deleted.
Note 4: A number of randomly selected classes are changed.
cause, but it is relatively easy to change a different component to fix the problem, at
least temporarily. In this case, these two alternatives should be identified. The changes
identified are analyzed to:
1. Assess the change impact—that is, which other components will be affected by
the changes made to a given component.
2. Estimate the costs and time required to implement the changes and test the result.
3. Identify risks and define resolution measures.
Object-oriented software exhibits complex dependencies among the classes.
Changes made to one class may affect many classes. This is also called the rip-
ple effect. Figure 21.4 shows the change impact in the InterViews library discussed
earlier. The data indicate that on average, 15 classes are affected when one class is
changed. The first three cases indicate that changes made to one class could affect 51,
62, and 74 classes, respectively. However, in some case, change impact is limited. For
example, in one case, five classes are changed but only two classes are affected. As
discussed above, there are alternatives to fix a defect or solving a problem. Change
impact analysis should consider the maintenance costs associated with the alternative
ways to change the software. The number of alternatives should be limited to reduce
the cost of change analysis. In addition to change impact, the risks associated with the
changes are identified and measures are defined to resolve the risks if they do occur.
The outcome of this step is used in the configuration change control step to determine
if the proposed changes should be performed.
Change impact is identified by the dependencies among the classes. If a design
class diagram is available and up to date, then the classes that are affected by changes
to a class can be identified from the dependencies among the classes. However, in
many real-world projects, the code and the design class diagram do not match. In
these cases, a reverse-engineering tool can be used to produce the implementation
class diagram from the code. The change impact can be derived from the design class
diagram or the implementation class diagram as follows. If class B depends on class
A, then changes to class A affect class B. Moreover, if class C depends on class B
and class B depends on class A, then changes to class A also affect class C. This is
because the dependency relation is a transitive relation. Class B depends on class A
if one of the following holds. Figure 21.5 illustrates these cases with sample code.
1. Class B is a subclass of class A.
2. Class B is an aggregate of class A.
546 Part VII Maintenance and Configuration Management
Change impact analysis using the design class diagram is associated with a num-
ber of problems. The design class diagram usually does not include implementation
classes and associated relationships. Moreover, the implementation of the classes and
relationships of a design class diagram may differ from their design counterparts. For
example, an implemented class may have more functions than its design counterpart.
These functions may call functions of other classes. Such dependencies may not ex-
ist in the design class diagram. Thus, change impact analysis based on the design
class diagram may produce incorrect results. Finally, if the design class diagram is
not available, then it is not possible to use this approach. Change impact analysis
Chapter 21 Software Maintenance 547
21.6 REVERSE-ENGINEERING
•
The process that converts the code to recover the design, specification, and a prob-
lem statement is a reverse process of the development process. Therefore, this is
called reverse-engineering. Chikofsky and Cross define reverse-engineering as “the
548 Part VII Maintenance and Configuration Management
Artifact Diagram
Database Layouts
process of analyzing a subject system to identify the system’s components and their
interrelationships, and create representations of the system in another form or at a
higher level of abstraction” [46]. In comparison, “the traditional process of moving
from high-level abstractions and logical, implementation-independent designs to the
physical implementation of a system” is called forward-engineering [46].
Object Relation Diagram (ORD). This component takes the source code and
produces a UML class diagram showing the classes, their attributes and opera-
tions, and the relationships between the classes. The user can select the classes
and relationships, and the attributes and methods of which classes to be displayed.
The ORD utilities include:
• Change Impact Analysis. The user can select the classes to be changed and
have the tool highlight the classes that are affected, based on the dependencies
among the classes, as described in the last section.
• Software Metrics. This utility calculates software metrics including, for each
class, the class size, number of lines of code, number of children, fan-in,
fan-out, number of relationships, depth-in-inheritance-tree, and so on.
• Version Comparison. This utility takes as input two versions of the source
code and displays the ORD for the old and new versions. Moreover, the new
version highlights the classes added, changed, and affected. The old version
highlights the classes deleted, changed, and affected.
• Test Order. This utility computes the order to test the classes so that the effort
required to implement the test stubs is substantially reduced.
Block Branch Diagram (BBD). The Block Branch Diagram performs reverse-
engineering of the functions of a class and displays the flowcharts for the func-
tions. The BBD component also calculates and displays the basis paths of the
function, highlights the basis path selected, and shows the variables that are used
and modified.
Object Interaction Diagram (OID). This component performs reverse-
engineering of the source code to generate and display a sequence diagram that
describes the interaction between the objects.
Object State Diagram (OSD). This component performs reverse-engineering
of the source code to produce and display a state diagram that describes the state-
dependent behavior of an object. The utilities include state reachability analysis
and state-based fault analysis.
These cause the structure of the software system to deteriorate. As a consequence, the
software becomes more difficult to comprehend and more costly to maintain. In this
case, it is necessary to restructure the software system to reduce the maintenance cost.
First, the metric calculation tool of OOTWorks is applied to identify places that
need improvement. The tool indicates many places required improvements. One of
these is the extremely high complexity of one of the methods of a metrics calculation
class. The method calculates the software metrics selected by the user. The software
industry has an unofficial complexity threshold of 10, but the method has a com-
plexity of 38. To understand why the method has such a high complexity, a closer
examination of the code is performed. It reveals that the method uses conditional
statements to test if a metric is selected. If so, it calculates the metric. The com-
plexity reflects the use of 38 conditional checks to determine which metrics need be
computed.
The next step is to select an improvement strategy. The use of conditional state-
ments implies behavior variations. That is, different metrics are calculated by using
different algorithms. This suggests that the polymorphism pattern can be applied. The
polymorphism pattern is summarized as follows:
Problem: How does one handle behavior variations without using conditional state-
ments?
Solution: Define an interface for the behaviors that vary and let the subclasses im-
plement the behavior variations.
Thus, an abstract class called Metric is defined. It implements the Action Listener
interface of Java. Its actionPerformed(. . .) method invokes its abstract computeMet-
ric(. . .) method. The subclasses of Metric implement the computeMetric(. . .) method
to compute the concrete metrics. Moreover, the subclasses are the action listeners of
the respective metric selection widgets, which are check boxes. In this way, when
the user checks a metric check box, the corresponding metric is calculated. When the
user clicks the Display Metrics button, the selected metrics are displayed.
The third step implements the proposed improvements. That is, the skeleton code
for the Metric abstract class is implemented. Test-driven development is applied to
implement each of the concrete Metric classes, one at a time. More specifically, the
skeleton code for the subclass is implemented. Tests are written to test the unimple-
mented computeMetric(. . .) method and make sure all the tests fail. The implemen-
tation of the computeMetric(. . .) involves copying-and-pasting the existing code into
the appropriate places. The code is modified if needed. In most cases, very little effort
is required to modify the reused code. The tests are run to ensure that the metric is
correct. The process iterates for each of the metrics.
Finally, the modified tool is applied to assess the complexity of the modified class.
It shows that the complexities of the computeMetrics(. . .) methods of the subclasses
are low. As expected, about 40 new classes are added. Regression testing is performed
to ensure that the change does not alter other parts of the software. For this case study,
it is the case. In addition to substantial reduction in complexity, the improvement
makes the component much easier to maintain. For example, adding new metrics
is very easy—one needs to add and implement a Metric subclass and a check box
to notify an object of this class. Test-driven development of this extension is also
made easy, compared to testing the chunk of code that contains 38 nested if-then-else
statements.
Chapter 21 Software Maintenance 553
Name Facade
Type GoF/Structural
Specification
Problem How to simplify the interface for a client that interacts with a web of components.
Solution Define a class in-between the client and the components. The class interacts with the components and
provides a simple interface for the client.
Design
Facade Component 1
Client operation1( )
operation2( )
Structural
Component 2 Component 3
Diagram is illustrative only. The exact relationships between
the facade and the components are application dependent. Component 4
operation1( ) a( )
Behavioral b( )
To illustrate, consider the design in Figure 21.9. The classes enclosed in the gray
cloud shape interact with each other in a complex fashion. The interaction behavior
is somewhat difficult to comprehend. In addition, a change to one class may affect
the other classes. To improve, the mediator pattern is applied. Figure 21.11 shows
the result. In the figure, the mediator interacts with the objects, which are decoupled
from each other. The mediator coordinates the interaction.
Chapter 21 Software Maintenance 555
Name Mediator
Type GoF/Behavioral
Specification
Problem How to simplify complex component-to-component interaction.
Solution Introduce a Mediator class to interact with each of the components and let this replace the complex
m-to-m component interaction.
Design
Class 1 Class 2
Class 5 Class 4
operation1( ) a( )
Behavioral b( )
c( )
• Class 1 through Class 5: These are the classes that interact with each other forming an m-to-m
Roles and interaction in an existing design.
Responsibilities • Mediator: It is introduced to interact with each of the Classes 1–5. This 1-m interaction replaces the m-m
interaction in the existing design.
• Client: The client interacts with the mediator and through the mediator to interact with Class 1 through
Class 5.
• It simplifies the interaction between the components.
• It facilitates understanding because the interaction behavior is simplified.
• The components only interact with the mediator.
Benefits • It facilitates reuse of the components because the components are decoupled from each other.
• Change to one component has little impact on the other components because the mediator hides the
components from each other.
• It is easy to add or remove components.
• It facilitates test driven development because the component classes can be tested separately.
Liabilities The mediator’s logic may be complex because it needs to interact with the components.
Guidelines
Related Patterns State may be used to design and implement the state dependent behavior of a mediator.
Uses It is useful for designing and implementing the control element of an embedded system such as the cruise
control. In this case, Classes 1–5 represent the driver classes that interact with the hardware devices.
Artifacts Parser
// do parsing
read (): Result parse( ) mediator.writeArtifacts (...)
write (r:Result)
parser.parse();
layout.doLayout(); artifacts parser
display.draw();
mediator mediator
return artifacts.read();
<<Mediator, Facade>>
Mediator
doReverseEng() Layout
mediator layout
Client readArtifacts (): Result
doLayout()
writeArtifacts (r:Result)
readLayout(): Layout Result
writeLayout(l: Layout Result)
artifacts.write(r)
mediator mediator
Result r=mediator.readArtifacts();
layout file display // do layout then
mediator.writeLayout (...)
Layout File Display
read( ):Layout Result draw() Layout l=mediator.readLayout();
write(l:Layout Result) // draw diagram
Static analysis tools are useful for detecting violation of coding standards, in-
correct use of types, existence of certain bugs and anomalies, and security
vulnerabilities.
Change impact analysis tools are useful for assessing the scope of impact of
proposed improvements. The change impact analysis results are the basis for the
estimation of the effort required to perform the proposed improvements.
Effort estimation tools are useful for calculating the required time, effort, and
costs to implement the proposed improvements.
Configuration management tools such as Concurrent Versions System (CVS)
and Subversion are useful for coordinating the changes to maintain the consis-
tency of the software being reengineered.
Regression testing tools are useful for rerunning the test cases to ensure that
the system satisfies the requirements and reengineering does not introduce new
errors. Some of the tools can analyze the software and select a subset of test cases
to rerun. This reduces the regression testing time and effort.
SUMMARY
•
This chapter presents the Lehman’s laws of sys- engineering, reengineering, and patterns and tools that
tem evolution, types of software maintenance, and can be applied during the maintenance phase are de-
software maintenance process models. Reverse- scribed.
560 Part VII Maintenance and Configuration Management
FURTHER READING
•
The IEEE International Conference on Software Mainte- hancement, and full reuse maintenance models. A reverse-
nance proceedings are good sources of publications on soft- engineering definition is presented in [46]. The change im-
ware maintenance. Another source of publications is the pact analysis method described in this chapter is detailed in
Journal of Software Maintenance and Evolution. Reference [102]. Gao and colleagues [70] extended the impact analysis
[73] provides an excellent coverage of various topics of soft- algorithm to consider also polymorphism. Some regression
ware maintenance. The maintenance chapter of [4] is very test selection techniques are found in [85, 130, 164].
good. Reference [16] presents the quick fix, iterative en-
EXERCISES
•
21.1 Collect more than five articles from refereed jour- 21.3 Describe how you would use a metrics tool to iden-
nals, magazines, and conference proceedings. The tify places that need improvement. Assume that you
articles must be about industry lessons learned or have the tool that can compute all the metrics and
case studies regarding reengineering, restructuring, provide the capabilities you want.
or reorganizing a software system. Write a survey ar- 21.4 Assume that right after you graduate, you are hired by
ticle about these project experiences. The survey arti- the maintenance team of a financial company. More-
cle should discuss the factors that cause the change, over, you are assigned to maintain an online security
types of maintenance, the change process, reverse- (e.g., stocks, mutual funds, exchange-traded funds,
engineering, reengineering, patterns or architectural etc.) trading software. Describe and explain the re-
styles applied, and tools used by the projects. Limit sponsibilities of this position. State the assumptions
the article to no more than 10 pages or as instructed you wish to make.
by the instructor. 21.5 This exercise is a continuation of the previous exer-
21.2 Collect more than five articles as in exercise 21.1. cise (i.e., exercise 21.4). For this exercise, describe
For this exercise, suggest and discuss your improve- how you would fulfill your responsibilities to opti-
ments to the reengineering projects described in the mize your job performance. Describe also how you
articles. For example, a project could have used a would obtain job satisfaction from doing the work.
reverse-engineering or metrics tool, but it did not. Limit the article to no more than five pages or as set
A certain pattern could be applied to improve the by the instructor.
system, but the project did not. Write a report to de- 21.6 Suppose you are hired by an IT consulting com-
scribe your improvement suggestions. Limit the re- pany to work on a major reengineering project or
port to no more than five pages or as designated by a large, complex object-oriented software system.
the instructor. For this exercise, you have the freedom to assume
Chapter 21 Software Maintenance 561
the application domain and specific application of 21.7 Discuss the similarities and differences between the
the software system. Assume that your team has 20 patterns in each of the following pairs. Describe a
members. The members may work in groups. Write unique situation in which one of the patterns should
a brief article to do the following: be applied and the other should not be applied.
a. Describe how the project would proceed. 1. Facade and mediator
b. Describe which of the tasks you would like to be 2. Builder and facade
assigned to you, and why. 3. Observer and mediator
c. Assume that you are assigned the tasks you would 4. Facade and proxy.
like. Describe how you would carry out the tasks.
22
Software Configuration
Management
During the software life cycle, numerous documents are produced. These include
requirements specification, software design documents, source code, and test cases.
These documents depend on each other. For example, a software design is usually de-
rived from and dependent on the requirements specification. Classes depend on other
classes. This means that changing the requirements specification requires changes
to the design and changing one class requires changes to other classes. In general,
changes made to a document may ripple throughout the project, affecting many other
documents.
In software development, changes are inevitable because many events mandate
changes to the software development documents. If changes to the documents are not
coordinated, then inconsistencies may occur. For example, new requirements are
added to the requirements specification, but the design document is not updated to
reflect the new requirements. As a consequence, the software system that is eventually
constructed will not satisfy the customer’s needs and expectation. As another example,
when changes are made to a class, other classes that directly or indirectly depend on
the class must be updated. If this is not done properly, then the software system
may behave abnormally. Therefore, one needs a way to control and track changes. In
addition to change control, one also needs to track the progress of a software project.
Using the traditional waterfall model, tracking the completion status of the phases is
one way to track the progress of a software project. It is important to track the progress
because the completion of one phase enables the development teams to start the work
of the next phase. Project management requires the progress status information to
562
Chapter 22 Software Configuration Management 563
make decisions, such as adjusting the project schedule, adding people to the project,
and/or changing the functionality of the system.
This chapter presents concepts, activities, and techniques for controlling changes
to the documents produced during the life cycle, and tracking the status of the soft-
ware system and its components. These activities belong to the software engineering
discipline referred to as software configuration management (SCM). Traditionally,
configuration management only applies to the development of hardware elements of
a hardware-software system. It is concerned with the consistent labeling, tracking, and
change control of the hardware elements of a system. Software configuration man-
agement adapts the traditional discipline to software development. In this chapter,
you will learn the following:
the SQA reviews. At this point, the SCIs are checked in to the configuration
management system. Once a configuration item is checked in to the configuration
management system, changes to the item must go through a procedure to ensure
that the changes will maintain the consistency of the configuration of the system.
3. It forms a common basis for subsequent development activities. Before the estab-
lishment of the requirements baseline, the teams could proceed with the design
activities but changes to the requirements and use cases are to be expected. The
establishment of the requirements baseline “freezes” the documents associated
with the baseline, that is, changes can no longer be made freely. Needed changes
must be documented and evaluated to assess their impact to configuration items
produced in subsequent activities such as design diagrams and implementation.
4. It is a mechanism to control changes to configuration items as explained in the
last bullet.
checked in to the configuration management system. When all these documents are
checked in, the baseline is established.
The configuration item management aspect of SCM is concerned with updates
that are made to the baseline items. That is, before a document is checked in to
the configuration management system, changes to the document can be made freely.
However, once the document is checked in, then any update to the document must go
through a change control procedure to coordinate the update.
change status
Change
ECP: Engineering Change Proposal Incorporation
system configuration and successful cooperation between the teams and team
members. This function is performed when change requests arrive, due to events
that require changes.
• Software configuration auditing. Software configuration auditing verifies and
validates the baselines and configuration items, defines and executes mechanisms
for formally establishing the baselines, and ensures that proposed changes are
properly implemented.
• Software configuration status accounting. Software configuration status account-
ing is responsible for tracking and maintaining information about the system
configuration. It provides database support to the other three functions.
* SCI Baseline
1+
depends
attributes attributes
on components
operations operations
* * 0..1 predecessor
follow
Simple SCI Composite SCI
operations operations
(Simple SCI) and composite software configuration items (Composite SCI). A Simple
SCI does not include other configuration items. Examples are an expanded use case,
a domain model, a sequence diagram, and a design class diagram. A Composite SCI
may contain other configuration items. For example, a design specification includes
expanded use cases, sequence diagrams, and a design class diagram.
As shown in the model, changes to a SCI may affect other SCIs due to inheritance,
aggregation, and association relationships. As an example of change impact due to an
association relationship, consider a sequence diagram that is derived from an expanded
use case. Obviously, if the expanded use case is modified, the sequence diagram may
be affected and may need to be modified as well. As an example of change impact
due to an aggregation relationship, consider a design specification that contains an
expanded use case and a sequence diagram derived from the expanded use case. If
the expanded use case is deleted, then the sequence diagram must be deleted. These
imply that the design specification must be changed.
The abstract software configuration item (SCI), which is displayed in Figure 22.3
in italic font, defines a set of attributes and operations that are common to all config-
uration items. Useful attributes include, but are not limited to, the following:
• ID number—A unique ID to identify the SCI. It should bear certain semantics
to communicate the functionality of the SCI and the system or subsystem it
belongs to. For example, a domain model constructed in increment 1 for a library
information system may have an ID number like LIS-Inc1-DM.
• name—The name of the configuration item, for example, Checkout Document
Expanded Use Case, Checkout Document Sequence Diagram, and so on.
• document type—The type of the document of the SCI, for example, requirements
specification, domain model, design specification, test cases, and the like. This
attribute eliminates the need for subclassing.
• document file—The document file or the full path name for the file that contains
the SCI.
• author—The developer who creates the configuration item.
• date created, target completion date, and date completed—These are useful for
tracking the status of the SCI.
• version number—This is used to keep track of the multiple versions of a config-
uration item.
568 Part VII Maintenance and Configuration Management
• update history—A list of update summaries, each of which briefly specifies the
update, who performs the update, and date of update.
• description—A brief description of the configuration item.
• SQA personnel—A technical staff who is responsible for the quality assurance
of the configuration item.
• SCM personnel—A technical staff who is responsible for checking in the con-
figuration item.
As usual, a simple configuration item has concrete operations to set and get
attributes. It may also include abstract operations for verifying and validating the
configuration item as well as computing various metrics. A composite configuration
item has additional operations to add, remove, and get component configuration items.
Finally, a baseline has operations to add, remove, and get a predecessor as well as
operations to add, remove, and get a configuration item. To apply the model, each
concrete project extends the abstract leaf classes to provide concrete implementation
of the abstraction operations. In particular, a subclass is created for a set of SCIs that
share the same behavior.
Software Configuration
identified Change Control
changes
ECP [rejected]
Legend:
ECP: Engineering Change Proposal ECP
CCCB: Configuration Change Control Board Archive
2. Configuration item verification. This ensures that what is intended for each con-
figuration item as specified in one baseline or update is achieved in a succeeding
baseline or update. For example, for each high-level use case allocated to an
increment in the requirements baseline, there must be an expanded use case in
the design baseline that specifies how the system and the actor would interact to
carry out the front-end processing of the use case.
3. Configuration item validation. This checks the correctness to ensure that the con-
figuration item solves the right problem. Consider, for example, the Checkout
Document use case of a library information system (LIS). Verification ensures
that there is an expanded use case in the succeeding baseline. Validation en-
sures that the specification of the expanded use case indeed matches the user’s
expectation.
4. Ensuring that changes specified in approved ECPs are properly and timely im-
plemented.
versions, and revisions. In addition, SCM tools need to notify relevant teams and team
members of the state of the SCIs and changes to the SCIs. Concurrent updates to the
SCIs may be needed to improve efficiency. Such updates require concurrency control
to ensure consistency. Clearly, SCM tools are needed to support these activities. This
section presents the capabilities of such tools.
The capabilities provided by SCM tools vary significantly. Some SCM tools
provide full support to all SCM activities while others support only a subset of the
SCM activities. Which SCM tools to use depend on the project. In general, large,
mission-critical systems or distributed development require more SCM functions.
Small, agile projects tend to use only version control tools. A typical SCM tool
provides the following capabilities:
• Version control. The objective of version control is to manage the releases, ver-
sions, and revisions of a software system. It is used during the development
process as well as the maintenance phase. The need for such a function has been
discussed in the “Why Software Configuration Management’’ section.
• Workspace management. Software engineers work together to design and im-
plement a software system. To coordinate the work of the software engineers, a
central repository of software artifacts is needed. Workspace management pro-
vides local workspaces for the software engineers and the central repository
for the software engineers to share their work. It allows the software engineers
to check in local files to the repository, and check out repository files to their
workspaces.
• Concurrency control. Software engineers may need to work on the same set of
files simultaneously, which may result in inconsistent updates. Concurrency con-
trol provides mechanisms to enable or disable concurrent updates. If concurrent
update is enabled, then the tool provides mechanisms to merge the concurrent
updates and facilitate resolution of conflicts.
• System build. The system build capability allows the team to specify the system
configuration, that is, which versions of which components should be included
in a system. The SCM tool will automatically compile and link the components
to produce the executable system.
• Support to SCM process. This capability is aimed at automating the SCM proce-
dures described in previous sections.
Tools that provide version control, workspace management, and concurrency con-
trol include Source Code Control System (SCCS), Revision Control System (RCS),
Concurrent Versions System (CVS), Subversion (SVN), Domain Software Engineer-
ing Environment (DSEE), IBM ClearCase, and many others. SCCS is one of the
earliest computer-aided software for source code revision control. RCS controls ac-
cess to shared files through an access list of login names and the ability to lock and
unlock a revision. CVS is a substantial extension of RCS and is a preinstalled plugin of
NetBeans. Subversion is initially designed to replace CVS; and hence, it possesses all
of the CVS capabilities. However, since its inception in 2000, Subversion has evolved
beyond a CVS replacement and introduced a comprehensive set of advanced features.
DSEE is a proprietary SCM software, which forms the basis for IBM ClearCase.
572 Part VII Maintenance and Configuration Management
Figure 22.5 is a comparative summary of some of the features of RCS, CVS, Subver-
sion, and ClearCase. Appendix C.7 describes in detail how to use CVS and Subversion
in NetBeans.
Tools that support system build include make and ant. Make is a UNIX/Linux
utility and ant provides the functions of make to build systems using Java components.
These tools let the software engineer specify a script or a sequence of commands.
System build is accomplished by executing the script. Nowadays, system build is
supported by almost all of the integrated development environments (IDEs).
SUMMARY
•
This chapter presents the notion of a baseline and the control, software configuration auditing, and software
baselines of a typical project. A baseline represents a configuration status accounting. These functions form
significant achievement of the software project. The the SCM process as shown in Figure 22.2. The SCM
establishment of a baseline signifies that the project activities need to process a lot of data and software
has reached a new status of progress. Besides this, the artifacts. Therefore, tools are needed to support SCM
baselines also serve to control change to the software activities. This chapter presents the capabilities of
artifacts. Before a given baseline is established, all of SCM tools. How to use CVS and Subversion in the
the artifacts of the baseline can be modified freely. NetBeans IDE is given in Appendix C.7. Finally, the
However, after the baseline is established, changes to chapter summarizes the state-of-the-practice of SCM
the artifacts or SCIs must go through a change control in agile methods. That is, although only a few agile
process. methods require SCM, almost all agile methods use
The functions of SCM are software configuration version control systems and system build tools such
item identification, software configuration change as an IDE.
Chapter 22 Software Configuration Management 573
FURTHER READING
•
For more complete coverage of SCM see [5]. In [24], in [54, 143]. The agile methods that require SCM, or use a
Berczuk and Appleton present a set of configuration man- version control system are described in [21, 50, 119, 140].
agement patterns and how they related to each other. IBM Resolving conflicts between a local file and a repository file
Rational ClearCase is a powerful SCM tool, which is de- is a challenging task. Many techniques have been proposed.
scribed in [23]. References [108, 154] are excellent intro- An excellent survey of such techniques is found in [115]. Fi-
ductions to CVS and Subversion, respectively. Tutorials for nally, Juha Koskela conducted an excellent literature survey
using CVS and Subversion in the NetBeans IDE are found on SCM in agile methods. The result is reported in [96].
EXERCISES
•
22.1 Describe, with examples, how to use the model in ECP, and what should be included in the ECP for
Figure 22.3 to represent the baselines and the asso- this change?
ciated baseline configuration items in Figure 22.1. b. ECP evaluation board. What is the name of the
Hint: For this exercise, you do not need to construct board or committee that will review and evaluate
the complete model; it is enough to show just how to the ECP? What are the responsibilities of this or-
represent a couple of baselines and a few associated ganizational unit? Who are the possible members
configuration items. of this organizational unit? What are the possible
22.2 Suppose that you work on a project to develop a outcomes of the review and evaluation process,
library information system using the conventional and why?
waterfall process. Define the baselines for the project, c. Post-evaluation. What are the possible actions to
identify and specify the configuration items for the take place after the ECP is reviewed and evaluated,
baselines. taking into account the possible outcomes of the
22.3 Suppose that during the implementation phase of ECP evaluation process?
the library information system project, a fatal de- 22.4 Do the same as in exercise 22.2, except that the
sign flaw is discovered in the architectural design. project uses one of the agile methods presented in
The architectural design must be modified. You are Chapter 2.
required to coordinate this activity. Therefore, you 22.5 Identify all possible software configuration items for
are required to write a proposal that addresses the each of the agile methods described in Chapter 2.
following issues:
a. Engineering change proposal (ECP). What is an
ECP, who should be responsible for writing the
This page intentionally left blank
part VII
Project Management and Software
Security
Chapter 23 Software Project Management 576
Chapter 24 Software Security 606
575
23
Software Project
Management
Software systems are large, complex, intellectual products. Managing software devel-
opment projects is different from managing projects in other engineering disciplines.
This is due to the nature of software and software development. First of all, software
is an intangible product—you cannot really see it, you cannot touch it, and you cannot
accurately and directly measure it, but it exists. These properties make it difficult to
estimate the effort required to develop a software product and measure the progress of
the software project. Second, software development activities are intellectual activi-
ties. Today’s software projects require a large number of software engineers working
in teams. The teams and team members must communicate and collaborate to jointly
carry out the development activities. These create challenges to software project man-
agement, especially in project organization, planning and scheduling of development
activities, assigning work to project teams and team members, and monitoring the
progress.
Effective communication is critical for software development and incurs ex-
tremely high communication overhead. This is because the content being commu-
nicated is intellectual, complex, abstract, and easy to misinterpret. Software project
management has to consider software process and team organization to ensure ef-
fective communication and reduce communication overhead. Software project man-
agement must include risk management because many events could jeopardize the
success of the project. Finally, the development and management processes must be
integrated and continually improving.
Software project management is concerned with the management aspect of soft-
ware engineering to increase software productivity and quality, and reduce software
cost and time to market. This chapter presents software project management concepts
576
Chapter 23 Software Project Management 577
and techniques to ensure that these management goals are accomplished, that is, that
the budget is not overrun, and the product is delivered with the required functionality
and quality, according to the schedule.
The importance of project management cannot be overstated. Two real-world
stories, referred to as the National Health System (NHS) project and the Textile Pro-
cess Control (TPC) project, illustrate this. The NHS project was reported in 2006 and
involved a large IT consulting firm as the developer.1 The developer lost hundreds
of millions of dollars due to cost overruns and the delayed delivery of the software
system to the national health organization of a European country. The company paid
a penalty of approximately $100M. The penalty would have been $500M if the con-
tract had not been taken over by its competitor. The TPC project was about a small
IT consulting company.2 The company won a “death march” project to implement a
system for a textile manufacturer in an eastern U.S. state. The project was a “death
march” project because the analysis and design were carried out by another company.
This means that the implementation team would not have the needed domain knowl-
edge to implement the system. It would be an extremely lucky case if the analysis
and design documents produced by the previous developer could truly communicate
that knowledge. As expected, the implementation team could not deliver the system
by the deadline. The company had to choose between two options—paying a huge
lumpsum penalty to walk away or paying $1M per month until the system is delivered.
These two stories partly reflect poor management decisions. They also illustrate the
importance of good management to the success of a software project. In the following
sections, you will learn the following:
• Project formats and team organization, which deal with the organization of soft-
ware projects and the structuring of project teams.
• Estimation methods, which are needed to obtain estimates of effort, duration, and
costs for project planning and scheduling, and resource allocation that includes
staffing, budgeting, and financial management.
• Software project planning and scheduling, which deal with the scheduling of
development activities, such as when to develop and deliver which use cases, as
well as the assignment of development work to teams and team members.
• Risk management, which deals with the identification, analysis, and resolution
of risk items to ensure the success of the software project.
• Process improvement, a continual and conscious effort to “optimize” the software
processes.
1 http://www.theregister.co.uk/.
2 Private communication.
578 Part VIII Project Management and Software Security
needed in a software project, and factors that affect the project organization. This
section deals with these issues.
1. Specialized teams tend to increase effectiveness and efficiency because the func-
tion teams can be formed by members who are experts in the functional areas.
2. It works well for a distributed development environment in which different func-
tional activities are performed at different locations. For example, analysis and de-
sign are performed close to the customer site, implementation at a less-expensive
location, and testing is carried out elsewhere.
3. It could result in lower development costs because of increased effectiveness and
efficiency, a reduced number of high-paid analysts/architects, and reduced cost
and increased utilization of special equipment such as analysis, design, and test
tools.
Chapter 23 Software Project Management 579
different experiences. However, it is essential that the team members have a mutual
understanding of why you want to do things that way. This mutual understanding al-
lows the team members to work toward a common goal once a decision is made. The
egoless team structure may be less productive if the team is divided. In such cases,
the issues should be resolved as quickly as possible so that the project can move on.
Sometimes, the problem is due to different opinions; in such cases, the team may take
a vote to resolve differences.
the project. If the project has to be completed in six months, then 16 software en-
gineers are required. However, such a compression in a project schedule may result
in project failure or drastically increase project costs. When moving a pile of dirt, a
team can double the workforce to reduce the time by half. However, this is not the
case for creating software. This is because the increase in team size drastically in-
creases the communication and coordination overhead. For example, the overhead is
8 ∗ (8 − 1)/2 = 28 and 16 ∗ (16 − 1)/2 = 120 for 8 and 16 persons, respectively.
That is, the effort to communicate and coordinate increases substantially.
of the function point method are that it is considered subjective by some authors,
and for some projects the category counts may not be easy to obtain in an early
development stage.
1. Count the number of screens, reports, and 3GL components that will comprise
the application.3
2. Determine the complexity levels of each of the screens and reports using Fig-
ure 23.2(a).
3. Look up the complexity weights for each of the screens, reports, and 3GL com-
ponents from Figure 23.2(b).
4. Add the weighted counts of screens, reports and 3GL components to produce
one number, called the Object Point (OP) count.
5. Estimate the percentage of reuse to be achieved, and compute the New Object
Points (NOPs) to be developed in the project:
6. Determine the object point productivity from Figure 23.2(c), that is, the average
of two capabilities shown in Figure 23.2(c).
7. Compute the person-month effort: Effort PM = NOP/PROD
•
The planning phase of a project needs to prototype a part of the system. The EXAMPLE 23.2
prototype requires four screens, three reports, and no 3GL component. Each
∨ screen has one view and accesses to one server data table. The first report has
3 3GL stands for “third-generation programming languages,” which include high-level programming
languages such as C, C++, C#, and Java.
584 Part VIII Project Management and Software Security
Complexity Weight
Object Type
Simple Medium Difficult
Screen 1 2 3
Report 2 5 8
3GL Component 10
where a = 2.94 is a constant, b is computed using five project specific scale factors
(SFs), si ze is the estimated software system size in thousand source lines of code
or KSLOC, n = 7 denotes the number of effort modifiers, and E Mi are the effort
modifiers. The following describes how to obtain these input parameters.
Estimate Software Size The software size in thousand source lines of code (KSLOC)
can be estimated in two different ways: direct estimation or using function points. The
approach that uses function points is described here. First, count each of the function
types as follows:
• External inputs. Count each unique user data or control input type that updates
an internal file.
• External outputs. Count each unique user data or control output type that leaves
the software system.
• Internal logical files. Count each major group of user data or control informa-
tion in the system including files that are generated, used, or maintained by the
software system.
• External interface files or interfaces. Count files passed or shared between soft-
ware systems.
• External queries. Count unique external queries that produce an immediate
output.
For each of the counted items, determine the complexity level and then the
weighted function points from Figure 23.3. Sum up the weighted function points for
Complexity Weight
Function Type
Low Average High
Internal Logical 7 10 15
External Interfaces 5 7 10
External Inputs 3 4 6
External Outputs 4 5 7
External Queries 3 4 6
all of the counted items to produce an unadjusted function point (UFP) value. Convert
the unadjusted function points to thousand lines of source code or KSLOC as follows.
First, look up a mapping table to determine the SLOC per UFP for the implementation
language. The SLOC per UFP values are: Ada 71, APL 32, C 128, C++ 55, ANSI
Cobol 85 91, Fortran 77 107, HTML 15, Java 53, Lisp 64, Modula 2 80, Pascal 91,
PERL 27, Prolog 64, Spreadsheet 6, Unix Shell Scripts 107, Visual Basic 5.0 29,
Visual C++ 34. Next, multiply the looked up value and the UFP value and divide the
result by 1000 to produce the KSLOC.
Adjust Size for Requirements Volatility Requirements change could result in code that
is developed but not delivered. If the discarded amount of code is not negligible, then
it must be added to the estimated software size to adjust for requirements change.
Calculate Constant b The constant b takes into account five project and development
team factors, called scale factors (SF), which can be looked up from Figure 23.4.
The constant b is then computed using the following formula:
b = 0.91 + 0.01 × (SF1 + · · · + SF5)
Cost Drivers for the Early Design Model There are seven cost drivers for the early design
model. Their meanings and ranges of values are described below. The modifier values
are listed in the order for Extra-Low, Very-Low, Low, Nominal, High, Very-High,
Extra-High.
1. Personnel Capability (PERS). This reflects the analyst capability, programmer
capability, and personnel continuity of the project team. The values are: 2.12,
1.62, 1.26, 1.00, 0.83, 0.63, 0.50.
2. Product Reliability and Complexity (RCPX). This is concerned with the require-
ments on software reliability and life cycle–related documentation. Also consid-
ered is the complexity of the software and the size of the database. The values
are: 0.49, 0.60, 0.83, 1.00, 1.33, 1.91, 2.72.
3. Developed for Reusability (RUSE). This is concerned with whether components
of the software system must be developed with reuse in mind. The values are:
n/a, n/a, 0.95, 1.00, 1.07, 1.15, 1.24.
4. Platform Difficulty (PDIF). This is concerned with execution time and main
memory constraints as well as platform volatility. The values are: n/a, n/a, 0.87,
1.00, 1.29, 1.81, 2.61.
Chapter 23 Software Project Management 587
5. Personnel Experience (PREX). This is concerned with experiences with the ap-
plication, programming languages, tools, and platform. The values are: 1.59,
1.33, 1.22, 1.00, 0.87, 0.74, 0.62.
6. Facilities (FCIL). This is concerned with the use of software tools and multisite
development. The values are: 1.43, 1.30, 1.10, 1.0, 0.87, 0.73, 0.62.
7. Required Development Schedule (SCED). This is concerned with flexibility
of development schedule expansion. The values are: n/a, 1.43, 1.14, 1.00, 1.00,
1.00, n/a.
Account for Effort to Reuse Components Effort is required to handle reusable com-
ponents. This effort should be added to the computed effort estimate PM. The reuse
effort could be computed by estimating the reused KSLOC less the amount of such
code that is automatically generated, and divide the result by the productivity to adapt
reused code.
Driver Description VL L N H VH XH
RELY Required Software Reliability 0.82 0.92 1.00 1.10 1.26 —
DATA Database Size — 0.90 1.00 1.14 1.28 —
CPLX Product Complexity 0.73 0.87 1.00 1.17 1.34 1.74
RUSE Developed for Reusability — 0.95 1.00 1.07 1.15 1.24
DOCU Documentation Match to Life-Cycle Needs 0.81 0.91 1.00 1.11 1.23 —
TIME Execution Time Constraint — — 1.00 1.11 1.29 1.63
STOR Main Storage Constraint — — 1.00 1.05 1.17 1.46
PVOL Platform Volatility — 0.87 1.00 1.15 1.30 —
ACAP Analyst Capability 1.42 1.19 1.00 0.85 0.71 —
PCAP Programmer Capability 1.34 1.15 1.00 0.88 0.76 —
PCON Personnel Continuity 1.29 1.12 1.00 0.90 0.81 —
APEX Application Experience 1.22 1.10 1.00 0.88 0.81 —
PLEX Platform Experience 1.19 1.09 1.00 0.91 0.85 —
LTEX Language and Tool Experience 1.20 1.09 1.00 0.91 0.84 —
TOOL Use of Software Tools 1.17 1.09 1.00 0.90 0.78 —
SITE Multisites Development 1.22 1.09 1.00 0.93 0.86 0.80
SCED Required Development Schedule 1.43 1.14 1.00 1.00 1.00 —
Legend: VL=very low, L=low, N=neutral, H=high, VH=very high, XH=extra high
3. Ask the experts to estimate independently the efforts required by the system and
its components.
4. Ask the experts to present their estimates and the rationale behind the estimation.
5. Repeat the last two steps until a consensus estimation is reached.
The estimation may be improved by requiring the experts to produce pessimistic
most likely, and optimistic estimates, denoted E p , E m , and E o , respectively. The
expected effort is then derived by the following formula:
Expected Effort E = ( E p + 4 × E m + E o )/6
Cohn suggests programmers estimate size with story points. A story point is a
unit of measurement for expressing the overall size of a user story, feature, use case,
or a piece of work. For example, a small, easy-to-implement use case is given 1
point, while a use case that is twice the size is given 2 points, and so forth. Used as
a measurement, it is similar to a function point. However, it differs in the process to
obtain the estimate. It relies on consensus of an overall estimate rather than a value
that is computed from a number of parameters. In this regard, it works more like
the Delphi estimation method. The planning poker game, described in [51], is one of
the best techniques for agile estimation. It combines expert opinion (such as Delphi
method), analogy, and divide-and-conquer into a fun process that results in quick and
reliable estimates.
The participants of the planning poker game include all of the developers on the
team—i.e., analysts, architects, programmers, testers, and database designers, and
more. The participants are aware that, beyond a certain point, additional estimation
effort yields very little value in terms of the accuracy of the estimate. The game
requires prior preparation of a deck of cards for each participant. Each card in a deck
has a valid story point written on it and it is big enough to be seen across the table in
the meeting room. The cards may read 0, 1, 2, 3, 5, 8, 13, 20, 40, etc.—the Fibonacci
numbers. The use of the Fibonacci numbers is based on the belief that the larger the
size, the lower the accuracy of the estimate. The Fibonacci numbers provide room for
possible errors. For example, if a use case is estimated to be twice the size of another
use case that is estimated to be 2 points, then the size for the former is not 4 points
but 5 points. The extra point is included to accommodate for possible errors in the
estimation. Instead of Fibonacci numbers, the team can use a sequence of integers
such that each is twice the previous one, for example, 1, 2, 4, 8, 16, . . . , or simply the
natural numbers if so desired.
The planning poker game iterates the following steps:
1. At the start of the game, each participant is given a deck of cards. The participants
are reminded that the goal is to obtain a good-enough estimate quickly but not to
pursue an accurate estimate that will withstand all future scrutiny.
2. For each piece of work, such as a use case, to be estimated, the moderator reads the
description and the product owner answers all questions concerning the product.
The participants then perform the following three steps.
3. Each participant privately selects a card that represents his or her estimate. When
all the participants finish the selection, they turn over their cards simultaneously
so that all participants see all the estimates.
4. If the estimates differ significantly, then the participants that give the high and low
estimates are asked to explain the rationale behind their estimates. If desired, the
participants exchange their understanding of the story and discuss their estimates
for a while.
5. The group repeats the last two steps until a consensus estimate is obtained. Some-
times, the discrepancies in the estimates are small and the moderator could ask
the participants with the lower estimates if they are OK with the other estimates
to resolve the discrepancies to quickly converge the estimates.
Chapter 23 Software Project Management 591
Two issues should be addressed when using the story point approach. The first
issue is how to estimate a large size of work. The answer is divide-and-conquer, a
well-known technique for solving large, complex problems. In this case, the piece
of work or the use case is decomposed into a number of smaller pieces of work.
Estimates are obtained for the smaller pieces of work. These estimates are then used
to derive an estimate for the large piece of work.
The second issue is when to reestimate. The advantage of using a story point
is that it is a relative concept, that is, the story points of a story are relative to the
estimates of other similar or reference stories. This means that reestimation of a story
is needed only when the size of a reference story is revised up or down due to any
reason.
Figure 23.6(a) shows a PERT chart for a hypothetic project, where m0, m1, . . . ,
m5 are the milestones and T1 = 2, T2 = 1, . . . , T7 = 1 are the tasks and their durations
in days, weeks, or months. m0 and m5 are the project start and project completion
milestones. The PERT chart shows that m2 is established when task 1 is completed.
The establishment of m2 allows task 3 and task 4 to start. Unlike m2, the establishment
of m4 requires the completion of both task 4 and task 5.
PERT charts are widely used to produce project schedules and identify a project’s
critical path, which is the path with the longest total duration from the project start
to the project completion. That is, it defines the total time required to complete the
project. Any delay along the critical path will delay the completion of the project.
592 Part VIII Project Management and Software Security
m2 m4 TE = 2 m2 1/17/201 2/7/2011 m4 TE = 5
TL = 2 TL = 5
T4 = 3 T4 = 3
1/3/2011 T3 = 1 m3
T3 = 1 m3 T5 = 1 T1 = 2 T5 = 1
T1 = 2 T7 = 1 m0 T7 = 1
m0 TE = 3
T2 = 1 T2 = 1 1/24/201
TE = 0 TL = 4
TL = 0
m5 T6 = 3 TE = 6 m5
T6 = 3 m1 TE = 1
m1 TL = 6 2/14/201
1/10/201 TL = 3
(a) A PERT chart (b) Project schedule and critical path
To produce a project schedule and identify the critical path, the following items
are computed:
1. The earliest start time of each milestone m, denoted TE(m), is the earliest time
that the milestone can be established. It is calculated as follows:
TE(m0) = 0
TE(mi) = the longest total duration from m0 to mi
In Figure 23.6(b), the longest total duration from m0 to m3 is 3, from m0 to m5
is 6. Therefore, TE(m3) = 3, TE(m5) = 6.
2. The latest completion time of each milestone m, denoted TL(m), is the latest time
that the milestone must be reached in order to meet the scheduled project com-
pletion date. It is computed as follows, where mn denotes the project completion
milestone:
TL(mn) = TE(mn)
TL(mi) = TE(mn) − the longest total duration from mi to mn
In Figure 23.6(b), TL(m5) = TE(m5)=6, because m5 is the sink. The longest
total duration from m3 to m5 is 2 and the longest total duration from m2 to m5 is
4. Therefore, TL(m3) = TL(m5) − 2 = 6 − 2 = 4 and TL(m2) = TL(m5) − 4 =
6 − 4 = 2.
3. The critical path, which consists of the project start milestone along with every
milestone that has identical earliest start time and latest completion time, that is,
for all milestone m on the critical path, TE(m) = TL(m). In Figure 23.6(b), the
critical path consists of the directed edges (m0, m2, T1), (m2, m4, T4), and (m4,
m5, T7), as highlighted in the figure.
4. Specifying the earliest start date for each of the milestones, as shown in Fig-
ure 23.6(b).
The PERT chart in Figure 23.6(b) shows that two milestones—m 1 and m 3 —
are not on the critical path. Their earliest start time and latest completion time are
different. More specifically, their latest completion time is greater than their earliest
start time. The difference is called the elapsed time, which is the amount of time
Chapter 23 Software Project Management 593
m0 m1 m2 m3 m4 m5
T1
T2
T3 task on the critical path
T4
T5 tasks with an elapsed time
T6
T7
that the milestone can be delayed without delaying the project completion time. It
allows the project manager to adjust the schedule of the task according to project
conditions.
1. Draw a rectangle and mark the project milestones and their calendar dates chrono-
logically along the horizontal axis. Add vertical guidelines to facilitate the reading
of the milestones and calendar dates.
2. For each task, depict a horizontal bar from the source milestone of the task to the
destination milestone of the task. Color the bars for the tasks on the critical path
with a distinctive color. This step produces T1, T4, and T7 in Figure 23.7.
594 Part VIII Project Management and Software Security
m0 m1 m2 m3 m4 m5
T1
David T3
T5
T2
Maggy
T6
T4
Chen
T7
3. Color the initial portions of the remaining bars to indicate the durations of the
noncritical tasks. Use the same color or fill pattern to indicate the dependence
of one task on another. For example, Figure 23.7 fills T2 and T6 with the same
pattern to indicate that the start time of T6 depends on the completion time of T2.
4. If the destination milestone of a noncritical task has an elapsed time, then extend
the bar proportionally to show the elapsed time. This step extends T2 with an
elapsed time of two weeks in Figure 23.7.
The Gantt chart facilitates the allocation of the tasks to the developers. For the
Gantt chart in Figure 23.7, assume that the task duration is equal to the task effort
in person-weeks. Under this assumption, the total effort for the project is 12 person-
weeks. Assume further that the team has three members: Chen, David, and Maggie.
If the effort is to be equally divided among the team members, then each of them
should be assigned four person-weeks of work. Figure 23.8 shows an allocation of
the tasks to the members with a Gantt chart. Of course, in practice, the assignment of
tasks to the team members must also consider the allocation of the tasks to match the
expertise of the team members.
As shown in Figure 23.8, T1, T3, and T5 are assigned to David, T2 and T6 are
assigned to Maggie, and T4 and T7 are assigned to Chen. Each of these members
is assigned four person-weeks of work. David must complete T1 in two weeks;
otherwise, the project completion time will be delayed. However, he has one week
elapsed time for completing T3 and T5, as indicated by the one week elapsed time
for these two tasks. Similarly, Maggie has two weeks elapsed time. Chen, however,
has to complete T4 and T7 on schedule.
Iteration1, 3 wks Iteration 2, 3 wks Iteration 3, 3 wks Iteration 4, 3 wks Iteration 5, 4 wks
9/15/08–10/3/08 10/6/08–10/24/08 10/27/08–11/14/08 11/17/08–12/5/08 12/8/08–1/15/09
UC1: Do One UC3: Do Three UC2: Do Two UC5: Do Five UC6: Do Six
points: 5 points: 2 points: 4 points: 3 points: 6
priority: 1 priority: 1 priority: 4 priority: 4 priority: 5
depends on: None dep. on: UC9, UC1 depends on: UC8 depends on: UC4 depends on: UC4
UC9: Do Nine UC4: Do Four UC8: Do Eight UC7: Do Seven UC10: Do Ten
points: 4 points: 5 points: 5 points: 5 points: 6
priority: 2 priority: 2 priority: 3 priority: 4 priority: 3
depends on: None depends on: UC3 depends on: None depends on: UC2 dep. on: UC5, UC7
Assumptions: (1) The team can produce 3 points of work per week. (2) Priorities are ranked from 1 to 5 with
1 being the highest.
plan can be produced quickly and easily by arranging the cards or Post-it notes in
a conceptual grid. The columns represent the assignment of stories to the iterations.
Figure 23.9 illustrates the use of Post-it notes to plan the deliveries of the use cases
for a hypothetic agile project, where the iterations and durations are displayed at the
top of the grid. The points measure the required effort to develop the use cases. It is
assumed that the team can produce three points of work per week. This agile planning
technique is associated with the following merits:
1. It is easy to ensure that high-priority use cases are developed and deployed early.
2. It is easy to ensure that the dependencies between the use cases are satisfied. For
example, in Figure 23.9, UC1 and UC9 are assigned to iteration 1 and UC3 is
assigned to iteration 2 because UC3 depends on UC1 and UC9, although UC9
has a lower priority than UC3.
3. It is easy to ensure that the sum of the points in each column is not greater than
the team “velocity,” which is the amount of work or points that the team can
complete in one iteration.
1. Identify the options and all possible outcomes for each option. Identify also the
loss probability and loss magnitude for each of the outcomes. The sum of the
loss probabilities for each option should be one.
2. Do the following for each option that is identified:
a. Expand the root with a new branch and label it with the name of the option.
For the example described above, this expands the root with two branches,
labeled “Design for Change” and “Direct DB Access,” respectively.
b. For each possible outcome of the option, do the following:
i. Expand the tip of the option with a new branch and label it with the name
of the outcome, the loss probability, and the loss magnitude.
598 Part VIII Project Management and Software Security
Combined
Risk Exposure Risk Exposure
Replace DB
$160 K $32 K
prob = 0.20
Design for $152 K
prob = 0.80
Change $150 K
Not replace DB $120 K
Replace DB $500 K
$2.5 M
Direct DB prob = 0.20
Access $500 K
prob = 0.80
$0 $0
Not replace DB
Combined
Possible Loss Loss Risk
# Option Risk
Outcome Probability Magnitude Exposure
Exposure
Design for Replace DB 20% $160,000 $32,000
1 Change $152,000
Not replace DB 80% $150,000 $120,000
Direct DB Replace DB 20% $2,500,000 $500,000
2 Access $500,000
Not replace DB 80% $0 $0
The expected estimates are then used as the input parameters in the decision tree or de-
cision table. The pessimistic, most likely, and optimistic estimates of loss probabilities
and loss magnitudes may be obtained using the Delphi estimation method, described
in Section 23.2.3, or the agile estimation method described in Section 23.2.4.
The risks are ranked according to their effects and combined risk exposures.
Generally speaking, catastrophic risks and risks with a high combined risk expo-
sure are high-priority risks. Expert opinion, project management experiences, and
brainstorming are useful in assigning priorities to the risks.
weaknesses of the process and the analysis result should be used to improve the pro-
cess. The Capability Maturity Model Integration (CMMI) and the ISO 9000 Standards
are widely used in process improvement. This section briefly describes the CMMI.
The CMMI was originally developed by the Software Engineering Institute (SEI)
to assist the U.S. Department of Defense (DoD) to assess the performance of the
defense contractors. During the years, the CMMI has expanded its acceptance beyond
the defense industry; currently, it is widely used by many software development
organizations. The CMMI defines five levels of software capability maturity. As shown
in Figure 23.12, each level has a number of key process areas that an organization
should focus on to improve its software process. Each key process area is further
decomposed into key practices and subpractices, which are omitted to conserve space.
The assessment of an organization’s software process begins with an on-site visit
by a team of software professionals, who examine several representative projects
provided by the organization. On the first day, survey questionnaires are distributed
and the responses to the survey are analyzed, resulting in an initial set of issues. On
the second day, the team interviews the project leaders to clarify the initial set of
issues and request explanatory materials. The team then refines the findings. On the
third day, the team discusses the findings with representatives of each functional area.
The team then finalizes the findings and prepares the briefing, which is given on the
fourth day. The final report that gives the recommendations for improvement is sent
Chapter 23 Software Project Management 601
to the organization about two months after the on-site assessment. Items that require
immediate actions are given the highest priority. The CMMI model has a number of
merits:
• It reflects the actual process improvement practices. For example, studies show
that the delivered defect densities or delivered defects per 1,000 lines of code for
CMMI level 1 to level 5 are 7.5, 6.24, 4.73, 2.28, and 1.05, respectively.
• For each level, it clearly defines the improvement goals and progress measures.
• The five maturity levels define a logical roadmap toward an optimizing process.
The improvement from one level to the next higher level can usually be achieved
in two years.
• The recommendation provides improvement priorities.
Agile development requires active involvement of the users because this is re-
quired to solve a wicked problem. However, in today’s competitive work environment,
the users won’t have the time and effort to do so. One solution is that the customer
assigns a dedicated, experienced user representative to the project. This means extra
602 Part VIII Project Management and Software Security
costs to the customer. If the customer does not collaborate, for example, does not
assign such a person or ask the person to do this as a volunteer work, then even if the
team wins the contract, the agile project may not be able to succeed.
GUIDELINE 23.4 Agile development values individuals and interactions over pro-
cesses and tools.
For software, documentation is important, but it is not the silver bullet. After all,
the team has to design, implement, and deliver the software that works in the target
environment. Moreover, software development is a wicked problem. This implies
that the real requirements and the desired design cannot be completely and definitely
specified prior to implementing the code. The iterative nature of agile processes is
part of the solution to tackling these problems. This leads to the next principle.
Agile development suggests “barely enough modeling, but no more.” This means
performing modeling and design to the extent that is sufficient for the team to move
on. That is, the extent that clarifies the doubt and establishes a common understanding
among the team members of what needs to be implemented, and how.
SUMMARY
•
This chapter presents the basic functions of software chart. This chapter also presents agile estimation and
project management. The project organizations in- agile planning. Project risk management involves risk
clude project-based, function-based, and hybrid or- identification, analysis, resolution, and monitoring.
ganizations. The team structures include the ego- Finally, the chapter presents the CMMI model for pro-
less team structure, chief programmer team struc- cess improvement. Knowledge of these project man-
ture, and hierarchical team structure. Conventional agement functions enables the project manager to plan
effort-estimation methods include the function point and schedule the development activities according to
estimation method, COCOMO II method, and Del- the project milestones to deliver the use cases and
phi method. The conventional project planning and subsystems.
scheduling methods are the PERT chart and Gantt
FURTHER READING
•
The COCOMO II estimation method is described in [34] ods are found in [12, 145]. A comparison between ISO 9001
while the agile estimation and planning methods are found and the CMMI is given in [121]. Finally, reference [19] de-
in [51]. For more on project risk management see [33, 120]. scribes approaches and guidelines for planning and tracking
The CMMI and its use in process improvement are described an XP project.
in [79, 127]. Discussions that relate CMMI to agile meth-
604 Part VIII Project Management and Software Security
EXERCISES
•
23.1 Discuss in a brief article the pros and cons of the ous fields. The OIE staff clicks the Submit button
different team structures presented in this chapter. to save the program.
Discuss also their pros and cons with respect to agile d. When the Submit button is clicked, the system
projects. saves the program into a database and displays a
23.2 Apply the COCOMO II Application Composite “program is successfully saved” message.
Model described in Section 23.2.2 to estimate the 23.3 Make proper assumptions for the missing informa-
effort required to develop the Add Program use case tion in the Add Program use case description pro-
for a Study Abroad web application for the Office vided in the previous exercise and apply the function
of International Education (OIE) of a university. As- point method to estimate the required effort. Justify
sume that the object point productivity is nominal your assumptions and effort estimate.
and no reuse of existing components is expected. 23.4 Apply COCOMO II Early Design Model to estimate
The Add Program use case allows an OIE staff to the effort required to develop the following use cases
add an overseas exchange program, such as French for the Study Abroad web application. Make nec-
Language and Culture. This use case needs to display essary assumptions including the number of inputs,
three web pages and a message as follows: outputs, and the scale factors, cost drivers and the
a. Initially, it displays a Welcome page, which con- like. For example, you can assume average/nominal
sists of three frames. The main frame shows a de- levels for all of the scale factors.
scription of the Study Abroad program. The top a. UC01. Search for Programs (Actor: Web User,
frame shows the OIE logo along with a row of System: SAMS)
buttons, such as OIE Home, About Study Abroad This use case allows a user to search overseas ex-
program, Contact Us, etc. The left frame shows change programs using a variety of search criteria
a list of three menu items: Program Management, such as subject, semester, year, country and region.
User Management, and System Settings. The Wel- The system searches the database and displays a
come page is displayed after an OIE staff member list of programs, each of which includes a link to
successfully logs into the system. display the detail of the program.
b. To add a program, the OIE staff clicks the Pro- b. UC02. Display Program Detail (Actor: Web User,
gram Management item, which expands the item System: SAMS)
and shows a list of four menu items under the This use case retrieves and displays the detailed
expanded item—Add Program, Update Program, description of a program, selected by clicking the
Delete Program, and Import Programs. link of the program displayed by the Search for
c. The OIE staff clicks the Add Program item. The Programs use case, or by giving the program ID or
system displays an Add Program Form in the main program name.
frame of the page. The Add Program Form lets the c. UC03. Submit Online Application (Actor: Student,
OIE staff enter program information into the vari- System: SAMS)
Chapter 23 Software Project Management 605
This use case allows a student to apply to an over- approve course equivalency forms submitted by
seas exchange program. The student fills in an ap- students when they submit their online applica-
plication form and submits it. The system verifies tions. Each form specifies the overseas courses that
the application, saves it in the database, and sets the the student plans to use to substitute for the courses
status of the application to “submitted.” The sys- of the academic department.
tem also sends e-mail to the two faculty members 23.5 Base on the estimates produced in the previous exer-
requested by the student to write recommendation cise, perform the following:
letters, and the academic adviser to approve the a. Identify the dependencies among the nine use
course equivalency form. cases for the Study Abroad application.
d. UC04. Login (Actor: Student, System: SAMS) b. Assume that the team cannot work on a use case
This use case allows a registered student to login until the use cases that it depends on are completed.
to the system. Assume that the completion of a use case marks
e. UC05. Logout (Actor: Student, System: SAMS) a milestone. Produce a PERT chart schedule for
This use case allows a student to logout from the developing the use cases.
system. c. Compute the earliest start time and latest comple-
f. UC06. Edit Online Application (Actor: Student, tion time for each of the milestones.
System: SAMS) d. Identify the critical path for the project.
This use case allows the student to edit an applica- e. Select a calendar date for the project start and fill
tion that is not yet submitted. in the calendar dates for the milestones.
g. UC07. Check Application Status (Actor: Student, 23.6 Form a group of five students and practice agile esti-
System: SAMS) mation and planning for the 9 use cases of the Study
This use case allows a student to check the status of Abroad application. Produce a brief report describing
an application, such as in-preparation, submitted, the process and the results obtained.
under-review, accepted, and rejected.
23.7 Identify top five possible risks for the SAMS project
h. UC08. Submit Recommendation (Actor: Faculty,
and develop risk resolution measures for them.
System: SAMS)
Briefly justify your solution.
This use case lets a faculty member submit a rec-
ommendation on behalf of a student. The system 23.8 Suppose that a company is at level 1 of the
saves the recommendation in the database. CMMI. Propose a process improvement plan for
i. UC09. Approve Course Equivalency Form (Actor: the company to improve its process to level 5.
Advisor, System: SAMS) Make necessary assumptions about the level-1
This use case lets an academic adviser review and company.
24
Software Security
Computer system security has become a serious concern in recent years. As shown in
Figure 24.1, the number of security vulnerabilities reported to the Computer Emer-
gency Response Team Coordination Center (CERT/CC) has increased significantly
during the last three decades. Several factors that contribute to this include an in-
crease in system complexity, connectivity, and expansion of computer applications to
all sectors of our society. Increasing complexity makes it more difficult to detect soft-
ware design flaws and implementation bugs; these are often exploited by attackers to
engineer attacks. Connectivity makes it possible for an attacker to access a computer
system remotely. Finally, the expansion of computer applications attracts adversaries
due to financial incentives. Although computer security problems already appeared
in the 1980s, active R&D in computer security did not begin until 10 or 15 years ago.
Books and other publications that provide an in-depth treatment of software security
are rare and occur only recently [114, 156].
Computer security covers a wide spectrum of areas and topics, including cryptog-
raphy, security protocols, authentication and authorization, access control, intrusion
detection, virus and malware, privacy, and software security, to mention a few. Some
of these deserve a book or two of their own. The focus of this chapter is software
security or “building secure software,” that is, life-cycle activities that aim to produce
more secure application software.
As pointed out by McGraw [114], current approaches to application security
are reactive approaches—security is primarily based on finding and fixing known
security problems. Software security is a proactive approach—start tackling the se-
curity problems from day one and continue throughout the entire software life cycle.
Unfortunately, research in software security is still in its infant stage. Processes,
methodologies, and techniques for the analysis and design of secure software have
just begun to appear. Therefore, the materials presented in this chapter are expected
606
Chapter 24 Software Security 607
9000
8000
7000
6000
5000
4000
3000
2000
1000
0
1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008
345 311 262 417 1090 2437 4129 3784 3780 5990 8064 7236 6058
to evolve during the next several years. Upon completing this chapter, the student
should understand the following:
• Basic concepts of software security.
• Importance of software security.
• Security attacks and defenses.
• Security requirements.
• Secure software design principles.
• Security patterns.
• Life-cycle activities for building secure software.
1. Modeling and analysis for security. Modeling and analysis are performed in the
early stage of the software project. The development team constructs models that
show the resources that need protection and entities that access the resources.
Such models help the development team identify, formulate, and validate the
security requirements.
608 Part VIII Project Management and Software Security
2. Design for security. Design for security is performed during the architectural
design and behavioral design phases. It applies security patterns and security
design principles to ensure that the security requirements are satisfied. It also
takes into account anticipated change of the security requirements.
3. Secure coding. Secure coding applies security principles and security patterns to
produce secure code during the implementation phase.
4. Test for security. Test for security aims to detecting security vulnerabilities in the
software. Conventional functional testing ensures that the software is correct with
respect to the functional requirements. Security testing ensures that the software
does not contain loopholes that attackers can explore to compromise the security
of the system. It applies static as well as dynamic security-testing techniques to
detect such vulnerabilities.
Description, Participants,
Name Intent/Problem Solved Remarks
Responsibilities, & Interaction
Privilege How does one compartmentalize A System consists of Mutually Distrustful Also called
Reduction (A) a system? Decompose the system Components that require different access Distrustful
into mutually distrustful privileges. Decomposition.
components.
Privilege To be reluctant to trust, and Using/introducing a Least Privilege Module to A special instance
Separation (A) practice least privilege. decouple a Privilege-Elevated Module from an of Privilege
External Source. Reduction.
Defer to Kernel Prevent privilege elevation A Client sends requests to a Server, which It is a specialization
(A) attacks through Privilege invokes functions of the Kernel to carry out of Privilege
Separation and use of kernel operations that require elevated privileges. Reduction.
functions.
Single Access Provide only one entry to a A Single Access Point serves as the only entry May delegate
Point (A) system to facilitate user into the system. It collects and validates user validation to Check
validation. information, and launches appropriate Point.
functions/applications.
Check Point (A) How does one organize checking A Check Point uses Security Policy subclasses Security Policy may
of security policies and execution to check security policies and calls functions of be implemented as
of countermeasures? Countermeasure in case of an attack. Strategy.
Secure Access How does one interact with the An Application communicates through a May use security
Layer (A) security mechanism of an Secure Access Layer, which communicates mechanisms
external system? Use or with an External System through a Lower provided by the OS,
implement a secure access Level Security Mechanism. network, or DBMS.
layer to interact.
Secure Pipe (I) How does one secure the An Application creates a Secure Pipe at the
connection between the client system level to communicate with its client or
and the server, or between partners. The Secure Pipe is an encrypted
servers that require mutual communication channel that provides the
authentication, confidentiality, required security functionality such as mutual
or non-repudiation? authentication, integrity, and privacy.
Roles/RBAC (D) How does one structure and A Principal (such as actor/process) is associated Multilevel RBAC
manage role-based access with a Role, which has access privileges to supports
control? Resource. hierarchical Role
and Resource.
Session (I) Multiple subjects want to share Create a globally accessible container, called a
information but don’t want to Session object, to hold the shared variables.
interact with each other. The subjects access the shared variables stored
in the Session object.
Input Validation An instance of a Check Point at the implementation level.
(I)
Secure Logger How does one protect system An Application writes to a Secure Logger,
(I) log data from unauthorized which protects the log data. A Log Viewer
access? reads the protected log and displays the log
data.
Legend: (A)=Architectural Level, (D)=Design Level, (I)=Implementation Level
Secure
<<Defer to Kernel>>
Logger Login Controller university
Authentication
authentication server
uses relationship
to trust. For example, a buffer overflow attack could be prevented if the code in-
cludes checks to ensure that the input size is less than the buffer size.
Architectural risk analysis, performed during the requirements, architectural
design, and testing and integration phases, is aimed at identifying design flaws in
the architecture and the design class diagram. Problems to be detected by archi-
tectural risk analysis include poor compartmentalization, inadequate protection
of critical assets, failure to authenticate clients, or failure to control role-based
access to resources.
Penetration testing, performed during the deployment and field operation
phases, is aimed at finding architectural design flaws in the fielded environ-
ment. As such, the generation of penetration test cases should be guided by
architectural risk analysis and focus on detecting security problems relating to
the configuration and environmental factors.
Risk based security testing, performed during the unit testing and system test-
ing phases, is aimed at ensuring that the security functionality, such as authenti-
cation and authorization, is correct and adequate, and the security tests derived
from attack patterns and risk analysis results achieve the desired coverage.
Misuse cases, identified during the requirements phase and used throughout the
life cycle, specify attack scenarios. Modeling and analysis of misuse cases help
the developer gain insight into potential security problems. This knowledge is
valuable to architectural design, behavioral design, and security testing.
Security requirements, identified and formulated in the planning phase and
evolve throughout the iterative development life cycle, specify the required pro-
tection to valuable assets. Security requirements promote the importance of se-
curity to the requirement level and form the basis for subsequent design, imple-
mentation, testing, and deployment activities.
Security operation, performed during the system operation phase, is aimed at
setting up, monitoring, and understanding the behavior of the system that leads
to successful attacks. This understanding provides valuable knowledge for en-
hancing the security of the software system.
activities. Secure software design principles and security patterns are applied to pro-
duce a preliminary software architecture.
During the iterative phase, changes to functional as well as security requirements
are considered at the beginning of each increment, based on the feedback from the
users. Changes to functional requirements may lead to changes to the security require-
ments and misuse cases, and possibly the software architecture. On the other hand,
changes to security requirements may introduce additional functional requirements.
Domain modeling should capture security-related domain concepts and relationships,
for example, roles and resources accessed by the roles as well as related access
privileges.
Design for security is an important consideration during actor-system interac-
tion modeling, behavioral modeling, responsibility assignment, and deriving design
class diagrams. That is, these design activities should consider security risks and
countermeasures to defend the system and its valuable resources. During test-driven
development, integration and deployment, security requirements and misuse cases
are used to generate test cases. Code review and inspection as well as static analysis
tools are applied to detect security vulnerabilities.
a software system shall accomplish these goals are specified as software security
requirements. The derivation of security requirements should be carried out jointly
with the customer and users as well as security personnel. The information-collection
techniques described in Chapter 4 (Software Requirements Elicitation) can be ap-
plied during this process. The objective is to identify: (1) valuable assets that need
protection, (2) which roles need what access privileges to which assets and for how
long, (3) potential threats to the assets, (4) required countermeasures to possible at-
tacks, and (5) recovery capabilities in cases of a successful attack. Domain modeling,
described in Chapter 5, may be applied to capture security-related domain concepts
and relationships if desired.
The use case diagrams produced during the planning phase are a good place to
start. Use case diagrams depict the business processes, actors, and the subsystems
that encompass the business processes. The business processes and subsystems are
valuable business assets. In addition, the data or information resources that are ac-
cessed or processed by the business processes can be identified or inferred from the
verb-noun phrases that label the use cases. For example, from the Reset Password use
case one can identify passwords as a valuable data asset or information resource that
needs to be protected.
The actors and their associations to use cases shown in the use case diagrams
specify which roles need access to which business processes. Moreover, from this
and the data that are accessed or processed by the business processes, one can derive
role to resource access privileges.
The actors shown in a use case diagram represent either outside sources or insid-
ers. The CSI/FBI surveys indicate that insider misuses represent about 40%–60% of
the security incidents reported during the last several years. Some other statistics show
that 70%–80% of all computer-related frauds are committed by insiders [95]. Insiders
have direct physical access to the computer and network, and know the resource ac-
cess controls. Insiders may misuse access privileges or view sensitive data that travel
the network. Separation of duties, least privilege, and individual accountability are
the countermeasures to these insider attacks [95].
The potential threats are identified by examining a list of attacks (or attack
patterns) to determine which attacks could happen to which assets. Alternatively,
the potential threats can also be identified with STRIDE, which stands for Spoof-
ing, Tampering-with-Data, Repudiation, Information Disclosure, Denial-of-Service,
and Elevation-of-Privilege attacks. That is, one analyzes the assets to identify which
STRIDE attacks are possible.
It should be noted that the protection against each potential threat could in-
volve a cost. Therefore, it is necessary to conduct a cost-benefit analysis to identify
and prioritize the needed protections. To accomplish this, threats that could cause
significant damages are identified. The costs of damages, the costs to repair the dam-
ages, the costs to recover from such damages, and the probabilities of occurrences
of such threats are estimated. Techniques to accomplish these tasks include brain-
storming, survey, and the Delphi method described in Chapter 23 (Software Project
Management).
The benefit of the protection against a potential threat is the costs of damages
minus the costs of protection. The expected benefit is the benefit times the probability
Chapter 24 Software Security 617
of occurrence. Clearly, one wants to focus on the potential threats that have a high
expected benefit. For these threats, one formulates security requirements so that the
software under development will provide security mechanisms to defend the system
and resources against such threats.
The following is a summary of the activities described above:
1. Identify valuable assets and potential threats, aided by the use case diagrams and
known attacks such as STRIDE attacks, or the ones listed in Figure 24.5.
2. Conduct cost-benefit analysis to identify threats that are costly to ignore, costly
to repair the damages, and costly to recover from such damages, and have a high
probability of occurrence.
3. For the threats identified in the last step, formulate security requirements to
provide the protection to the assets, defend the system from possible attacks,
and/or recover the application from successful attacks. The appropriate security
requirements can be looked up from the list described in Section 24.2.
4. Update the requirement-use case traceability matrix to include the security re-
quirements and relate them to the use cases.
618 Part VIII Project Management and Software Security
5. If additional functional requirements and use cases are introduced, due to the
addition of the security requirements, then repeat the above steps.
•
EXAMPLE 24.2 Derive security requirements from the following use cases for the Study Abroad
Management System (SAMS):
UC1: Search for Programs (actor: Web User, system: SAMS)
UC2: Display Program Detail (actor: Web User, system: SAMS)
UC3: Submit Online Application (actor: Student, system: SAMS)
SAMS
Solution: Figure 24.6 displays the use case diagram, which shows the business
processes and the subsystem. These are the assets that may need protection. In
addition, it identifies the information resources from the nouns of the verb-noun
phrases that name the use cases, for example, “program,” “program detail,” and
“online application.” Based on the domain knowledge acquired or by consulting
the customer and users, one can identify the assets that need protection, that is,
assets that are crucial to the business and business operation. In this example, the
exchange programs, program detail, and online applications are critical for the
business of the Office of International Education.
Cost-benefit analysis identifies the potential threats, their damage costs, and
occurrence probabilities or risks as shown in Figure 24.6 using UML notes. From
the analysis result, one identifies input manipulation, man-in-the-middle, and sniff-
ing attacks to be the threats that are associated with high damage costs and ∨
Chapter 24 Software Security 619
•
Derive misuse cases from the security requirements obtained in Example 24.2. EXAMPLE 24.3
Solution: For simplicity, Figure 24.5 is used as the attack list. First, identity theft
or stealing personal information is among the bad things an attacker loves to do.
An attacker has many options to accomplish this. He or she may try to gain access
to the machine that hosts the database and then compromise the database security
mechanism. The attacker may compromise a student account on SAMS and steal
the student’s information. He or she may also use this compromised account to try
to obtain other students’ information. This list of options may go on and on. For
the purpose of our discussion, let us assume that the attacker wants to compromise
a student’s account and uses it to steal the student’s information. In this case, three
misuse cases, referred to as MC1, MC2, and MC3, are identified:
MC1: Compromise an Account. The attacker tries to compromise a weak-
password account through repeatedly guessing or using a password cracker.
This means there are two alternative misuse cases: (1) Compromise an Account
by Guessing, and (2) Compromise an Account with a Password Cracker. For
simplicity, only (2) is considered in this example.
MC2: Logon SAMS. This is the same as the Logon SAMS use case except
that it is carried out by an attacker; and hence, it is treated as a misuse case
because the functionality is illegally accessed.
MC2: Steal Information. After logging on the SAMS system, the attacker
views and downloads the student’s information.
Figure 24.7 shows the misuse case diagram and the high-level misuse cases,
where the attacker and misuse cases are inverted, as proposed by Sindra and
Opdalh [136].
TMCBW=This misuse case begins with, TMCEW=This misuse case ends with
Although misuse cases are useful, the potential misuse cases could be numerous.
Therefore, the identification of misuse cases should be restricted to those that are most
likely to occur and the consequences are politically or economically unacceptable.
1. Produce an architectural design that satisfies the security requirements and ac-
counts for misuse cases.
2. Evaluate the architectural design to identify significant security risks.
3. Modify the architectural design to remove or mitigate the significant security
risks.
4. Repeat the last two steps until an acceptable risk level is achieved.
following: examine input data for malicious intent, perform bounds checking,
check configuration files, check command line parameters, don’t trust web URLs,
be careful of web content, check web cookies, check environment variables, set
valid initial data values, understand and correctly use file name references, be
wary of indirect file references, be careful of how programs and data are searched,
and pay special attention to the storage of sensitive information.
4. Testing for security.
Software security testing is a new, interdisciplinary area that involves both
software engineering and information security. Approaches to software security
testing are classified into two categories: static approaches and dynamic ap-
proaches. Static approaches include inspection, review and use of static analysis
tools. These approaches can be applied to requirements, design, and code. With
regard to security, the conventional code review and inspection checklist should
be augmented with security-related review questions and inspection items to de-
tect security vulnerabilities. The design of the review questions and inspection
items should evaluate the code with respect to the security requirements, secure
software design principles, patterns, misuse cases, and attack patterns.
Static analysis tools, also called code analyzers, are an aid to code review and
inspection. These tools examine the software to detect security problems and vul-
nerabilities. Static analysis tools can check either the source code or the compiled
code. Their functions include type checking, style checking, property checking,
security analysis, bug finding, program verification, and program understanding.
During the last several decades, many static analysis tools have been developed.
The use of tools can drastically reduce time and effort. One problem of static
analysis tools is that they tend to produce too many false positives or false alarms.
Tremendous effort is required to examine the analysis result. Another problem
is that a few tools report false negatives, that is, they do not detect some of the
problems that actually exist.
All dynamic approaches to testing require execution of the program using
a set of test cases. These approaches differ in the way in which the test cases
are generated, and the test model that is used to generate the test cases. With
regard to testing for security, the goal of a secure software test method is to
generate test cases that can detect security problems as effectively and efficiently
as possible. Many methods and tools for security testing have been proposed
during the last two decades. Similar to conventional software testing methods
and tools, security-testing methods and tools are also classified into black-box,
white-box, and gray-box methods and tools, depending on the way in which the
test cases are generated.
Test-driven development (TDD) is an emerging trend in recent years. It is a
best practice to consider security during TDD. That is, security test cases should
also be generated and run during TDD. This ensures not only the correctness of
the functionality but also the desired degree of security of the implementation.
Note that test for security should be performed for security functions as well as
ordinary functions that have a security implication. For example, a component
that implements strong password rules should be tested to ensure that the rules
are implemented correctly. Moreover, the component should also be tested with
Chapter 24 Software Security 627
boundary, extreme, and exceptional cases to ensure that it behaves properly under
such circumstances.
If a component does not implement a security function but its execution
has security implications, then the component should be tested for its security
impact. For example, if a component accesses an object that contains sensitive
information, then the component should be tested for proper access control, non-
elevation of privilege, and failing in a secure state.
The misuse cases identified during the planning phase are useful for security
test case generation. In particular, the attack scenario of each misuse case can be
described by an “expanded misuse case,” which is similar to a use case except
that it has a hostile intent. The expanded misuse cases can be used to gener-
ate misuse case–based test cases (see Chapter 20 for use case–based test case
generation).
5. Perform penetration testing during deployment. This is described in the “Seven
Best Practices of Software Security” section.
Security needs are different for different applications. The customer and users know
what are the valuable resources of their business and the level of protection needed.
Therefore, building secure systems requires active customer and user involvement.
The team needs to work with the customer and users closely throughout the life
cycle. In particular, active user involvement is critical during the requirements phase
to identify and formulate the security requirements, and assign priority to the security
requirements.
Security not only costs effort and money to build and operate, it costs convenience
to comply to security procedures. With respect to security, different stakeholders have
different opinions. The director of the office of information security tends to think the
more security the better. This is because his sole responsibility is to stay away from
trouble. On the other hand, the end users do not want the inconvenience associated
with certain security procedures. Often, the users want the office of information
security and the office of information technology to implement convenient measures
to protect the valuable resources. In these cases, how to reach a viable solution requires
a collaborative and cooperative approach between the stakeholders.
SUMMARY
•
This chapter presents the notion of software security, others. The security area alone covers a broad spec-
that is, building secure software throughout the life- trum of topics. These include cryptography, authen-
cycle activities. It discusses the importance of soft- tication, authorization, access control, intrusion pre-
ware security as well as secure software design prin- vention and detection, privacy, malware, and software
ciples and security patterns. Other techniques such as security. This chapter serves as a brief introduction
attack tree and misuse cases are described. Software to the field of software security. The Further Read-
security is an emerging, multidisciplinary area that ing section provides pointers to software security and
involves software engineering, information security, other related topics.
operating systems, and computer networking, among
FURTHER READING
•
Building Secure Software: How to Avoid Security Problems an attacker launches attacks. Reference [113] provides a
the Right Way by Viega and McGraw [156] and Software brief introduction to software security testing. Fuzzing has
Security: Building Security In by McGraw [114] are excel- emerged as a new way to software security testing, espe-
lent readings. Reference [114] provides a comprehensive cially for input validation functions [68, 71, 146]. Fuzzing
coverage of important topics in the area, mostly from a prac- makes small changes to the program or input according
titioner’s point of view. It also provides a long list of attack to certain patterns. There are black-box and white-box ap-
patterns and a list of commercial tools. Security require- proaches to fuzzing. Black-box approaches mutate the test
ments are traditionally treated as quality requirements. The input and use it to test the security of the program. The
paper by Firesmith [62] discusses the security requirements white-box approach presented in [71] uses dynamic sym-
in detail and includes examples. Reference [74] presents a bolic execution to collect program conditions. These pro-
framework for security requirements elicitation and analy- gram conditions are modified and then solved by using a
sis based on satisfiability arguments. Security requirements constraint solver. The results are used to derive the security
elicitation and analysis using misuse cases are presented in tests. Another white-box approach that fuzzes the seed in-
[9, 110, 111, 136]. Chess and West [44] provide a compre- put file is presented in [68]. Other security testing methods
hensive treatment of secure programming, static analysis, are found in [1, 6, 42, 43, 47, 129], among numerous other
and related tools. It includes chapters on secure program- publications. For a comprehensive survey of vulnerability
ming techniques as well as static analysis and their applica- detection methods, see [134].
tions to detecting security problems in Java programs, web Security patterns are discussed in many papers in
applications, and others. different contexts [58, 75, 165]. Some of the patterns
Dynamic approaches to software security testing has presented in this chapter come from [58, 165]. Refer-
appeared in security-related journals and conference pro- ence [58] includes architectural-level, design-level, and
ceedings. One type of approach uses dynamic symbolic ex- implementation-level security patterns. The architectural-
ecution [41, 71, 155] to overcome the limitations of sym- level patterns are presented in this chapter—the privilege
bolic execution, such as loops and pointers. The approach reduction, privilege separation, and defer to kernel patterns.
proposed in [166] reuses the test traces produced during The design-level patterns are the secure counterparts of
functional testing to symbolically and dynamically execute some of the Gang of Four patterns, for example, secure fac-
the component under test. The program conditions gathered tory, secure strategy factory, secure builder factor, secure
during the execution are analyzed to detect potential viola- chain of responsibility, secure state machine, and secure
tion of security requirements. The analysis result is used to visitor. The implementation-level patterns includes secure
generate test cases and test data to test the security of the logger, input validation, and clear sensitive information, and
component under test. others.
The books by Hoglund and McGraw [82], and Whit-
taker and Thompson [160] help testers understand how
630 Part VIII Project Management and Software Security
EXERCISES
•
24.1 Identify and formulate security requirements for the application. Include security-related domain con-
online car rental project described in Appendix D.1. cepts, their properties and relationships.
24.2 Identify five of the most significant misuse cases for 24.5 Produce sequence diagrams for the three most use-
the online car rental project. Also specify the abstract, ful use cases for the online car rental application.
high-level, and expanded misuse cases for these five Include and indicate in the sequence diagrams secu-
misuse cases. Hint: These are the same as abstract, rity mechanisms to satisfy the security requirements
high-level, and expanded use cases except that they formulated previously.
have a hostile intent. 24.6 Do the same exercises as above but use the
24.3 Produce a secure architectural design for the on- Study Abroad Management System described in
line car rental software. Indicate which secure soft- Appendix D.3.
ware design principles and security patterns are 24.7 Do the same exercises as above but use the National
applied. Trade Show Service (NTSS) system described in
24.4 Produce a domain model for the online car rental Appendix D.2.
Appendix A
Personal Software
Process: Estimation, Planning,
and Quality Assurance
Appendix A is a continuation and supplement to the personal software process pre-
sented in Chapter 2.
quality and productivity. The following are PSP code review principles:
1. Personally review all of your own work before you move on to the next develop-
ment phase.
2. Strive to fix all of the defects before you give the design or code to review by
others.
3. Use a personal checklist and follow a structured review process. The personal
checklist is produced from the Defect Recording Logs’ that is, for frequent de-
fect types, devise checks that are specific to detect the defects. The checklist is
organized into sections, each of which focuses on detecting similar defects. The
checklist is modified from time to time to reflect the improvement from using
the PSP.
4. Follow sound review practices: review in small increments, do reviews on paper,
and do them when you are rested and fresh.
5. Measure the review time, the sizes of the artifacts reviewed, and the number and
types of defects you found and missed.
6. Use these data to improve your personal review process.
7. Design and implement your components so that they are easy to review.
8. Review your defect data to identify ways to prevent defects.
9. Review against coding standards.
Java Technologies
This appendix provides a mini-tutorial to some of the commonly used Java technolo-
gies: Java Data Base Connectivity (JDBC), Swing, and Java Server Pages (JSP).
634
Appendix B Java Technologies 635
Java Application
JDBC/ODBC Vendor-
Bridge Supplied
JDBC
ODBC Driver Driver
Database Database
distinguish, all components of Swing are preceded with a capital J, such as JFrame and
JComponent, which extend AWT Frame and AWT Component. Swing is meant for
implementing graphical user interfaces for stand-alone applications. The following
presentation uses the state diagram editor GUI shown in Figure 16.3 to illustrate
programming with Swing. Many IDEs greatly facilitate Swing programming. For
example, the program segments displayed in this section can be easily produced by
using the interactive GUI design capabilities of an IDE.
package gui;
import javax.swing.*;
public class SDEFrame extends JFrame {
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenuFile = new JMenu("File");
JMenu jMenuEdit = new JMenu("Edit");
JMenu jMenuTools = new JMenu("Tools");
JMenu jMenuHelp = new JMenu("Help");
public SDEFrame() {
try { initComp();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void initComp() throws Exception {
setTitle("State Diagram Editor");
jMenuBar1.add(jMenuFile); jMenuBar1.add(jMenuEdit);
jMenuBar1.add(jMenuTools); jMenuBar1.add(jMenuHelp);
setJMenuBar(jMenuBar1); setSize(800, 600);
}
/** exit application when the window is closed */
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.WINDOW_CLOSING==e.getID()) System.exit(0);
}
}
To show the window, one needs a Main class, which creates an instance of
SDEFrame and makes it visible:
package gui;
import java.awt.Toolkit;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
638 Appendix B Java Technologies
import java.awt.Dimension;
public class Main {
public Main() {
SDEFrame frame = new SDEFrame();
frame.validate();
// Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().
getScreenSize();
Dimension frameSize = frame.getSize();
frame.setLocation( (screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
public static void main(String[] args) {
try { UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
} catch (Exception exception) {
exception.printStackTrace();
}
new Main();
}
}
The reader can compile and run these programs to view the result.
// ...
ImageIcon openImg = new ImageIcon(getClass().
getResource("openFile.png"));
ImageIcon closeImg = new ImageIcon(getClass().
getResource("closeFile.png"));
ImageIcon helpImg = new ImageIcon(getClass().
getResource("help.png"));
openButton.setIcon(openImg); closeButton.setIcon(closeImg);
helpButton.setIcon(helpImg); jToolBar1.add(openButton);
jToolBar1.add(closeButton); jToolBar1.add(helpButton);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(jToolBar1, BorderLayout.NORTH);
}
}
public class Init extends ControllerState { public class AddTransition extends ControllerState {
private static Init instance; private static AddTransition instance = null;
private Init() { } private AddTransition() {}
public static Init getInstance() {...} public static AddTransition getInstance(){...}
public ControllerState addState() { public ControllerState mousePressed(Point2D p) {
return AddState.getInstance(); Controller c= Controller.getInstance();
} if(c.getDiagram().find(p)!=null)
public ControllerState addTransition() { return AssSrcSelected.getInstance();
return AddTransition.getInstance(); return this;
} }
} }
public class AddState extends ControllerState{ public class TransSrcSelected extends ControllerState {
private static AddState instance; private static TransSrcSelected instance;
private AddState() {} private TransSrcSelected() {}
public static AddState getInstance() {...} public static TransSrcSelected getInstance() {...}
public ControllerState mouseClicked(Point2D p) { public ControllerState mouseDragged (Point2D p1, Point2D p2)
Controller c= Controller.getInstance(); { return null; }
Diagram d = c.getDiagram(); public ControllerState mouseReleased (Point2D p1, Point2D p2)
if(!d.contains(p)) d.addState(new State(p)); { Controller c=Controller.getInstance();
return Init.getInstance(); Diagram d=c.getDiagram();
} State s1 = d.find(p1), s2 = d.find(p2);
} if(s1!=null && s2!=null) {
d.addTransition(...); return Init.getInstance();
} else { return this; }
}
}
response
execute servlet
control flow
hello_jsp.class business
objects business
objects data flow
involved
used by the servlet is identified. The JSP engine then extracts the form’s data and
uses them to set the attributes of the bean. This is possible because the bean is written
according to the Java coding convention and provides setter methods that correspond
to the names of the input fields in the form. The JSP engine then executes the servlet,
which in turn queries the bean and interacts with relevant business objects to process
the request and produce the response. The response is then sent to the client.
(a) HTML page for entering search criteria (b) Corresponding Java bean
can be set by multiple setProperty lines in each of which the asterisk is replaced
by the attribute name.
Lines (6) and (7) are scriptlets that create an instance of SearchController and
call its search (searchBean) method, which normally returns an array of Program
objects. In this case, the searchBean object serves to pass the search criteria. Note
the use of a pair of <% string and %> string to enclose Java source code in an
html file.
Lines (8)–(23) are html code with scriptlets, which carry out necessary check-
ing and computation to produce the response to the client. The assignment op-
erator or the = sign that precedes a function call, such as =p.getName() on line
(17), causes the return value to be displayed in the html page.
Step 4. Implement the other classes.
In this step, the other relevant classes, such as SearchController and Program,
are implemented.
Step 5. Build and deploy the web application.
In this step, the bean classes and the business object classes are compiled into
bytecode. To deploy the web application, the bytecode files, html files, JSP files,
and image files are arranged in appropriate directories as shown in Figure B.8.
The files including the directories are jarred to produce a web archive file, say
jsptest.war. An IDE such as eclipse or NetBeans automatically produces the war
file when it compiles the Java files.
The jsptest.war file is then placed in the appropriate directory according
to the instructions given by the vendor of the web server and JSP engine. For
Tomcat, the file should be placed in the webapps directory under the directory
where Tomcat is installed, for example,
C:\...\Tomcat 6.0\webapps\jsptest.war.
Finally, start the web server according to the instructions given by the
vendor.
646 Appendix B Java Technologies
C.1 NETBEANS
•
It is rather cumbersome to use a text editor to write Java programs, and the javac and
Java commands to compile and run Java programs from the command prompt. These
problems are overcome by integrated development environments (IDE). An IDE is
a software tool that provides support to a variety of software development activities,
which may include analysis, design, implementation, compilation, execution, test-
ing, debugging, software quality assurance, software configuration management, and
software project management. As an example, Figure C.1 shows a screen shot of Net-
Beans 6.5.1. NetBeans is an open source IDE licensed under Common Development
and Distribution License (CDDL) and General Public License (GPL). It is written
entirely in Java, and hence, it can run on different platforms.
After installation, the user double-clicks the NetBeans icon in the desktop to
launch it. The first thing to do is to create a project. This is accomplished by clicking
File then selecting New Project to launch a dialog box. The dialog box lets the user
select the category and type of project. To create a Java project, the user clicks Java
in the Categories list and Java Application in the Projects list. The user then clicks
the Next button to fill in project specific information. The window in Figure C.1 is a
typical IDE window. It contains three panels, the project panel, the editor panel, and
the navigator panel. The project panel, located at the upper-left corner of the main
area, has three tabs. The Projects tab lets the user view the packages and libraries of
each project. The Files tab lets the user view the files of each project. These include
source files, .class files, and xml files that specify various project properties. The
services tabs show the services that the user can use to access databases and web
services.
The lower-left panel shows the functions and attributes of the class selected in
the upper-left panel. The return types of the functions and the attribute types are also
displayed. If the user double-clicks a function or attribute, the cursor in the editor
panel will jump to that function or attribute so that the user can work on that feature.
The editor has many code assistance features that make programming much easier
and more pleasant. For example, the user can click the Run button and select Build
647
648 Appendix C Software Tools
Main Project, Run Main Project, or Test Project to compile, run, or test the project.
It is beyond the scope of this book to provide a detailed presentation of an IDE.
Fortunately, many IDE downloads come with an easy-to-learn tutorial, which the
reader can follow to get familiar with the IDE.
in Figure C.2. These implement the four test cases described in Section 20.3.1.
Each of these functions initializes the input list, calls the purge() function, and
checks the resulting list. For example, the testSingleItem() method adds an item
to the initially empty list, calls the purge() method, and then checks to ensure
that the list is not changed. The checking is performed by the two assertTrue
statements. The assertTrue(String message, boolean condition) function prints
a message when the boolean condition is evaluated to false. The first of these
statements checks the list size and ensures that the size is 1. The second assert-
True(. . .) statement ensures that the sole element in the list is named “item1.”
Besides assertTrue(. . .), many other polymorphic assert functions can be used,
for example, assertEqual(. . .), assertFalse(. . .), assertNull(. . .), and so on. The
JavaDoc API page for the Assert class describes these functions in detail.
Each of these is a Java class, and hence, they can be run as any other Java
programs. These test runners differ in the user interfaces they provide, as the
package names indicate. Figure C.3 displays the Swing test runner user inter-
face after running the test cases shown in Figure C.2. The awt test runner user
interface is similar and the text user interface prints the run result to the standard
output. The text user interface facilitates the integration of JUnit into another
tool. It is also useful when you want to implement your own graphical user in-
terface to visualize the run result, for example, to display the result using a pie
chart.
The JComboBox and the browse JButton located at the top of the Swing GUI
lets the user select the test suite to run. After selection, the user clicks the Run but-
ton to run the tests. For example, the GUI shows that the test.example.PurgeTest
test suite is selected. The execution of the four tests produces one error and one
failure. The long, horizontal progress bar turns red to indicate that there are er-
rors and failures. It would have been green if no error or failure were detected.
The detail of the error and failure is shown in the Results JScrollPane. That is,
the error occurred when executing the testEmptyList(. . .) method and the failure
occurred when executing the testDuplicate(. . .) method.
In JUnit, failures are anticipated failed conditions. It means that a test failed
because an assertTrue(. . .) was evaluated to false. If the test case is designed
and implemented correctly, then the failure indicates that an error (or bug) in the
software is detected. To verify this, let us examine the CUT, which is the purge
function of the Purge class. Line 5 and 6 in Figure 20.6(a) are responsible for
652 Appendix C Software Tools
To have JUnit execute the test cases in NetBeans, click the Run icon from the
toolbar. The test runner GUI shows up and the execution result is displayed.
1. Install plugin. Select Tools–>Plugins, check the “Code Coverage Plugin” check-
box in the list of available plugins, click Install, and follow the
instructions.
Appendix C Software Tools 653
2. Activate code coverage plugin for a project. Right-click the project name in
Projects view and select Coverage− >Activate Coverage Collection. The tool is
activated.
3. Run the test cases with JUnit in NetBeans. Do as described in the last section.
4. View test coverage. Right-click on the project name and choose Coverage − >
Show Project Coverage Statistics. To see which lines of a class are exercised
and which are not, double-click the class name in Project view. Green lines
are covered completely, yellow lines are covered partially, and the rest are not
covered.
Another subtle step to take is to move your test case Java source files from the
project test directory to the project src directory. This is because the Cobertura tasks
only check the src directory for CUT and test case source files. You may change the
cobertura-build.xml file to avoid moving the test files.
You need to compile the CUT and test cases, instrument the bytecode of the CUT,
run the test, and collect test-coverage information. All these tasks are accomplished
by a simple action. That is, you expand the cobertura-build.xml file in the Files view,
right-click the main task and choose Run Target. You should see each task being
executed and the status of the execution.
If all Cobertura tasks are built successfully, then you can view the coverage
information in the reports directory under the project directory. For example, you can
expand the cobertura-html directory to see a listing of html files. You can right-click
the index.html file and select view from the pop-up menu to view the Coverage Report
as shown in Figure C.4.
If you do the same for the index.html file under the junit-html directory, you will
see the unit test results shown in Figure C.5.
654 Appendix C Software Tools
To run the test case in NetBeans, one needs only to set LogonTest as the main class,
as described in Section C.3. However, the code displayed in Figure C.6 is incomplete.
It must be completed and the server must be set up properly before compiling and
running the test case.
Command Description
cvs init Initialize a repository by adding the CVSROOT subdirectory and default control files.
cvs checkout modules ... Create a private copy of the source for modules including at least one subdirectory.
cvs update Bring your working directory up to date with changes from the repository. It must be executed
from within the private source directory.
cvs commit file ... Incorporate the changes you made to the files to the source repository.
cvs add file ... Enroll new files in the cvs records for the modules that are checked out to your working
directory. This takes effect when you execute the cvs commit command.
cvs remove file ... Remove files from the repository. This takes effect when you execute the cvs commit command.
cvs export modules ... Prepare copies of a set of source files for shipment off site.
cvs import Incorporate a set of updates from off-site into the source repository, as a vendor branch.
cvs diff Show differences between the files in the working directory and the source repository.
cvs status Show file status.
cvs –H, or cvs –help List available cvs commands, or display a command’s usage information if a cvs command
name is provided.
cvs –V, or cvs –version Display cvs version information.
5. Set the ownership and access mode for the cvs user and cvsgrp for the CVSROOT
directory and subdirectories:
chown -R cvs $CVSROOT
chgrp -R cvsgrp $CVSROOT
chmod -R g+s $CVSROOT
6. Check that the cvspserver entry is in the /etc/services file
grep cvs /etc/services
which should show the following lines:
cvspserver 2401/tcp \# CVS client/server operations
cvspserver 2401/udp \# CVS client/server operations
658 Appendix C Software Tools
If grep does not print such lines, then add these lines to the /etc/services file.
7. Add an entry to /etc/inetd.conf to invoke CVS as a server
# CVS server
cvspserver stream tcp nowait root /usr/bin/cvs cvs
--allow-root=/usr/local/src/cvsroot pserver
2. In the CVS Root/Repository URL field, fill in the actual user name, host name, and
repository path of the CVS root/Subversion repository directory on the remote
host. In the Password field, fill in the required password. Alternatively, you can
click the Edit button to display a dialog box, or click the down-arrow to select
the protocol. These make the task easier because you don’t have to cope with the
syntax. NetBeans supports four different CVS root formats, where the last two
formats require an external CVS executable:
a. Remote password server format, which is the format used in Figure C.9, the
syntax is
“:pserver:username@hostname:/repository path”
b. Access using Remote Shell (RSH) or Secure Shell (SSH) format, the syntax is
“:ext:username@hostname:/repository path”
c. Access to a local repository format, the syntax is
“:local:/repository path”
d. Access to a local repository using a remote protocol format, the syntax is
“:fork:/repository path”
For Subversion, NetBeans supports five types of connection protocols:
a. Direct repository access on local disk. The URL format is file:
///repository path.
b. Access via WebDAV protocol to a Subversion-aware server. The URL format
is http://hostname/repository path.
c. Access via HTTP protocol with SSL encryption.
The URL format is https://hostname/repository path.
Appendix C Software Tools 661
665
666 Appendix D Project Descriptions
car is checked out to a customer, an invoice is opened. A single invoice may cover
one or more rentals. Normally a customer will settle the invoice when the car is
returned but, in some cases, the invoice must be sent to a company (such as the
customer’s employer). When the customer pays by a credit card, the rental charge
will be processed through a credit card processing company.
A car may or may not be available for rental on a given day. Rental cars need
frequent preventive maintenance and, in addition, any damage to a car has to be
repaired as soon as possible. The company wants to keep track of the rental car
purchase, repair, maintenance, and disposal information for business and tax purposes
(e.g., depreciation of the rental cars).
status of a proposal includes pending review, accepted, and rejected. The exhibitors
come to the trade show to exhibit their products or services. The exhibitors have to pay
for the booths depending on the size of the booth (large, medium, or small). Booths
are requested and rented for the whole duration of the event. Finally, the observers
come to visit the trade show for various purposes.
This GUI must be user-friendly and require minimal effort from the
user.
R3.2.3 The system must be easily extendible to include other file for-
mats and structures (how the data are organized in the file).
R4 Online application.
R4.1 The web-based application must provide the capability for students
to submit online applications to overseas exchange programs. The process
may begin by showing a checklist/to-do list. See R6 for details.
R4.2 The system must securely save the submitted applications in the database.
R4.3 The system must reply with a message showing the status of the appli-
cation process. One possible message will be the to-do list that shows what
still needs to be done to complete the application process.
R4.4 The system must generate and send an email to notify OIE staff ac-
cording to preset notification preference.
R5 System administrator and staff users.
R5.1 The system must initially create an administrator account with a given
password. The system administrator will have the privilege to create, update,
and delete staff users. The system administrator is a staff user.
R5.2 The system must provide a password-protected, web-based user-
interface for staff users to login and specify their individual email notifi-
cation preference.
R5.3 The system must allow the administrator to specify systemwide email
notification preferences, which will take precedence over the staff user’s
individually set preferences.
R6 The system must provide a checklist and to-do list to facilitate students to
keep track of the application process.
R6.1 The list(s) must display what has been done and what needs to be
done. The list may be different for different students and different overseas
programs (the teams need to discuss with OIE to finalize it).
R6.2 Each list item must show only one to-do task.
R6.3 For each to-do task and if applicable, there must be a link to the
appropriate page for completing the task.
R6.3 For each done task and if applicable, there must be a link to the ap-
propriate page for updating the information that is already submitted.
R7 The website must allow an OIE staff to review and process online
applications.
R7.1 On the staff home page (show after a staff has logged on), there must be
a “Review Online Applications” link with a plus (‘+’) sign, when expanded,
there will be several choices: (1) review newly assigned applications, (2)
review processed applications, (3) review all applications. (The teams need
to consult the OIE to finalize this requirement.)
R7.2 After a staff member selects the online applications to review, the sys-
tem must display a table showing the summary information of the
Appendix D Project Descriptions 669
applicants, one online application on each row. Each row must include a
link to an editable page so that the staff member can update the online ap-
plication.
R7.3 After the staff member submits the update, the system must display a
message showing the status of the update.
The project must take into consideration a number of quality requirements, in-
cluding but not limited to the following:
• Reliability, the system must be thoroughly tested to ensure that the increments
delivered to the OIE will be operational and highly available.
• Extensibility, the system must be easy to extend to provide new capabilities.
• Platform independence, the system must run on different platforms and support
different database management systems.
• User-friendly interface, the system must provide a user-friendly interface that
conforms to commonly used web-application user interface look-and-feel and
man-machine interaction conventions.
• Security, the system must protect the contents of the website from malicious
attacks and protect the privacy of its users.
calling and called units are legal subscribers of the system. It also emits radio signals
to notify the called unit of the call. Calls can be from a mobile unit to another mobile
unit, from a mobile unit to a telephone (mobile to land call), or from a telephone to
a mobile unit (land to mobile call). The base has a limited number of phone lines
to connect to telephones so that calls between mobile units and telephones can be
achieved.
The project will perform analysis and design using the agile unified methodology
and implement a prototype to simulate the system in Java. The goal of the project
is to model the software and simulate the hardware behaviors. The software system
of a mobile transceiver allows a user to program the transceiver using the following
commands, where texts enclosed in < and > denote system responses:
Command Description
0# <3 beeps, pause, 3 beeps> exit programming mode
1# <beep> 4 digit ID enter this transceiver’s ID number
2# <beep> 4 digit ID enter group 1 ID number
3# <beep> 4 digit ID enter group 2 ID number
4# <beep> 4 to 7 digit ANI number # enter this transceiver’s automatic number
<3 beeps> identification number
5# <beep> 0 (disable) or 1 (enable) disable/enable this user a priority user
6# <beep> 2 digit code (00–41) define CTCSS tone
7# <beep> 0 (carrier) or 1 (CTCSS tone) define busy channel detection mode
8# <beep> 4 digit code define manual operation access code
9# <beep> 2 digit (01–16) define number of radio channels available
10# <beep> 1 to 4 digit reset code # define transceiver reset code
<3 beeps>
3. Making a mobile-to-mobile call. In the scanning state, the user can press the PTT
key simultaneously with the 0 key and release them. The software detects these
and begins searching for a clear channel to transmit this request. If a clear chan-
nel is found, the software sends the unit’s ANI number to hardware to transmit;
else the software instructs the hardware to issue an error tone. After transmitting
the unit’s ANI number, the user will hear a beep when carrier is received from the
base, and the user must press the PTT and hold it while dialing the called mo-
bile’s ID number. When the called mobile becomes off hook, the connection is
established. If the base does not find carrier, then it will send an error tone to the
calling unit and the unit software resets the hardware to scanning mode.
4. Terminating a call. The user presses the PPT key and the # key simultaneously.
The software instructs the hardware to send the # key followed by the ANI number
of the unit.
5. Accessing conventional mode. The user presses the PTT key while entering the
four-digit conventional mode access code. The software generates three beep
tones and the hardware sounds the beeps.
6. Exiting conventional mode. There are two cases. The user can press PTT and the
# key and the radio acknowledges this with three beeps. The conventional mode
is also exited when the reset code is received from the base.
In addition, Eclipse, NetBeans, or ant may be used to integrate the above tools. The
implementation will be in Java because the tools are implemented in Java. Figure D.1
shows the workflow of the proposed tool. The tool has the following requirements:
1. The tool should provide a GUI for the user to edit a ClassBench test model
using OpenJGraph. The user should be able to specify the state conditions and
transition actions. These are Java conditions and Java statements, respectively.
Figure D.2 shows an example GUI implemented in Java. In this project, for
simplicity, the implementation reuses OpenJGraph. The Edit State dialog allows
the user to specify the condition for the state. The Java statements for the actions
of a transition can be specified similarly.
2. The tool will perform the following either in one step or several steps as requested
by the user:
a. From the test model, the tool will automatically generate the OpenJGraph
traversals.
Appendix D Project Descriptions 673
Graphical Graph
test model
Editor Traversa
[OpenJGraph] [OpenJGraph]
paths
(test cases)
HALT
b. From the traversals, the tool will automatically generate the JUnit Test Case
subclass including the test methods.
c. The tool will compile the JUnit Test Case subclass and the class under test
(CUT).
d. The tool will instrument the CUT.
e. The tool will execute the JUnit tests and show the coverage information.
3. If the students have learned the state pattern, then apply the state pattern to design
and implement the test model.
References
1. M. Abadi, M. Budiu, U. Erlingsson, and J. Ligatti, 11. Scott Ambler, Agile Modeling: Effective Practices
“Control-flow Integrity,” in Proceedings of the 12th for eXtreme Programming and the Unified Process
ACM Conference on Computer and Communications (Hoboken, NJ: Wiley 2002).
Security (CCS), 2005, pp. 340–353. 12. D. J. Anderson, “Stretching Agile to Fit CMMI
2. P. Abrahamsson, J. Warsta, M. Siponen, and J. Level 3—The Story of Creating MSF for CMMI?
Ronkainen, “New Directions on Agile Methods: A Process Improvement at Microsoft Corporation,” in
Comparative Analysis,” in Proceedings of the 25th Proceedings of 2005 Agile Conference, Denver, CO,
International Conference on Software Engineering July 24–29, 2005, pp. 193–201.
(ICSE’03), Oregon, 2003, pp. 244–254. 13. K. Arnold, J. Gosling, and David Holmes, The
3. Mathur Aditya, Foundations of Software Testing Java Programming Language, 4th ed. (Upper Sad-
(Boston: Addison-Wesley Professional, 2008). dle River, NJ: Prentice Hall, 2005).
4. K. K. Aggarwal and Yogesh Singh, Software Engi- 14. David Astels, Test-Driven Development: A Practical
neering (3rd ed.), (New Delhi, India: New Age Inter- Guide, 2nd ed. (Upper Saddle River, NJ: Prentice
national Publishers, 2007). Hall, 2003).
5. Robert Aiello and Leslie Sachs, Configuration Man- 15. David Avison and Guy Fitzgerald, “Where Now
agement Best Practices: Practical Methods That for Development Methodologies,” Communications
Work in the Real World (Boston: Addison-Wesley of the ACM, vol. 46, no. 1 (January 2003),
Professional, 2010). pp. 79–82.
6. P. Akritidis, C. Cadar, C. Raiciu, M. Costa, and 16. Victor R. Bassili, “Viewing Maintenance as Reuse-
M. Castro, “Preventing Memory Error Exploits with oriented Software Development,” IEEE Software,
WIT,” in Proceedings of the 2008 IEEE Symposium vol. 7, no. 1 (1990), pp. 19–25.
on Security and Privacy, Washington, DC, 2008. 17. Victor R. Bassili, Lionel C. Briand, and Walcelio
IEEE Computer Society, pp. 263–277. L. Melo, “A Validation of Object-Oriented Design
7. J. Aldrich, C. Chambers, and D. Notkin, “Architec- Metrics as Quality Indicators,” IEEE Transactions on
tural Reasoning in ArchJava,” in Proceedings of the Software Engineering, vol. 22, no. 10 (October 1996),
European Conference on Object-Oriented Program- pp. 751–761.
ming (ECOOP), vol. 2374, 2002, pp. 185–193. 18. Len Bass, Paul Clements, and Rick Kazman, Software
8. Roger T. Alexander and A. J. Offutt, “Analysis Tech- Architecture in Practice (Boston: Addison-Wesley,
niques for Testing Polymorphic Relationships,” in 2003).
Proceedings of 30th IEEE International Conference 19. Kent Beck and Martin Fowler, Planning Extreme Pro-
on Technology of Object-Oriented Languages and gramming (Boston: Addison-Wesley Professional,
Systems (TOOLS 30), Santa Barbara, CA, August 2000).
1–5, 1999, pp. 104–114. 20. Kent Beck, Test-Driven Development: By Example
9. Ian Alexander, “Misuse Cases: Use Cases with Hos- (Boston: Addison-Wesley Professional, 2002).
tile Intent,” IEEE Software, vol. 20, no. 1, January/ 21. Kent Beck, Extreme Programming Explained: Em-
February 2003, pp. 58–66. brace Change, 2nd ed. (Boston: Addison-Wesley,
10. Paul Ammann and Jeff Offutt, Introduction to Soft- 2004).
ware Testing (Cambridge, UK: Cambridge University 22. B. Beizer, Software Testing Techniques, 2nd ed.
Press, 2008). (Hoboken, NJ: Van Nostrand Reinhold, 1990).
675
676 References
23. David Bellagio and Tom J. Milligan, Software Con- the Presence of Dependency Cycles,” in Proceedings
figuration Management Strategies and IBM Rational of the 12th International Symposium on Software
ClearCase: A Practical Introduction, 2nd ed. (Indi- Reliability Engineering (ISSRE), November 2001,
anapolis, IN: IBM Press, 2005). pp. 287–296.
24. S. P. Berczuk and B. Appleton, Software Configura- 38. L. C. Briand, Y. Labiche, and Y. Wang, “An In-
tion Management Patterns: Effective Teamwork, vestigation of Graph-Based Class Integration Test
Practical Integration (Boston: Addison-Wesley, Order Strategies,” IEEE Transactions on Software
2003). Engineering, vol. 29, no. 7 (July 2003), pp. 594–607.
25. Berzins and Luqi, Software Engineering with Ab- 39. F. P. Brooks Jr., The Mythical Man-Month, 2nd ed.
stractions (Boston: Addison-Wesley, 1991). (Boston: Addison-Wesley Professional, 1995).
26. T. Bhat, et al., “Evaluating the Efficacy of Test-Driven 40. Bernd Bruegge and Allen H. Dutoit, Object-Oriented
Development: Industrial Case Studies,” Proceedings Software Engineering: Using UML, Patterns, and
of International Symposium on Empirical Software Java, 3rd ed. (Upper Saddle River, NJ: Prentice Hall,
Engineering, Rio de Janiero, Brazil, September 21– 2009).
22, 2006, pp. 356–363. 41. C. Cadar, V. Ganesh, P. Pawlowski, D. Dill, and
27. R. Binder, “Design for Testability in Object-Oriented D. Engler, “EXE: Automatically Generating Inputs
Systems,” CACM, vol. 37, no. 9 (September 1994), of Death,” in Proceedings of the 13th ACM Con-
pp. 87–101. ference on Computer and Communications Security
28. Robert Binder, Testing Object-Oriented Systems: (CCS’06), 2006, pp. 322–335.
Models, Patterns, and Tools (Boston: Addison- 42. C. Cadar, D. Dunbar, and D. Engler, “KLEE: Unas-
Wesley, 2000). sisted and Automatic Generation of High-Coverage
29. Kurt Bittner and Ian Spence, Use Case Modeling Tests for Complex System Programs,” in Proceedings
(Boston: Addison-Wesley Professional, 2002). of the USENIX Symposium on Operating Systems De-
30. Michael R. Blaha and James R. Rumbaugh, Object- sign and Implementation (OSDI), 2008.
Oriented Modeling and Design with UML, 2nd ed. 43. W. Chang, B. Streiff, and C. Lin, “Efficient and Ex-
(Upper Saddle River, NJ: Prentice Hall, 2004). tensible Security Enforcement Using Dynamic Data
31. Benjamin S. Blanchard, System Engineering Man- Flow Analysis,” in Proceedings of the 15th ACM
agement, 4th ed. (Hoboken, NJ: Wiley, 2008). Conference on Computer and Communications Se-
32. Boehm, B. “A Spiral Model of Software Develop- curity (CCS), New York, 2008, pp. 39–50.
ment and Enhancement,” IEEE Computer, vol. 21, 44. Brian Chess and Jacob West, Secure Programming
no. 5 (May 1988), pp. 61–72. with Static Analysis (Boston: Addison Wesley, 2007).
33. Barry Boehm, “Software Risk Management: Princi- 45. S. Chidamber and C. F. Kemerer, “A Metrics Suite
ples and Practices,” IEEE Software, January 1991, for Object-Oriented Design,” IEEE Trans. on Soft-
pp. 32–41. ware Engineering, vol. 20, no. 6 (June 1994),
34. Barry W. Boehm, Chris Abts, A. Winsor Brown, pp. 476–493.
Sunita Chulani, Bradford K. Clark, Ellis Horowitz, 46. Elliot J. Chikofsky and James H. Cross, “Reverse En-
Ray Madachy, Donald J. Reifer, and Bert Steece, gineering and Design Recovery: A Taxonomy,” IEEE
Software Cost Estimation with COCOMO II (Upper Software, vol. 7, no. 1 (1990), pp. 13–17.
Saddle River, NJ: Prentice Hall, 2000). 47. J. Clause and A. Orso, “Penumbra: Automati-
35. Barry Boehm and Richard Turner, “Observations on cally Identifying Failure-Relevant Inputs Using Dy-
Balancing Discipline and Agility,” Proceedings of the namic Tainting,” in Proceedings of the 18th Interna-
Conference on Agile Development, IEEE Computer tional Symposium on Software Testing and Analysis
Society, 2003, pp. 32–39. (ISSTA), New York, 2009, pp. 249–260.
36. G. Booch, J. Rumbaugh, and I. Jacobson, The Unified 48. Paul Clements, Felix Bachmann, Len Bass, David
Modeling Language User Guide, 2nd ed. (Boston: Garlan, James Ivers, Reed Little, Paulo Merson,
Addison-Wesley, 2005). Robert Nord, and Judith Stafford, Documenting
37. L. Briand, Y. Labiche, and Y. Wang, “Revisiting Software Architectures: Views and Beyond, 2nd ed.
Strategies for Ordering Class Integration Testing in (Boston: Addison-Wesley Professional, 2010).
References 677
49. Alistair Cockburn, Writing Effective Use Cases 3rd ed. (Boston: Addison-Wesley Professional,
(Boston: Addison-Wesley Professional, 2000). 2003).
50. Alistair Cockburn, Agile Software Development: The 64. Elisabeth Freeman, Eric Freeman, Bert Bates, Kathy
Cooperative Game (Boston: Addison-Wesley Profes- Sierra, and Elisabeth Robson, Head First Design Pat-
sional, 2006). terns (Sebastopol, CA: O’Reilly Media, 2004).
51. Mike Cohn, Agile Estimating and Planning (Upper 65. Sanford Friedenthal, Alan Moore, and Rick Steiner, A
Saddle River, NJ: Prentice Hall, 2006). Practical Guide to SysML, 2nd ed. (Burlington, MA:
52. Mike Cohn, Succeeding with Agile: Software De- Morgan Kaufmann, 2011).
velopment Using Scrum (Boston: Addison-Wesley 66. Wilbert O. Galitz, The Essential Guide to User Inter-
Professional, 2009). face Design (Hoboken, NJ: Wiley, 2007).
53. Lisa Crispin and Janet Gregory, Agile Testing: A 67. E. Gamma, Richard Helm, Ralph Johnson and John
Practical Guide for Testers and Agile Teams (Boston: Vlissides, Design Patterns: Elements of Reusable
Addison-Wesley Professional, 2009). Object-Oriented Software (Boston: Addison-Wesley,
54. http://netbeans.org/kb/docs/ide/cvs.html#checking 1995).
55. Marco D’Ambros, Alberto Bacchelli, Michele Lanza, 68. V. Ganesh, T. Leek, and M. Rinard, “Taint-Based Di-
“On the Impact of Design Flaws on Software De- rected Whitebox Fuzzing,” in Proceedings of 31st
fects,” in Proceedings of IEEE 10th International IEEE International Conference on Software Engi-
Conference on Quality Software (QSIC), Zhangjiajie, neering, Washington DC, 2009, pp. 474–484.
China, July 14–15, 2010, pp. 23–31. 69. M. Ganis, D. Leip, F. Grossman, and J. Bergin, “In-
56. Alan A. Davis, Software Requirements: Objects, troducing Agile Development (XP) into a Corporate
Functions and States, rev. ed. (Upper Saddle River, Webmaster Environment—An Experience Report,”
NJ: Prentice Hall, 1993). in Proceedings of Agile Conference, Denver, CO,
57. Alan A. Davis, et al., “Identifying and Measuring July 24–29, 2005, pp. 145–152.
Quality in a Software Requirements Specification,” 70. J. Gao, C. Chen, T. Yasufumi, D. Kung, and P.
in Proceedings of the First International Software Hsia, “Identifying Polymorphism Change and Impact
Metrics Symposium, IEEE, Baltimore, MD, 1993, in Object-Oriented Programs,” Journal of Software
pp. 141–152. Maintenance, 1997.
58. Chad Dougherty, Kirk Sayre, Robert C. Seacord, 71. P. Godefroid, M. Y. Levin, and D. Molnar, “Auto-
David Svoboda, and Kazuya Togashi, “Secure De- mated Whitebox Fuzz Testing,” Network and Dis-
sign Patterns,” Technical Report, CMU/SEI-2009- tributed Systems Security, 2008, pp. 151–166.
TR-010, March 2009. 72. Mark G. Graff and Kenneth R. van Wyk, Secure Cod-
59. M. Dowson, “The Ariane 5 Software Failure,” Soft- ing (Sebastopol, CA: O’Reilly Media, 2003).
ware Engineering Notes, vol. 22, no. 2 (March 1997), 73. Penny Grubb and Armstrong A. Takang, Software
p. 84. Maintenance: Concepts and Practice, 2nd ed. (Sin-
60. H. Erdogmus, M. Morisio, and M. Torchiano, “On the gapore: World Scientific Publishing Company, 2003).
Effectiveness of the Test-First Approach to Program- 74. Charles B. Haley, Robin Laney, Jonathan D. Moffett,
ming,” IEEE Transactions on Software Engineering, and Bashar Nuseibeh, “Security Requirements Engi-
vol. 31, no. 3 (2005), pp. 226–237. neering: A Framework for Representation and Anal-
61. R. Eshuis and R. Wieringa, “Tool Support for Veri- ysis,” IEEE Transactions on Software Engineering,
fying UML Activity Diagrams,” IEEE Transactions vol. 34, no. 1 (January/February 2008), pp. 133–153.
on Software Engineering, vol. 30, no. 7 (2004), 75. Spyros T. Halkidis and Nikolaos Tsantalis, “Architec-
pp. 437–447. tural Risk Analysis of Software Systems Based on Se-
62. Donald Firesmith, “Engineering Security Require- curity Patterns,” IEEE Transactions on Dependable
ments,” Journal of Object Technology, vol. 2, no. 1 and Secure Computing, vol. 5, no. 3 (July–September,
(January–February 2003), pp. 53–68. 2008), pp. 129–142.
63. Martin Fowler, UML Distilled: A Brief Guide 76. D. Harel, “On Visual Formalisms,” CACM, vol. 31,
to the Standard Object Modeling Language, no. 5 (May 1988), pp. 514–531.
678 References
77. M. J. Harrold, J. D. McGregor, and K. J. Fitz- 91. Ivar Jacobson, James Rumbaugh, and Grady Booch,
patrick, “Incremental Testing of Object-Oriented Unified Software Development Process (Boston:
Class Structure,” in Proceedings of 14th Interna- Addison-Wesley, 1999).
tional Conference on Software Engineering, 1992, 92. Jim Johnson, Chaos: Charting the Seas of Infor-
pp. 68–80. mation Technology (Boston: The Standish Group,
78. David Hay, Requirements Analysis: From Business 1994).
Views to Architecture (Upper Saddle River, NJ: 93. Jeff Johnson, Designing with the Mind in Mind:
Prentice Hall 2011). Simple Guide to Understanding User Interface De-
79. James Herbsleb, David Zubrow, Dennis Goldenson, sign Rules (Burlington, MA: Morgan Kaufmann,
Will Hayes, and Mark Paulk, “Software Quality and 2010).
the Capability Maturity Model,” Communications of 94. C. Jones, Assessment and Control of Software Risks
the ACM, vol. 40, no. 6 (1997), pp. 30–40. (Upper Saddle River, NJ: Prentice Hall, 1994).
80. James A. Highsmith, Adaptive Software Develop- 95. Christopher M. King, Curtis E. Dalton, and Ertem
ment: A Collaborative Approach to Managing Com- Osmanoglu, Security Architecture: Design, Develop-
plex Systems (New York: Dorset House Publishing ment and Operations (New York, NY: McGraw-Hill,
Company, 1999). 2001).
81. D. Hoffman and P. Strooper, “ClassBench: A 96. Juha Koskela, “Software Configuration Manage-
Framework for Automated Class Testing,” Software ment in Agile Methods,” 2003, www.vtt.fi/inf/pdf/
Practice and Experience, vol. 27, no. 5 (1997), publications/2003/P514.pdf.
pp. 573–597. 97. Lasse Koskela, Test Driven: Practical TDD and Ac-
82. G. Hoglund and G. McGraw, Exploiting Software ceptance TDD for Java Developers (Greenwich, CT:
(Boston: Addison-Wesley, 2004). Manning Publications, 2007).
83. Cay S. Horstmann and Gary Cornell, Core Java, Vol- 98. Alexander Kossiakoff, William N. Sweet, Sam Sey-
ume 1: Fundamentals, 8th ed. (Upper Saddle River, mour, and Steven M. Biemer, Systems Engineer-
NJ: Prentice Hall, 2007). ing Principles and Practice, 2nd ed. (Hoboken, NJ:
84. Cay S. Horstmann and Gary Cornell, Core Java, Vol- Wiley-Interscience, 2011).
ume 2: Advanced Features, 8th ed. (Upper Saddle 99. D. Kung, J. Gao, P. Hsia, J. Lin, and Y. Toyoshima,
River, NJ: Prentice Hall, 2008). “Design Recovery for Software Testing of Object-
85. P. Hsia, X. Li, C. Hsu, and D. Kung, “A Technique Oriented Programs,” in Proceedings of the Working
for Selective Revalidation of OO Software,” Journal Conference on Reverse Engineering, Baltimore, MD,
of Software Maintenance, 1997, pp. 217–233. May 21–23 (Los Alamitos, CA: IEEE Computer
86. Watts S. Humphrey, Introduction to the team software Society Press, 1993), pp. 202–211.
process (Boston: Addison-Wesley, 2000). 100. D. Kung, “On Decision Tree Verification and Consol-
87. Watts S. Humphrey, PSP: A Self-Improvement Pro- idation,” Journal of Information and Software Tech-
cess for Software Engineers (Boston: Addison- nology, vol. 36, no. 7 (1994), pp. 485–494.
Wesley, 2005). 101. D. Kung, J. Gao, P. Hsia, Y. Toyoshima, C. Chen,
88. Ming Huo, J. Verner, Liming Zhu, and M. A. Babar, Y. S. Kim, and Y. Song, “Developing an Object-
“Software Quality and Agile Methods,” in Proceed- Oriented Software Testing and Maintenance Environ-
ings of the IEEE International Conference on Com- ment,” Communications of the ACM, vol. 38, no. 10
puter Software and Applications, Hong Kong, 2004. (October 1995), pp. 75–87.
pp. 520–525. 102. D. Kung, J. Gao, P. Hsia, F. Wen, Y. Toyoshima, and
89. IEEE Std. 1219-1998, Standard for Software Main- C. Chen, “On Regression Testing of Object-Oriented
tenance (Los Alamitos, CA: IEEE Computer Society Programs,” Journal of Systems and Software, vol. 32,
Press, 1998). no. 1 (January 1996), pp. 21–40.
90. Ivar Jacobson, Object-Oriented Software Engineer- 103. Y. Labiche, P. Thevenod-Fosse, H. Waeselynck, and
ing: A Use Case Driven Approach (Reading, MA: M. H. Durand, “Testing Levels for Object-Oriented
Addison-Wesley, 1992). Software,” in Proceedings of the International
References 679
Conference on Software Engineering, 2000, Software Engineering, vol. 13, no. 3 (2008),
pp. 136–145. pp. 289–302.
104. Craig Larman, Applying UML and Patterns: An In- 117. Douglas W. Nance, Fundamentals of Pascal, Under-
troduction to Object-Oriented Analysis and Design standing Programming and Problem Solving, 3rd ed.
and Iterative Development, 3rd ed. (Upper Saddle (Course Technology, 1997).
River, NJ: Prentice Hall, 2005). 118. Nils J. Nilsson, “Artificial Intelligence: A New Syn-
105. N. Leveson, S. Cha, and T. Shimeall, “Safety Verifi- thesis” (Burlington, MA: Morgan Kaufmann, 1998).
cation of Ada Programs Using Software Fault Trees,” 119. Stephen R. Palmer and John M. Felsing, A Practical
IEEE Software (July 1991), pp. 48–59. Guide to Feature-Driven Development (Upper Sad-
106. Rudiger Lincke, Tobias Gutzmann, and Welf Lowe, dle River, NJ: Prentice Hall, 2002).
“Software Quality Prediction Models Compared,” in 120. C. Ravindranath Pandian, Applied Software Risk
Proceedings of the IEEE 10th International Confer- Management: A Guide for Software Project
ence on Quality Software (QSIC), Zhangjiajie, China, Managers (Boca Raton, FL: Auerbach Publications,
July 14–15, 2010, pp. 82–91. 2006).
107. M. Linton, “Composing User Interfaces with Inter- 121. Mark C. Paulk, “A Comparison of ISO 9001 and
Views,” IEEE Computer vol. 22 (February 1989), the Capability Maturity Model for Software,” Tech-
pp. 8–22. nical Report, CMU/SEI-94-TR-12, ESC-TR-94-12,
108. Mike Mason, Pragmatic Guide to Subversion, (Prag- July 1994.
matic Bookshelf, 2010). 122. D. E. Perry and G. E. Kaiser, “Adequate Testing and
109. T. J. McCabe and C. W. Butler, “Design Complexity Object-Oriented Programming,” Journal of Object-
Measurement and Testing,” CACM, vol. 32, no. 12, Oriented Programming, vol. 2 (January–February
(December 1989), pp. 1415–1425. 1990), pp. 13–19.
110. J. McDermott, “Abuse-Case-Based Assurance Argu- 123. Shari Lawrence Pfleeger and Joanne M. Atlee, Soft-
ment,” in Proceedings of the 17th Computer Security ware Engineering: Theory and Practice, 4th ed. (Up-
and Applications Conference, Washington DC, 2001, per Saddle River, NJ: Prentice Hall, 2009).
pp. 366–374. 124. Mary Poppendieck and Tom Poppendieck, Lean
111. John McDermott and Chris Fox, “Using Abuse Case Software Development: An Agile Toolkit (Boston:
Models for Security Requirements Analysis,” in Addison-Wesley, 2003).
Proceedings of the 15th Annual Computer Security 125. Roger S. Pressman, Software Engineering: A
and Applications Conference, Phonenix, AZ, 1999, Practitioner’s Approach, 6th ed. (New York, NY:
pp. 55–64. McGraw-Hill, 2004).
112. J. McDonald and Paul Strooper, “Testing Inheritance 126. A. Qumer and B. Henderson-Sellers, “A Frame-
Hierarchies in the ClassBench Framework,” in Pro- work to Support the Evaluation, Adoption, and
ceedings of the Technology of Object-Oriented Lan- Improvement of Agile Methods in Practice,” Jour-
guages and Systems, Melbourne, Australia, Novem- nal of Systems and Software, vol. 81, no. 11 (2008),
ber 23–26, 1998. pp. 1899–1919.
113. Gary McGraw, “Software Security Testing,” IEEE 127. Joseph Raynus, Software Process Improvement with
Security and Privacy, 2004, pp. 32–36. CMM (Boston: Artech House, 1999).
114. Gary McGraw, Software Security: Building Security 128. F. Ricca and P. Tonella, “Analysis and Testing of
In (Boston: Addison-Wesley, 2006). Web Applications,” in Proceedings of the 23rd Inter-
115. Tom Mens, “A State-of-the-Art Survey on Software national Conference on Software Engineering, 2001,
Merging,” IEEE Transactions on Software Engineer- pp. 25–34.
ing, vol. 28, no. 5 (May 2002), pp. 449–462. 129. M. F. Ringenburgand and D. Grossman, “Preventing
116. N. Nagappan, E. M. Maximilien, T. Bhat, and Format-String Attacks via Automatic and Efficient
L. Williams, “Realizing Quality Improvement Dynamic Checking,” in Proceedings of the 12th ACM
through Test Driven Development: Results and Ex- Conference on Computer and Communications Secu-
periences of Four Industrial Teams,” Empirical rity (CCS), New York, 2005, pp. 354–363.
680 References
130. G. Rothermel and M. J. Harrold, “Selecting Re- Agile Development Conference, Toronto, Canada,
gression Tests for Object-Oriented Software,” in 2008, pp. 97–101.
Proceedings of the IEEE International Conference 145. J. Sutherland, C. R. Jakobsen, and K. Johnson,
On Software Maintenance, Monterey, CA, 1994, “Scrum and CMMI Level 5: The Magic Potion for
pp. 14–25. Code Warriors,” in Proceedings of Agile Conference,
131. J. Rumbaugh, M. Blaha, W. Premerlani, and F. Eddy, 2007, pp. 272–278.
Object-Oriented Modeling and Design (Upper 146. M. Sutton, A. Greene, and P. Amini, Fuzzing: Brute
Saddle River, NJ: Prentice Hall, 1991). Force Vulnerability Discovery (Boston: Addison-
132. J. Rumbaugh, I. Jacobson, and G. Booch, The Uni- Wesley Professional, 2007).
fied Modeling Language Reference Manual (Boston: 147. K. C. Tai and F. J. Daniels, “Interclass Test Order
Addison-Wesley, 1998). for Object-Oriented Software,” Journal of Object-
133. S. R. Schach, Classical and Object-Oriented Soft- Oriented Programming, vol. 12, no. 4 (1999),
ware Engineering with UML and Java (New York: pp. 18–25.
McGraw-Hill Companies, 1999). 148. Richard N. Taylor, N. Medvidovic, and E. M.
134. Hossain Shahriar and Mohammad Zulkernine, “Miti- Dashofy, Software Architecture: Foundations, The-
gating Program Security Vulnerabilities: Approaches ory, and Practice (Hoboken, NJ: Wiley, 2009).
and Challenges,” ACM Computing Surveys, vol. 44, 149. R. H. Thayer, “Software System Engineering: A
no. 3, Article 11, June 2012. pp. 11:1–11:46. Tutorial,” IEEE Computer, vol. 35, no. 4 (2002),
135. Alan C. Shaw, Real-Time Systems and Software pp. 68–73.
(Hoboken, NJ: John Wiley and Sons, 2001). 150. Jenifer Tidwell, Designing Interfaces, 2nd ed.
136. Guttorm Sindre and Andreas L. Opdahl, “Elicit- (Sebastopol, CA: O’Reilly Media, 2011).
ing Security Requirements by Misuse Cases,” in 151. Y. L. Traon, T. Jeron, J. M. Jezequel and P. Morel, “Ef-
Proceedings of Technology for Object-Oriented Lan- ficient Object-Oriented Integration and Regression
guage and Systems, Sydney, Australia, November Testing,” IEEE Transactions on Reliability, vol. 49,
20–23, 2000, pp. 120–131. no. 1 (2000), pp. 12–25.
137. S. Sinha and M. J. Harrold, “Analysis and Testing 152. Andrew Troelsen, Pro C# 2008 and the .NET 3.5
of Programs with Exception Handling Constructs,” Platform, 4th ed. (Windows.Net), (New York: Apress,
IEEE Transactions on Software Engineering, vol. 26, 2007).
no. 9 (September 2000). 153. R. Tvedt, P. Costa, and M. Lindvall, “Does the Code
138. Jon Skeet, C# in Depth (Greenwich, CT: Manning Match the Design? A Process for Architecture Eval-
Publications, 2008). uation,” in Proceedings of the International Confer-
139. Ian Sommerville, Software Engineering, 9th ed. ence on Software Maintenance, Montreal, Canada,
(Boston: Addison-Wesley, 2010). 2002, pp. 393–401.
140. Jennifer Stapleton and Peter Constable, DSDM: Dy- 154. Jennifer Vesperman, Essential CVS (Sebastopol, CA:
namic Systems Development Method: The Method O’Reilly Media, 2006).
in Practice (Boston: Addison-Wesley Professional, 155. J. Viega, J. T. Bloch, Y. Kohno, and G. McGraw,
1997). “ITS4: A Static Vulnerability Scanner for C and C++
141. B. Stroustrup, The C++ Programming Language: Code,” in Proceedings of the 16th Annual Computer
Special Edition, 3rd ed. (Boston: Addison-Wesley Security Applications Conference, New Orleans, LA,
Professional, 2000). 2000, pp. 257–267.
142. B. Stroustrup, Programming: Principles and Prac- 156. John Viega and Gary McGraw, Building Secure Soft-
tice Using C++, 2nd ed. (Boston: Addison-Wesley ware: How to Avoid Security Problems the Right Way
Professional, 2008). (Boston: Addison-Wesley, 2002).
143. http://netbeans.org/kb/docs/ide/subversion 157. P. T. Ward, “The Transformation Schema: An Exten-
.html#checking sion of the Data Flow Diagram to Represent Control
144. K. Sureshchandra and J. Shrinivasavadhani, “Mov- and Timing,” IEEE Transactions on Software Engi-
ing from Waterfall to Agile,” in Proceedings of 2008 neering, vol. SE-12 (February 1986), pp. 198–210.
References 681
158. E. J. Weyuker, “Axiomatizing Software Test Data Ad- 164. Ye Wu, Mei-Hwa Chen, and Howard M. Kao, “Re-
equacy,” IEEE Transactions on Software Engineer- gression Testing on Object-Oriented Programs,” Pro-
ing, vol. SE-12, no. 12 (1986), pp. 1128–1138. ceedings of the 10th IEEE International Symposium
159. E. J. Weyuker, “The Evaluation of Program-Based on Software Reliability Engineering, Boca Raton, FL,
Software Test Data Adequacy Criteria,” CACM, vol. November 1–4, 1999.
31, no. 6 (1986), pp. 668–675. 165. Joseph W. Yoder and Jeffrey Barcalow, “Architec-
160. J. Whittaker and H. Thompson, How to Break Soft- tural Patterns for Enabling Application Security,” in
ware Security (Boston: Addison-Wesley, 2003). Proceedings of the Fourth Conference on Patterns
161. Karl Wiegers, Software Requirements 2, 2nd ed. Languages of Programs (PLoP ’97), Monticello, IL,
(Redmond, WA: Microsoft Press, 2003). September 1997.
162. Laurie Williams and Robert Kessler, Pair Program- 166. D. Zhang, D. Liu, J. Lei, D. Kung, C. Csall-
ming Illuminated (Boston: Addison-Wesley Profes- ner, and W. Wang, “Detecting Vulnerabilities in C
sional, 2002). Programs Using Trace-Based Testing,” in Proceed-
ings of the IEEE International Conference on De-
163. Rebecca Wirfs-Brock and Alan McKean, Object
pendable Systems and Networks, Chicago, IL, 2010,
Design: Roles, Responsibilities, and Collaborations
pp. 241–250.
(Boston: Addison-Wesley, 2001).
Index
682
Index 683
application security, current approaches to, 606 scalar types, 281, 282 needing warm-up time, 133
application software development, as a wicked tracking updated for an object, 437 not overdoing, 135
problem, 20 authentication requirements, 608 performing as team activities, 133
application systems, types of, 143 authorization requirements, 608 prior to classifying, 133
applications, adding new requests or Auto Detect Use Cases button, 198 branch coverage, as a unit test coverage
functions, 433 automatic derivation, of use cases, 198 criterion, 653
application-specific integrated circuits automatic identification and automatic branches, representing a rule, 380
(ASIC), 55 classification, 137, 197–198 bridge pattern, 157, 389, 558
architectural design, 139–168, 276 availability metric, 476, 480 accomplishing goals of the DB manager, 429
of a building, 139 available components first strategy, 532 allowing DBMgr to work with various
checking against design objectives and design AWT Component, extending, 637 databases, 264
principles, 166–167 AWT Frame, extending, 637 application of, 429, 430
custom, 142 description of, 428, 429
defined, 139 eliminating problems associated with direct
determining objectives of, 142–143 B database access, 429
guidelines for, 166–167 backdoor attack, 617 hiding implementation detail of which DBMS
importance of, 140–141 background, lack of a common, 84 is being used, 164
modified to remove security background processing, 212, 214 implementing, 597
vulnerabilities, 623 barely enough coding standards, 456 Brooks, Frederick, 83
performing custom, 157 barely enough modeling principle, 247, 345, 602 browser behavior, emulating, 655
providing security functions and ability to baseline, 568 budget constraints, for real-world projects, 81
battle security attacks, 622 associated with configuration items, 74 buffer overflow attack, 617
as a recursive process, 141 establishing, 74, 569 Buffered Input Stream, 422
review for, 489 baseline management, 564 bug database, using, 503
reviewing, 142, 158 baseline process (PSPO), six phases of, 26 bug fixes, 539
for a software solution similar to architectural baselines, in SCM, 563–564 build by feature, in FDD, 43
design of a building, 139 basis path builder pattern, 389, 558
as a wicked problem, 168 coverage criterion, 512 applying, 408, 410
architectural design diagrams, 66–70 defined, 510 specification of, 408, 409
architectural design patterns, 252 test method, 517 Building Secure Software: How to Avoid
architectural design process, 141–158 testing, 510–511 Security Problems the Right Way (Viega
architectural risk analysis, 613 bean class, creating a corresponding, 643, 644 and McGraw), 629
architectural style organization, for classes, 289, Beck, Kent, 648 built-in mechanism, for change, 162
291, 458 behavioral design, security in, 625 built-in type, 109
architectural styles behavioral modeling business administration and economics, 56
adapting when possible, 166 object interaction modeling (OIM) as, 248 business documents, procedures, operating
applying, 142, 147–157 performing in AUM, 49 manuals, and forms, 89
mapping system types to, 149 behavioral models, 278 business goals, identifying needs to satisfy,
architectural-level patterns, 629 behavioral patterns, 253, 254, 386 93–94
architecture, avoiding overdocumenting, 168 beta testing, 73, 538 business needs, identifying, 58–59
architecture-centric, unified process as, 25 big bang strategy, 531 business objects
association, 110–111, 113 binary association, denoting, 111 forming business-specific subsystems, 459
between actors and use cases, 187 blackboard architecture, 149, 156 invoking the constructor of, 263
between objects, 110 black-box approaches, to fuzzing, 629 as objects of the business domain, 256
association class, 108, 115–117 black-box testing, 504–510, 517, 528 business objects layer, of N-tier architecture, 158
association relationships Block Branch Diagram (BBD), 549 business operations, study of current, 59
describing properties about, 115 block diagrams, 6, 7, 66, 67 business procedures, change in, 540
identifying, 285, 287 Boehm, Barry, 22, 483, 595, 596 business processes
implementing, 460–461 Booch Diagram, 12 collecting information about, 226–227
atomic binary conditions plus one, as cyclomatic Booch Method, 39 collecting information about existing, 225
complexity, 512 border layout, 638–639 defined, 174
atomic decision, 477 bottom-up integration strategy, 532 including another business process, 190
atomic object interaction statement, 229 boundary testing, 527 nature of affecting user interface design, 308
atomic parts, 128 boundary value analysis, 505, 507–509 use case as, 173
attack patterns, identifying design flaws, 620 boundary value test, coverage criterion for, 517 working closely with customer and users to
attack trees, risk analysis with, 613–614 boundary value testing, rules for, 507, 508 understand, 246
attacks, summary of well-known, 617 boundary values, 379–380 business rule grammar, defining, 376
attributes brainstorming, 117, 119–120 business rules
of a class, 129 classifying results, 118, 120–124 changing dynamically, 375
describing and characterizing objects, 110 coordinating sessions, 134 conflicting, 381
distinguishing from objects, 110 deriving misuse cases, 620 interpreting, 378
entering from an input device, 110 effective approach to risk identification, 596 representing in a class diagram, 376–377
identifying, 281–285 environment suitable for, 579 updating dynamically, 378–379
missing, 124 length of sessions, 133 business study, in DSDM, 40
684 Index
business task, accomplishing a complete, 174 class diagram editor, 218 COCOMO 81, 583
button events, processing with Action class diagrams COCOMO model, 583
Listener, 640 classification results visualized using, 124 COCOMO II model, 583–588, 603
buttons, 297, 312 derived from the grammar, 376 code
bypass misuse, 620 editing, 175 generating from design, 459–461
modeling existing applications, 92 ownership and quality of, 467
notions and notations, 108 code analyzers, 626
C representing rules in, 376–377 Code Coverage Plugin, in NetBeans, 534
C program interface, to access a database, 634 requirements derived from, 96 code coverage tools, 652
C++, rapid spread of, 12 showing operations of a class, 126 code generation, 146, 153, 349, 375
CAD/CAM (computer-aided design and class names code inspection, detecting programming errors,
computer-aided manufacturing), 408 format for, 109 484–485
call graph, complicated, 161 in Java, 453 code optimization, 146, 153, 349
call relationships, 285, 287 class owners, in FDD, 43 code review, 612–613, 633
calls to constructors, identifying create ClassBench approach, 521–523, 535, 672 code walkthrough, 485
relationships from, 286 ClassBench test model, 672, 673 coding conventions, 452–453, 455
capability maturity model integration (CMMI), classes coding standards
474, 493, 600, 601 adding to a class diagram, 175 defining and complying to, 450–455
car rental system, described, 665–666 approaches to organizing, 458 defining barely enough, 456
case diagrams, 46 assigning to pairs, 462 described, 451–455
catalog, of a library, 300 collection of instances of, 220 easy to understand and practice, 456
cause-effect analysis, 505, 509–510 defined, 108 guidelines for practicing, 456–457
cause-effect test method, 517 dependencies between, 546 review checklist, 455–456
cause-effect testing, 527 description of, 451, 454 cohesion
chain of responsibility pattern, 311, 389, expanding with additional syntax-checking measuring degree of relevance, 164
418–419, 420, 558 operations, 401 of software, 475
change facilitating assignment to team cohesion metric, application of, 480
ease of, 143 members, 279 collaborative and cooperative approach, between
factors mandating, 539–540 identifying for the DCD, 279–281 all stakeholders as essential, 364–365, 381,
responding to, 423 identifying methods of, 281 498, 601, 628–629
as a way of life, 161 implementing, 459–460 collection, defined, 219
change control, 34, 74, 75 with low-functional cohesion, 161 collective code ownership, improving
change control board (CCB), 75 misidentifying as attribute types, 126 teamwork, 467
change identification and analysis, 542, 544–547 missing, 124 combined fragment, defined, 219
change impact, 545, 567 notion of, 107 combined risk exposure, with no design for
change impact analysis, 545, 546 organizing with package diagram, 288–291 change, 598
change impact analysis tools, 559 of a package, 159 command classes, prototype pattern reducing
Change Impact Analysis utility, 549 reducing number of, 444–447 the number of, 445, 447
change implementation, testing, and relationships between, 285 command line CVS commands, listing of,
delivery, 542 representing, 108–109 656, 657
changes representing instances of, 218–220 command objects, encapsulating requests
analyzing, 569 unnamed instances of, 219 as, 433
difficult using nested-switch approach, 335 without any attributes, 129 command pattern, 311, 389, 558
implementing, 547 classical OO methodologies, 39 ability to undo or redo a command, 431–433
improving ability to adapt to, 550 classification, 133, 300 applying to design of the persistence
logging and redoing during system recovery, codes, 121 framework, 434–435
434 process, 107 implementing the individual operations
merging from repository, 662 result, 126, 132 accessing the database, 431–435
to requirements, 101 rules, 121 situations applicable to, 433–434
to a SCI affecting other SCIs, 567 sessions, 133, 134 specification of, 431, 432
chart-oriented widget, 299 systems, 54 commercial off-the-shelf (COTS) components,
check point pattern, 610, 611, 622 ClearCase. See IBM ClearCase 188, 583
Checked Input Stream, 422 client interface, 429, 553 commercial off-the-shelf (COTS) parts, 61, 143
Checkout Document use case, 221–222 clients, 139, 151, 445, 447 common code, sharing with template method,
CheckoutController class, 460 client-server architecture, 139, 147, 149, 439–442
Checkstyle tool, 499 150–151 common coupling, 243
Chidamber & Kemerer Java Metrics tool, 499 client-server system, 149 Common Development and Distribution License
chief programmer team structure, 43, 580 closed regions plus one, obtaining the (CDDL), 647
child subroutines, calling, 152 cyclomatic complexity, 511 common interface, 164
Cigital SecureAssist(R) tool, 628 cloud computing architecture, 157 communication, critical for software
Cipher Input Stream, 422–423 CMMI level 1 to level 5 improvement, 493. See development, 576
civil engineering, 55 also capability maturity model integration communication barriers, 84, 100
class adapter, 415, 416, 417 (CMMI) communication diagram, 218
class attribute operation, 108 Cobertura coverage tool, 465, 653–654, 672 communication overhead, 579
Index 685
communication partition, 181, 183 concurrency control, 571 contingencies, negatively impacting a software
community resources, using, 610 Concurrent Versions System (CVS), 571, 572 project, 595
compact view, of a class, 108–109 importing files into a remote repository, continuing change, law of, 540
company-specific standards, 451 663, 664 continuing growth, law of, 541
compartmentalization, 609 merging files, 662 contract negotiation phase, 33
compiler, 146, 349 in NetBeans, 656–658 control coupling, 165
completeness performing version control tasks in NetBeans, avoiding, 243
checks, 488 659–661 defined, 243
of a decision table, 373 remote repository, 656–658 eliminated, 244
complex activities, refining, 357, 362–363 condition entries, in a decision table, 368 exhibiting design, 243, 244
complex behavior, reasons for, 345 condition list, in a business rule grammar, 376 control flow, 340
complex objects, creating and constructing, 387, condition stubs, in a decision table, 368 models, 544
404–411 conditional branching, 357, 362 relationships, 39
complex structures configuration auditing function, 75 control process, transformational schema,
accessing with iterator, 395–398, 399 configuration change control board (CCCB), 569 339–340
analyzing with visitor, 398–400, 402 configuration change control (CCC), 542, 547 control variable, 165
working with, 387, 391–403 configuration change control function, 75 controller classes, named after use cases, 148
complexity, increasing, 606 configuration item management aspect, of controller layer, 148
complexity attribute, of software, 470 SCM, 565 controller pattern, 167, 254–266, 274, 558
complexity levels, determining, 583, 584 configuration item validation, 75, 570 controllers
complexity metrics, 481, 550 configuration item verification, 75, 570 avoiding overloading, 266
complexity weights, 583, 584 configuration items described, 258
component interaction, simplifying with classified, 566–567 guidelines for using, 265–266
mediator, 553–554 controlling changes to, 564 overloaded, 263
component substate, of another state, 327 identifying, 74 types of, 261
component under test (CUT), 379–380, 504 set of attributes and operations, 567–568 using the pattern template, 259
exception-handling capabilities of, 524 configuration management, in an agile working with databases, 427
mutations to, 534 project, 570 conventional approaches, drawbacks of, 335
component-level programs, guiding the configuration management tools, 559 conventional black-box testing, 504–510
development of, 25 configuration setting dialog box, 297 conventional metrics for object-oriented
composite concurrent state (CCS), 331 configuration status reporting function, 75 software, reusing, 480
composite configuration item, 568 conflicts, resolving, 663 conventional processes, compared to agile
composite parts, 128 conformance guideline, 128 processes, 491–492
composite pattern, 128, 389, 558 connectivity, 606 conventional quality metrics, 474–480
applying bringing advantages, 392 conservation of familiarity, law of, 541 conventional white-box testing, 510–516
specification of, 392, 393 conservation of organizational stability, conventions, leaving decision to the
composite sequential state (CSS), 331 law of, 541 programmer, 452
composite software configuration items consistency conversion rules, from classified result to class
(Composite SCI), 567 of a decision table, 373 diagram, 124, 125
composite states, 391 in look and feel, 312 cooking, eat your own, 313
compound object interaction statement, 229 consistency checks, 488 core functionality, use cases exhibiting, 188
comprehensive documentation. See working consolidated decision table, 374 corrective maintenance, 541
software constants, names for as all capital, 453 cost drivers, for the post-architecture
Compromise an Account attack tree, 614 constraints model, 587
computation use (c-use), 514 compared to requirements, 82 cost-benefit analysis, 616, 617
computational complexity or the big oh defined, 81 coupling, of software, 471
notation, 472 deriving, 92–97 Coupling Between Object Classes (CBO), 483
computer applications, expansion of, 606 for event-driven systems, 145 coupling metric, application of, 480
Computer Emergency Response Team numbering, 96–97 create relationship, 285
Coordination Center (CERT/CC), restricting solution space, 60 creational patterns, 253, 386
606, 607 stringent real-time, 17 creator pattern, 270–273, 274
computer science, 13–14, 55 construction, software architecture facilitating, critical path, identifying, 591–592
computer-based systems, 54 158–159 critical/high priority components first
computers, expanding use of, 2 construction phase, of the unified process, 24 strategy, 532
concatenated loops, 513–514 container widgets, 297 cruise control
conceptual systems, 54 containment relationships, identifying, 287–288 with concepts identified, 324
conceptualization, 4, 158 content pane, 638 constructing a state transition table for,
conceptualization process, of domain context 328–329
modeling, 106 constructing a domain model to show, domain model, 326–327
conceptualization relationships, 285 325–327 software, modeling of, 341
concrete command classes, 439 of a software subsystem, 71 state diagram, 332
concrete decorators, 422 context diagram, 39, 71–72 state pattern, 338
concrete layout algorithms, 395 context domain model, 71 state transition table, 331–332
concrete tests, generating, 520 context-dependent help, 311, 418–420 Crystal Orange, 45
686 Index
Curricular Practical Training, activity databases assessing with respect to software design
diagram, 361 accessing from a program, 635–636 principles, 264
c-use, define-use path, 514 connecting to, 635 converted into source code, 450
customer and users disconnecting from, 636 decisions, 139
identifying and modeling state behavior, 344 hiding with a DB manager, 427 by feature in FDD, 43
involving in gathering and analyzing business locating at remote sites, 435 generating code from, 459–461
rules, 380–381 persistence framework, 155 principles for user interface design, 312
working closely with, 134–135, 195 querying, 635 software solution-oriented, 222
customer collaboration DBMgr, 459 design and build iteration, of DSDM, 40
emphasizing, 84 DBMgr object, 272 design and implementation concepts, ignoring
as imperative, 100 DCD. See design class diagram (DCD) during brainstorming, 119
valued over contract negotiation, 33–34, dead state, 330 design artifacts, integrating into one design
601, 628 death phase, in XP, 44 blueprint, 278
customer presentation, 59, 88–89, 226, 358 debugging, 517, 518 design class diagram (DCD), 226
customer representatives, interviewing, 89–90 debugging message, 311 with attributes identified, 285
customer review, 100, 488 decision node, in a flowchart, 352 change impact analysis using, 546
customers and users, not knowing what software decision table construction defined, 276, 277
can do, 84 algorithm, 374 defining classes of objects, 234
CUT. See component under test (CUT) progressive, 371–373 deriving, 49–50, 276–292
CVS. See Concurrent Versions System (CVS) systematic, 370–371 with methods filled in, 283
cycles, in the unified process, 23 decision tables not showing ordinary get and set
cyclomatic complexity, 472, 550 advantages of, 370 methods, 278
computing, 653 completeness of, 373 with relationships and degree of call
determining, 511–512 consistent, 373 dependency, 288
metric, 476, 479 consolidation, 374 review checklist, 288
of nested-switch approach, 335 described, 368–369 tool support for, 292
evaluating options, 597, 598 usefulness of, 278–279
facilitating test-driven development of design complexity metrics, 476, 477–478
D business rules, 381 design for change principle, 150, 161–162,
data collection methods, defining, 496–497 generating test cases, 509 259–260, 264, 391, 597, 598
data coupling, preferring over stamp inconsistent, 373 design for security, 608, 615
coupling, 241 nonredundant, 373–374 design issue, objects interacting in proposed
data define-use, identifying, 514 parts of, 368 system, 217
data entry, defects in, 529 in test-driven development, 379–380 design metrics (D), 475–479
data flow diagrams (DFDs), 353–354 usefulness of, 369–370 design models, prescribing a software
for IDE, 153–154 decision trees, 380, 597, 598 solution, 223
modeling business processes of, 39 decision-making activity, 362 design objectives, determining, 142
processes classified into three broad decisions, made by consensus, 579 design patterns
categories, 152 declining quality, law of, 541 applying, 166
data flow relationships, 39 decomposition, 354 architectural styles, 167
data flow testing, 514–515, 527 decomposition pattern, 611 benefits and liabilities, 167
data members of a class, making decorator pattern, 389, 420, 421, 422 defined, 252
private, 163 decorator visitor pattern, 558 described, 167, 252–253
data sets, automatic backup of deep history state, 331, 344 reasons for, 253
important, 311 Defect Recording Log form, of PSP, 27–28, 631 design phase, 222–223, 489
data sources, setting up, 634–635 defense in depth, practicing, 609 design problem
data store, 353 defer to kernel design pattern, 610, 611, commonly encountered, 252
Database (DB) manager (DBMgr), database 612, 625 search patterns to solve, 388
access responsibilities, 429 define-use relationships, of selected program design process, performing recursively, 141
database access code, duplicated, 427 variables, 514 design sequence diagram, 222, 265
database access objects, 266 definition incompleteness, 99 design solution, 252
database connectivity, 634–636 Delphi estimation method, 588–589, 599 design space, restrictions on, 223
database management systems (DBMS), types denial of service attack, 617 design specification, 11
of, 162 dependencies design templates, in PSP, 633
database manager, providing an object-oriented between classes, 285, 546 designing “stupid objects,” 150
interface, 155–156 between use cases, 191 design-level patterns, 629
database operations, one-to-one correspondence deployment design-oriented relationships, 285
with Concrete Commands, 435 in FDD, 43 destination-coded vehicles (DCV), 53
database queries, embedded in the procedural security in, 625–627 Developed for Reusability (RUSE), 586
programs, 426 Depth of Inheritance Tree (DIT), 481–482 development activities, 3
database requests, encapsulating as commands, Derive Use Case button, 197 development team, 84, 217
431–435, 436 design development time (TDEV), computing, 588
database subsystems, 143, 144, 147, 459 abstraction, 252 diagram beautify process, sharing steps with
database wrapper, 141 activity, performing as usual, 388 reverse-engineering process, 408
Index 687
diagram editor, portion of the state-dependent reviewing, 118 editing operations, exhibiting state-dependent
behavior of, 411 for SQA functions, 495, 496 behavior, 411
diagram editors using a UML class diagram, 48 editing states, keeping track of, 411–412
for UML diagrams, 135 visualizing, 118, 124–129, 132 Editor GUI Java code, 414, 415
user interface design for, 301–302 walkthrough, 488 Editor GUI object, processing events, 412
Diagram Element class, 392, 404 domain modeling, 276 Editor Main Window, Java implementation of
diagram elements, accessing, 395–396 capturing security-related domain concepts, the layout design for, 305
Diagram Generator component, 158 615, 616 efficiency, 470, 527, 550
diagram modeling notations, correct and conducting, 47–48 effort calculation, 583, 584–585
incorrect uses of, 224–225 defined, 106 effort estimation, 10
diagram-oriented widget, 299 described, 105–106 DCD useful for, 279
diagrams guidelines for, 133–134 methods, 580–591
reviewing, 176 performing only to understand the application in PSP, 631–632
types of, 66 domain, 135 and schedule for testing, 531
dialog boxes, 297 reasons for, 106–107 tools, 559
draft design of, 301 security in, 624 egoless team structure, 579–580
identifying, 304 similar to a child’s perception of the 80-20 rule. See 20/80 rule
layout design for, 294 world, 108 elaboration phase, of the unified process, 24
minimizing the number of, 297 steps applied to an example, 130–132 elapsed time, 592–593
digital camera, using during brainstorming and steps for, 117–129 electrical and electronic engineering, 55
classifying, 133–134 tool support for, 135–137 embedded systems, 5
digital watch, state diagram for, 347 domain relevant concepts, focusing on, 119 event-driven subsystems in, 146
digraph, 591 Domain Software Engineering Environment examples of, 53
Dijkstra, Edsger, 162 (DSEE), 571 large, complex, long-lasting, 19
direct database access, problems with, 427 domain specific concepts, focusing on, 119 software testing invaluable for, 503
direct physical access, insiders having, 616 domain-relevant phrases, identifying, 119 system development involving many
directed edge, 352, 353 domain-specific verb-noun phrase, as a use engineering and nonengineering
directory structures case, 177 disciplines, 55
deciding on, 457 dotted numbers, labeling requirements and using application specific integrated circuits
result of applying the architectural-style constraints, 96 (ASIC) and firmware, 3
functional subsystem organization, 459 draft layout design, producing, 304–306 emergency maintenance, 541
for a .war file, 645 drawing capabilities, implementing, 640–641 Emma coverage tool, 652–653
dispatching processes, 152 driver, and observer, 462 encapsulating, database requests as commands,
display capability, enhancing with decorator, DSDM method, 45 431–435, 436
420–423 DSDM process, five phases of, 40, 42 end users, not wanting inconvenience associated
distributed, decentralized system, 149 due date, computing involving at least three with security procedures, 628
divide-and-conquer approach objects, 269 engineering change proposal (ECP), 75,
decomposing a large project, 632 duplicate code, in many command classes, 547, 569
top-down, 56, 61 439–440 engineering disciplines, decomposing the
divide-and-conquer software engineering dynamic approaches system according to, 64
principle, 354 to software security, 626 engineering teams
do no more than needed principle, 296 to testing, 626 collaboration of, 73
do not show exception handling, 208–209 to user interface prototyping, 307–308 enabling separate to develop subsystems, 61
documentation dynamic systems development method enhancement
defects in, 529 (DSDM), 36, 40, 41, 42, 570 as one type of evolution, 257
describing activities, 362 dynamic validation, 10, 484 to the system, 538
function-based format requiring enhancement maintenance, 541
high-quality, 579 enterprise resource planning (ERP) systems
of requirements and constraints, 97, 98 E activity diagrams useful for, 351
documents needed, for testing, 531 earliest start time, of each milestone, 592 system engineering approach needed for, 53
domain concept, defining, 119 early design model, 584–587 equivalence partitioning, 505–507
domain experts, interviewing, 89–90 easy to learn and use, GUIs, 294 error handling, defects in, 529
domain knowledge, modeling as a tool to eavesdropping attack, 617 error messages, design of, 311
acquire, 91 Eclipse Metrics Plug-in tools, 499 errors, in JUnit, 652
domain model edge coverage criterion, 512, 522 The Essential Guide to User Interface Design
attributes indentifying from, 284 Edit Class Diagram use case, 175 (Galitz), 315
constructing, 321, 325–327 Edit Controller, 403, 640 estimated effort, obtaining, 582
identifying additional relationships edit decision table dialog, implementing, 378 estimation and planning, processes
from, 288 edit diagram use case, 175 introducing, 25
identifying and resolving differences in Edit State Diagram, expanded use case, 302 estimation methods, used with PSP, 631
perception, 106–107 Edit State Diagram use case, major system ethnography, increasing popularity in
looking up objects in, 234 displays for, 303 requirements gathering, 90
reusing information from, 203 Edit State Dialog, design of, 305–306 E-type of systems, 540
review checklist, 129 editing events, responding to, 412–414 event-absent transitions, 327–328
688 Index
event-driven subsystems, 143, 145–146 facade pattern, 389, 553, 554, 555 forking node, 356
event-driven system architecture (EDSA), 148, Facilities (FCIL), 587 formal analysis, 548
149, 154–155 factors, mandating change, 539–540 formal state diagram, for the thermostat
event-driven systems, 141, 149, 318–346 factory method pattern, 389, 442–444, 558 control, 333
events fail securely principle, 625 formally specified sequence diagram, as a result
categories of, 320 failures of conversion, 245
causing changes to a system, 161–162 in JUnit, 651–652 format, for coding standards, 452, 453
defined, 320 in a secure state, 609 formatting conventions, 453, 454
identifying changes required by various, false alarms, 626 formatting processes, 152
568–569 false negatives, few tools reporting, 626 forms, studying, 227, 359
translating into function signatures, 333–334 false positives, producing too many, 626 forward-engineering, 407–408, 548
evolutionary approach, of PSP, 25 fan-in metric, application of, 480 four blind men and an elephant story, 4
evolutionary process model, 22 fan-out metric, application of, 480 framework, for ensuring software quality,
evolutionary prototyping process model, 22 fault tree, 613 490–491
evolving, architecture providing a basis for, 159 FDD. See Feature Driven Development (FDD) free text input, 298
exception handling, 212, 214, 343, 524–525 method full reuse model, 542–543
exceptional cases, 208, 519 feasibility checks, 488 function point (FP), of a system, 581
executed command stack, storing commands, 433 feasibility study, 60 function point method, 581–583
execution sequence of actions, changing conducting, 97, 99 function points, 582, 585
dynamically, 434 in DSDM, 40 function type complexity, 585
existing architecture, decomposing the system performing during requirements analysis, 82 functional activities, allowing function-oriented
according to, 64 Feature Driven Development (FDD) method, 41, project organization, 19
existing scenario, applying controller pattern by 43, 45, 570, 580 functional clusters, system requirements
modifying, 265 feature list, building in FDD, 43 partitioned into, 63, 64
existing systems, user interfaces of, 308 features functional cohesion, checking, 65
expanded misuse cases, 627 of a class, 109 functional models, 544
expanded use case specification completing before moving on, 36, 466 functional requirements, 85, 95–96
problematic, 212 implementing and testing, 464, 465 Functional Specification Template, in PSP, 633
using UI prototypes, 205 selecting and writing tests for, 464–465 functional subsystem architectural-style
expanded use cases, 48–49, 200, 227 feedback systems, law of, 540, 541 organization, 289–290, 458
including another use case, 210 Feng Office tool, 603 functional subsystem organization, for classes,
initializing, 203 Fibonacci numbers, providing room for possible 289, 290
for a library information system, 201 error, 590 functional subsystems, deriving, 63, 64
not showing background processing and field-detect defects, information about, 495 functional testing, example, 504–510
exception handling, 214 15-minute daily Scrum meeting, 43 functionality, of each subsystem well-defined, 61
with references to UI exhibits, 207 file header, 451, 452, 453 function-based format, 578–579
reviewing, 204 file revisions, comparing, 662 functions
specifying alternative flows in, 205 file status, viewing, 662 communicating through a global data area or
specifying normal interaction between an files global variable, 243
actor and the system, 208 checking out from a remote repository, complexity of, 473
for Transfer Funds with a Check use case, 211 659–661 of software systems, 139
UI prototypes and, 205, 207 editing, 661 future problems, changes to prevent, 540
expanded view, of a class, 108–109 importing into a repository, 664 fuzzing, 629
expected benefit, 616–617 merging from repository with local
expected estimate, deriving, 598–599 copies, 662
expert pattern, 267–270 Filter Input Stream decorator, 422, 423 G
expert review, 99, 488 FilterInputStream, decorator, 423 Gamma, Erich, 648
exploration phase, in XP, 44 filters, interconnected by data streams Gang of Four (GoF) patterns, 252, 386
extend relationship, between use cases, 189, 190 (pipes), 156 Gantt chart, 593–594
extension relationship, between use cases, 187 final state, 331 General Public License (GPL), 647
extensional definition, defined, 107 FindBugs tool, 499, 628 general responsibility-assignment patterns.
external coupling, 243 finite state machine, ClassBench test model See GRASP (general responsibility
external entities, 144, 353 as, 522 assignment software patterns)
external incompleteness, 99 finite state model, of an integer set, 522 generalization, 114
external inputs, 585 Firesmith, Donald, 608 Generate Diagram button, 197, 198
external interface files, 585 flat state diagram, 301–302, 390 generic software testing process, 517–518
external outputs, 585 flow graph, 500, 510–511, 512 generic web model, for testing web
external queries, 585 flowcharts, 352, 500 applications, 525
extreme programming (XP), 36, 41, 44 FlowLayout, 638 genetic algorithm-based testing, 528
flyweight pattern, 389, 410–411, 558 get and set methods, identifying attributes from
forking ordinary, 282–283
F in the activity diagram, 361 Get Class Diagram, compared with Get State
facade controller, 261, 262–263, 265 introduced to specify parallel activities, 362 Diagram, 444, 445
facade mediator pattern, 558 introducing, 357 get command classes, 444
Index 689
get object messages, identifying relationships high-priority needs, identifying, 87 inconsistency, technical review revealing, 99
from, 287 high-priority risks, 599 inconsistent business logic, 485
GetDiagram database access command, partial history state modeling concept, 343 inconsistent decision table, 373
code for, 447 Hoffman, D., 521 inconsistent transition, 330
global data repository, 156 horizontal scroll bar, 297 incorrect business logic, 484
GoF patterns, 253 HP WinRunner, 534 increasing entropy or complexity, law of,
gold-plating, 596 html code, with scriptlets, 645 540, 541
good enough is enough rule, 36, 101, 168, 196, HTML page, containing a form, 643, 644 incremental, unified process as, 25
214, 291, 314, 345, 424, 497, 555, 589, HttpUnit open source software, 527, 655–656 incremental phase
602, 627 hybrid approaches change to functional as well as security
Google Apps, as an example of SaaS, 157 for classes, 289 requirements, 615
goto statement, uncontrolled use of, 13 to user interface prototyping, 308 security in, 623–627
government policies and regulations, change hybrid format, for project management, 579 increments, focusing on frequent delivery of
in, 539 hybrid organization, of classes, 458 small, 196
grammar, for shipping business rules, 376 independent existence, of an object, 110
graphical editor (GED), 669–670 indicators, 473, 497
graphical user interfaces (GUIs), 534 I indifference, 368
characteristics of, 294 IBM ClearCase, 571, 572 indirection pattern, 274
composed of GUI widgets, 296 IBM Rational ClearCase. See IBM ClearCase individual accountability, 616
layers, 148 IBM Rational DOORS, 101–102 individuals, assigning responsibilities to, 457
programming with Swing, 636 IBM Rational Logiscope tool, 499 individuals and interactions, valued over
GRASP (general responsibility assignment IBM Rational RequisitePro, 101 processes and tools, 30, 32, 602
software patterns), 169, 254, 274, 386 IBM Rational Team Concert, 603 infeasibility, technical review revealing, 99
grid layout, 638, 639 ID number, identifying the SCI, 567 informal or analysis sequence diagrams,
gross function point (GFP), 581 IDE. See integrated development converting to design sequence
guard conditions, 323, 334 environment (IDE) diagrams, 240
GUI layer, presenting information, 149 identification and classification rules, for state informal sequence diagram, 222, 239, 240, 245
GUI objects, decoupled from business behavior, 322 informal specification, of business rules, 367
objects, 312 identification requirements, 608 informal state diagram, converting to a formal
GUI widgets, 149, 298–300 IEEE. See Institute of Electrical and Electronics one, 333–334
guidelines, as lower-level principles, 312 Engineers (IEEE) informal style of scenario specification, 237
if-then-else sequential blocks, 510 informally specified message, 241, 242
if-then-else statements, 383, 404 information, collecting about the application,
H image-oriented widget, 299 87–91
Halkidis, Spyros, 610 immunity requirements, 608 information collection, 59, 226–227, 358
happenings, 320 implementation information expert pattern, 274. See also expert
hardware devices, states of each, 326 considerations for, 450–468 pattern
hardware-software interfaces security in, 625–627 information hiding, 150
in embedded systems, 70 testing, 547 information hiding principle, 163–164, 261, 264
requirements, 86 tool support for, 467 information presentation schemes, design of, 294
help facility, defects in, 529 implementation and unit testing phase, 9, 532 information processing activities,
help request handlers, hierarchy of, 311 implementation artifacts, organizing, 457–459 identifying, 356
heuristic problem solving system, 149 implementation metrics, 479 information-collection techniques, 88–91, 118,
hiding secret is hard, 610, 625 implementation phase 358, 616
hierarchical team structure, 580 of DSDM, 42 inheritance, 108, 113, 114, 523
hierarchy of subsystems, 60–61 verification and validation in, 489–490 compared to polymorphism, 114–115
high cohesion, 150 implementation work, assigning to team defined, 187, 188
high cohesion pattern, 274 members, 461–462 using, 127–129
high cohesion principle, 164–165, 260–261 implementation-based misuse, 620 inheritance hierarchy, testing, 523
assessing designs, 264 implementation-level patterns, 625, 629 inheritance relationship, 127, 181, 327
violating, 257 implicit correspondence assumption problem, initial state, 201, 331
high coupling 115–116 initial system display, no specification of, 211
increasing uncertainty of run-time effect and Import wizard, 663, 664 input fuzzing, 528
change impact, 165 impossible transition, 330 input manipulation attack, 617
problem, 161 improvement actions, recommending, 497 input space, rules for partitioning, 506
high functional cohesion, subsystems exhibiting, improvement strategy, selecting, 551 Input Stream, 422, 423
180–181 improvements input validation pattern, 611, 625
higher-level modules, calling lower-level implementing proposed, 551 input values, 519, 520
modules, 164 quantitative assessment of, 474 input widgets, 298
high-level use cases, 184, 185, 200 inception phase, in the unified process, 24 inside out approach, for requirements
reviewing, 191 inclusion relationship, between use cases, 187 elicitation, 90
specifications, 193 in-code comment conventions, 453, 455 insider misuses, 616
specifying, 185–186 incomplete business logic, 485 inspection, 484–485
highlight conventions, for rules, 323 incompleteness, technical review revealing, 99 instance names and types, 237, 239–240
690 Index
instance types, rules applied to determine, 240 interoperability, of software, 471 Journal of Software Maintenance and
instance variables, omitted when writing interpretation approach, merits of, 379 Evolution, 560
scenarios, 222 interpreter pattern, 389, 559 JPanel, 638, 640
instances applying, 375–379 JPanel object, 638
of an association, 111 benefits of, 379 jsp extension, 642
of a class, format for, 109 implementing a decision table, 370 JSP pages
instantiation relationship, 285 steps in applying, 376 testing, 655
Institute of Electrical and Electronics Engineers interprocedural data flow testing, 515–516 using, 643–646
(IEEE) interrupt handling, 343–344 jsptest.war file, placing in the appropriate
International Conference on Software interviews, 89–90 directory, 645
Maintenance proceedings, 560 InterViews library, 544 JUnit testing tool, 36, 465
quality model, 471, 493 intractability, technical review revealing, 99 integrating, 672
Standard 610.12-1991, 539 intraprocedural data flow testing, 515 running with NetBeans, 652
Std 830-1998 SRS standard, 97, 98 intrusion attack, 617 used for implementing and running tests for
1219 model, 543 intrusion detection requirements, 608 Java programs, 505
integrated development environment (IDE), 647 IntSet class, test model for, 522 using, 648–652
configuring to use HttpUnit, 655 invalid input, for test cases, 519
design of, 152 invocation chains, in the InterViews library, 544
generating code skeletons from UML irrelevant responsibilities, assigning with too K
diagrams, 459 many, 266 keep it simple and stupid (KISS) principle, 166,
including a project pane, a navigation pane, ISA guideline, 128 193, 213, 248, 264, 265, 296, 312, 497,
and a content pane, 294 IS-A relationship, 114, 188 609, 627
NetBeans, 12 ISO 9000 Standards, 600 keyboard mode, minimizing switching from, 312
open source, 647 ISO 9001, 474, 493
providing reverse engineering ISO Seven Layer Model, 149
capabilities, 407–408 ISO-12207 model, 543 L
supporting software development iterations Lack of Cohesion in Methods (LCOM), 483
activities, 467 allocating use cases to, 191–192 large complex objects, building, 407–409
integration and system testing, conventional of each cycle, 23–24 large-scale integrated circuits (VLSIC), 55
processes compared to agile, 492 to first release phase in XP, 44 Larman, Craig, 254
integration complexity metric, 476, 478–479 iterative, unified process as, 25 latest completion time, of each milestone, 592
integration nightmare, 532 iterative enhancement model, 542, 543 layered panes, 297
integration phase, 9 iterative phase, of AUM, 46, 47 layout algorithms, applicable to state
integration test plan, 531 iterative process, 233 diagrams, 395
integration testing, 10, 58 iterator pattern, 164, 389, 396, 399, 559 layout designs
integration testing phase, components tested, for user interfaces of IDEs and document
531–532 editors, 305
integrity requirements, 608 J for windows and dialog boxes, 294
intentional definition, 107–108 Java, classes stored in java files, 453 layout managers, using to arrange components,
interaction behavior Java Abstract Window Toolkit (AWT), Swing an 638–639
design of, 294 extension of, 636 layouts, three basic, 638
specifying, 301, 306–307 Java bean, 643 lazy evaluation, 296
interaction diagrams, 218 Java bean class, attributes and methods of, 526 LDAP (Lightweight Directory Access Protocol)
interactive subsystem, behavior of, 143 Java code, using the Action Listener hierarchical database, 162, 429, 430
interactive systems, 149 interface, 414 leaf-level processes, easily implemented, 39
containing several subsystems, 147 Java Compiler Compiler (JavaCC), 377 leaf-level requirement rows, in a traceability
interaction between the system and an Java Data Base Connectivity (JDBC), database matrix, 65
actor, 144 access interface for Java, 634 Lean Development, 45
most common, 144–145 Java reflection, filling attributes of the diagram least privilege, 609, 616
properties of, 144 object, 445 Lehman’s laws of system evolution, 540–541
using N-tier architecture, 141 Java Server Pages (JSP) levels, of the Capability Maturity Model
interdisciplinary approach, to system getting started with, 642–646 Integration, 600
development, 56 workflow, 642–643 lexical analysis, 146, 152–153, 349
interface design, evaluating with the users, 309 Java technologies, commonly used, 634–646 library information system (LIS), 46–47, 48, 159
interface programming construct, introduction JavaDoc, generating html pages as online life cycle
of, 164 documentation, 455 integrating testing throughout, 534
interface requirements, 86 JCoverage, 653 software security in, 614–627
interfaces, 585 JDBC API, 634 verification and validation in, 487–490
converting, 414–417 JDBC/ODBC bridge, 634 life-cycle activities, 9, 529
implementing, 459–460 JFrame, creating main window with, lifeline, defined, 219
internal incompleteness, 99 637–638 lightweight unified process (LUP), 45
internal logical files, 585 Jindent tool, 499 linear function, produced by PROBE, 632
International Standards Organization (ISO), joining, 357, 362 lines of code metric, 476, 479, 480
quality model, 471 joining node, 356 literature survey, 59, 226–227, 358
Index 691
local copies, updating, 663 menu items, 297, 312 most likely estimates, 589
local files, committing to a repository, 663 menus, 297 mouse events, Edit Controller handling, 640
Logic Specification Template, in PSP, 633 Merge Conflicts Resolver, invoking, 663 mouse mode, minimizing switching from, 312
logical inconsistency, 99 message passing, 219, 237 MS Project, 603
logical organization or logical architecture, 159 messages, objects sending or receiving, 279 MuJava, 534
Login sequence diagram, 268 method execution, defined, 219 multiplicity
Login use case, 210, 220 method implementation approach, to of a class, 112
long list, partitioning into a hierarchy of shorter implementing state behavior, 335 missing, 124
lists, 299–300 methodology multiplicity assertions, symbols for expressing
loops, 512–514 benefits of, 38–39 various, 112
loss magnitude, 597 compared to process, 37–38 mutations, to the CUT, 534
loss probability, 597 defining the steps, 37 mutual exclusion, Petri net modeling, 353
low coupling pattern, 274 required for software development, 16 mutual understanding, with the customer, 34
low coupling principle, 165, 264 steps presented so far, 276–277
low functional cohesion, 160 methods. See also specific methods
lower-level subroutines, calling, 152 identifying, 281 N
identifying attributes from computing a scalar named instance
type value, 283 of a named class, 218, 219, 220
M metric calculation tool, of OOTWorks, 552 of an unnamed class, 218, 219
Main class, creating an instance of SDEFrame, metrics, 496–497 naming conventions, 452–453
637–638 metrics and indicators, definition of for n-ary relationships, representing, 123
main program and subroutines architecture, 144, measuring and assessing software quality, National Health System (NHS) project, 577
147–148, 149, 151–154 494 national trade show service system, 666–667
main window, creating, 637–638 metrics calculation class, high complexity of natural language, leading to misunderstanding, 4
maintainability, of software, 471 one method of, 552 natural systems, 54
maintenance metrics calculation tools, 557 needs, 93–94
aimed at obtaining perfect architecture, 555 microcontroller integrated circuit (IC), 70, 155 neglected event, 330
ease of, 143 Microsoft Access, setting up data sources, nested loops, 513
maintenance challenge, from system changes, 18 634–635 nested-switch implementation approach, 334–335
maintenance phase milestones, 563 Net Mgr, 459
requirements change during, 101 missing information, identifying in classification NetBeans, 647–648
software entering, 9 results, 123–124 Code Coverage Plugin, 534
in XP, 44 mission-critical subsystem, design of, 157 configuring to use HttpUnit, 655
maintenance process models, 542–543 misuse cases, 613 integrated development environment (IDE), 12
major system displays, identifying, 302–304 deriving, 615, 621–622 performing version control tasks in, 659–664
management support, essential for software generating security test cases, 620 running a test case in, 656
quality assurance, 498 identifying, 619–622 running JUnit within, 652
managing, software architecture providing view for security test case generation, 627 setting up Subversion in, 658–659
for organizing, 159 misuses, of aggregation, 126–127 using CVS and Subversion in, 656–664
man-in-the-middle attack, 617 mobile transceivers, 670 viewing unit test results in, 654
man-made systems, 54 model, of baseline and configuration items, work areas of, 647–648
manual identification and manual classification, 566–567 network access, hiding with remote proxy,
136, 137, 197 Model Concept List pane, 137 435–439
many-to-many association, between classes, 461 modeling network communication functions, 435–436
mapping as a conceptualization and visualization network communication layer, of N-tier
between the design and bridge pattern, 429, 430 process, 91 architecture, 159
between editor and pattern classes, 392, 395 extensive doing more harm than good, 246 network communication protocols, 427
between the sample state machine and pattern of interobject behavior, 318 new object points (NOPs), computing, 583
classes, 335, 337 as an iterative process, 135 nice feature, may not be that nice, 313
marshalling, 427, 435 just barely enough, 101 no stopping rule, 184
material flows, showing, 68–70 skipping, 247 node coverage criterion, 512, 522
McCabe IQ Developers Edition tool, 499 modeling and analysis, for security, 607 nondeterministic transitions, 330
McGraw, Gary, 609 models, useful for deriving requirements, 94–96 nonfunctional requirements, 85, 86, 471,
Mealy type state machine, 339 model-view-controller (MVC) architecture, 139 527–529
meaningless names, 452 model-view-controller (MVC) pattern, 167, 255 nonredundant decision table, 373–374
measurements, compared to metrics, 472 modular design, facilitating system nonrepudiation requirements, 608
mechanical engineering, 55 maintenance, 61 nonterminal nodes, representing condition
mediator pattern, 389, 553–554, 556, 557 modularity, of software, 471 entries, 380
medical record management systems, ensuring modularity metric, application of, 480 nontrivial steps
accuracy and security, 308 module design complexity, calculating, 477 of expanded use cases, 225
memento pattern, 157, 311, 389, 403 modules identifying, 227–228
memory-intensive components, identifying, 557 degree of dependency between, 165 requiring background processing, 228
mental models, representing design and measuring size of, 472 writing a scenario for, 232
specification artifacts, 544 monitoring, risk, 599 writing scenarios for, 228–230
692 Index
persistence framework, 141, 426–448 preliminary activity diagram, 357, 360–362 project baselines, establishing, 75
persistence framework architecture, 148, preliminary user’s manual, 202, 205 project challenges, examples of, 17
155–156 presentation, 255–257 project descriptions, 665–674
persistence storage, hiding with bridge, 428–431 presentation layer, of N-tier architecture, 158 project format, 578
persistence storage layer, of N-tier prioritizing, requirements, 82, 97 project management
architecture, 158 privacy activities, 3, 10–11
persistent object, loading into memory when protecting, 609 importance of, 577
first referenced, 438 requirements, 608 requiring progress status information,
personal interviews, with users, 358–359 private collection, choosing carefully, 461 562–563
personal preferences, of the users, 309 privilege reduction pattern, 611, 612 tools supporting, 602–603
personal software process (PSP), 25–28, privilege separation pattern, 611, 612 project metrics, 472
631–633 problem-directed approach, for applying project organization, 577–580
person-month effort, computing, 583 patterns, 387 Project Plan Summary form, of PSP, 26, 28, 29
Personnel Capability (PERS), 586 problem-directed process, for applying project planning and scheduling, 10–11,
Personnel Experience (PREX), 587 situation-specific patterns, 388 591–595
PERT chart, construction of a Gantt chart from, problems. See also wicked problems project status and schedule, facilitating
593–594 commonly seen, 211–213 monitoring of, 593
pessimist estimates, 589 design, 252, 388 project-based format, 578
Petri, C. A., 352 future, 540 projection, of U on C, 109
Petri net, 352–353 high-coupling, 161 Project-Open tool, 603
phases, of iterations, 23 implicit correspondence assumption, 115–116 projects and systems, quantitative comparison of
PHP Security Audit tool, 628 software development, 83 similar, 473–474
ping-pong programming, 463 tame, 20 project-specific risks, 596
pipe-and-filter architecture, 156 technical review aiming to reveal, 99 properties, checking for desired, 373–374
pipeline, processing of items on, 342–343 user interface design, 387 Properties application programming interface
pipeline architecture, 156 problem-solving activity, software design (API), 445
places, in a Petri net, 352 as, 163 protected variations pattern, 274
plan, by feature in FDD, 43 procedures, studying, 227, 359 protection, 616
plan next phases step, of spiral process, 23 process, 353 protection proxy, 436, 438
plan-driven approaches, 44–45 compared to methodology, 37–38 protection proxy pattern, 559, 612
planning phase most crucial part of modeling, 246 prototype pattern, 389, 445–447, 559
of AUM, 46 process and methodology, definition of, prototypes
of AUP, 45–46 491–492 constructing, 307–308
modeling and analysis of security threats, 614 process improvement, 490, 495–497, 599–601 in feasibility studies, 21
security in, 615–623 methodology forming the basis for, 38 seeking user feedback, 344
in XP, 44 quantitative assessment of, 474 prototyping, 97, 248, 488, 531
planning poker game, technique for agile process improvement process (PIP), 496–497 prototyping process model, 21
estimation, 590 process metrics, 472 proven design solution, 252
planning the iterations with use cases, 191 process model, 16 proxy pattern, 389, 436–439, 440
Platform Difficulty (PDIF), 586 process scripts, 25–26 Proxy-Based Estimation (PROBE) method,
PMD tool, 499, 628 process standards, 492–493 631–632
point-of-sale shipping software, as an example processes, types of flow between, 340–341 pseudocode, of an algorithm, 232
of business rules, 367 processes and standards function, 490–494 PSP forms, 26–28
polymorphic state, defining hierarchy of, 337 processing complexity, assigning, 581 PSPO, introducing the baseline process, 25
polymorphism, defined, 114–115 processing complexity adjustment (PCA), publisher-subscriber pattern, 414
polymorphism pattern, 274, 552 581, 582 pure fabrication pattern, 274
pop-up menus, 297 processing node, in a flowchart, 352 Purge Test, created as a subclass of
pop-up messages, disturbing and product challenges, examples of, 17–18 TestCase, 649
counterproductive, 313 product metrics, 472 p-use, define-use paths, 515
portability, of software, 471 Product Reliability and Complexity
position, defined in investing, 272 (RCPX), 586
post-architecture model, 587, 588 product standards, 493 Q
postconditions, for use cases, 209 productionizing phase, in XP, 44 quality, as everybody’s business, 498
postmortem step, as a unique feature of the products, creating families of, 404–407 quality assurance
PSP, 26 program evaluation and review technique activities, 3
potential security risks, detecting, 622 (PERT) chart, 591–593 planning phase, 11
potential threats, identifying, 616 program understanding (program procedures, 28
PQCT (productivity and quality and operating comprehension), 542, 543–544, 548 processes, 491
costs and time to market), 3, 13 programs, accessing a database from, 635–636 software tools supporting, 499
practice defense in depth principle, 625 Progress Monitor Input Stream decorator, 422 quality attributes, of a decision table, 373
preconditions, for use cases, 209 progressive decision table construction process, quality control, 494
predefined processes, series of, 25 371–373 quality management, 490, 494–495
predicate, defining a class, 109 project, creating in NetBeans, 647–648 quality management and design, processes
predicate use (p-use), 514 project administration, 11 introducing, 25
694 Index
quality measurement and assurance, between the object classes, 110 requirements review, types of, 488
facilitating, 278 between use cases, 188–190 requirements specification, 11
quality measurements and metrics wrongly expressed, 127 requirements specification standards, 97, 98
study of, 472–483 Relay Off state, software entering into, 70 requirements traceability tool, 465
usefulness of, 473–474 release planning meeting, in Scrum, 43 requirements unambiguity metric, 474, 475
quality metrics, 472–473 releases, developing small, incremental, 36, requirements volatility, adjusting size for, 586
conventional, 474–480 314, 466 requirement-subsystem traceability matrix,
quality planning, 494–495 reliability, 143, 470 61, 65
quality requirements, 86 reliability metric, 476, 479 requirement-use case traceability matrix,
quality standards and procedures, defining for remote proxy, application to the design of the 177, 191
all software projects, 492 persistence framework, 438, 439 Reset Password use case, 210
quantitative assessments, advantages of, remote repository, creating, 656 resilience requirements, 609
473–474 requests, 320, 433–434 resource utilization, 527–528, 550
query result, processing, 636 Required Development Schedule (SCED), 587 resources, directing valuable to critical
querying, a database, 635 required resources, for testing, 531 areas, 473
questionnaires, 227, 358 requirement statements, defined, 172 responding to change
quick fix model, 542, 543 Requirement Use Case Traceability Matrix supported by proper application of
(RUTM), 183–184 patterns, 423
requirement-based misuse, 620 valued over following a plan, 34, 602
R requirements response actions, translating into function
race condition attack, 617 capturing at a high level, 35, 100–101, calls, 334
radio communication simulator (RCS), 6, 314, 365 Response for a Class (RFC), 483
670–672 changing throughout life cycle, 85 response time, 527
railroad crossing system (RCS), 346–347 compared to constraints, 82 responsibility
random testing, 528 compulsory, 452 assigning to create an object, 271
rapid application development (RAD), defined, 172 assigning to process a use case, 266
alternative to, 42 deriving, 94–96 responsibility-assignment patterns, applying,
reachable states, 330 deriving use cases from, 176–192 251–273
real requirements, identifying, 80, 81 evolving, 35, 196, 313–314 Responsibility-Driven Design (RDD), latest
real user interface requirements, identifying, 314 mistaken as constraints, 82 practices in, 274
real-time data flow, 341 numbering, 96–97 restrictions, stated as constraints in the
real-time embedded systems perception of real, 81 requirements specification, 96
exhibiting state-dependent behavior, 144 prioritizing, 97 resuability, of software, 471
modeling of, 341 relating to use cases, 96 ResultSet object, 635, 636
real-time system state behavior, modeling requirements allocation, 64–65 resume control flow, into the control
of, 342 requirements analysis, 80 process, 341
real-time systems modeling and design, 339–344 requirements analysis phase, 226 retail shipping stores, speed critical to, 308
real-world projects, much larger and much more requirements baseline, 564 return null implementation, providing in
complex, 17 requirements change Abstract Factory, 407
recovery, after a system crash, 143 accommodating, 47 return on investment (ROI), depending on
recursive, whole-part relationships, common for many software projects, 101 design of the user, 295
supporting, 391–392 security in, 623 return types
recursive activity, 104 requirements completeness metric, 474, classes serving as, 280
recursive view, of the development process, 26 475, 476 deciding on, 241
redundancy requirements consistency metric, 475, 476 identifying use relationships from classes as,
eliminating in a decision table, 374 requirements correctness metric, 475, 476 286–287
technical review revealing, 99 requirements decomposition, 63 reusable software elements, patterns as, 253
redundant transitions, 330 requirements elicitation, 80 reuse effort, computing, 587
reestimation issue, in story point, 591 for agile development, 100 reverse engineering, generating UML diagrams
refactoring, 440, 465, 466 challenges of, 83–85 from code, 135
refinement, obeying consistency or leveling importance and difficulty often reverse-engineering, 547–549
rules, 363 underestimated, 85 case study, 549
Register New User use case, expanded use case importance of, 82–83 defined, 547–548
for, 519 steps for, 86–100 recovering design diagrams from code,
regression test process, automating, 648 requirements elicitation phase, 96 407–408
regression testing, 532–533 requirements management, major activities of, steps of, 408
regression testing tools, 559 101, 102 usefulness of, 548–549
regression tests, for object-oriented requirements management tool, IBM Rational workflow, 548
software, 535 DOORS, 102 reverse-engineering functions, with diagram
relational database, 427, 634 requirements metrics (R), 474–475 generation and diagram display, 153
relationships requirements misconception, reducing risk reverse-engineering tools, 545, 548, 557
between classes, 285 of, 466 reviewer, and writer, 462
identifying, 285–288 requirements phase, verification and validation Revision Control System (RCS), 571, 572
missing, 124 in, 487–489 revision management, 662
Index 695
ripple effect, 545 SeaMonster—Security Modeling Software, 628 service architecture, 157
risk analysis, 597 SearchBean, creating an instance of, 643 service consumers, 157
with an attack tree, 613–614 secrecy requirements, 608 service providers, 157
risk analysis and prioritizing, 597–599 secrets, hard to hide, 610, 625 service-oriented architecture (SOA), 157
risk based security testing, 613 secure access layer pattern, 611 services, invoking through use of http protocol
risk exposure, 597 secure architecture, producing, 622–623 and XML, 157
risk identification, 596 secure coding, 608 session pattern, 611
risk management, 11, 595–599 secure logger pattern, 611, 625 set, of all instances of a class, 109
applied to identify and analyze risks, 97 secure pipe pattern, 610, 611 set object messages, identifying relationships
planning, 599 secure programming principles and from, 287
unique feature for, 22 practices, 625–626 shallow history state, 331, 343–344
risk monitoring, 599 secure software design patterns, 610–612, 622 shared files, 659–661
risk resolution, 599 secure software design principles, 609–610, 625 shared object, locking and unlocking, 438
risks, 22, 595, 599 secure software test method, goal of, 626 shipping software
Rittel, Horst, 19–20 secured systems, designing, 149 function category counts, 582
robustness, of software, 470 security simplifying user operation of, 296
role-based access control (RBAC), 436 coming with development and operating simple configuration item, 568
role-based access control (RBAC) pattern, 622 costs, 627 simple loops, 513
role-based partition, 181, 182, 183, 194 meaning different things in different simple software configuration items (Simple
roles domains, 106 SCT), 566–567
of objects in associations, 112–113 no absolute, 627 simple state, 331
played by entities, 144, 173 requirements for, 143 simpleminded object, 166
roles/RBAC pattern, 611 requiring passwords to be encrypted, 268 simulation tools, for performance testing, 528
root cause analysis, 495 testing for, 528, 608, 626–627 Single Access Point module, 610, 611, 612
rule count, in a decision table, 369 security auditing requirements, 609 single access point pattern, 611, 612
rule numbers, in a decision table, 368 security operation, 613 singleton pattern, 252, 253, 389, 558
rule-based systems, modeling and design of, security patterns, 148, 620, 629 compared to flyweight, 410, 411
367–382 security requirements, 86, 608–609, 613, specification of, 254, 255
615–619 used with the state pattern, 411
security software, compared to software situation-specific patterns, 253, 386, 388, 389
S security, 607 skeleton code
safety requirements, 86 security threats, identifying, 618 for abstract factory, 404, 406
sanctioned baseline, 569 security vulnerabilities, 606, 607, 608 for applying composite in the editor, 392, 396
save command classes, 444 security-testing methods and tools, for the bridge pattern, 429
scale factors (SF), accounting for, 586 classifying, 626 for the command pattern, 431, 433
scenario description, 236, 248 selected version, becoming the default, 404 for the composite pattern, 392, 394
scenario statements, involving objects, 232 selection input, using when possible, 298 generated for the design, 402
scenario tables selection-oriented input widgets, 298 generated from the bridge pattern, 431
constructing, 225, 230–232, 265 Selenium, 534 implemented for Metric abstract class, 552
converting to a sequence diagram off-line, 247 self-regulation, law of, 540–541 producing for the class to be implemented,
converting to sequence diagrams, 237 sensitivity analysis, 598 464
defined, 231 separation of concerns principle, 150, 162–163, for the strategy pattern, 395, 398
deriving sequence diagrams from, 236–245 193, 257, 260, 264 for the visitor pattern, 401
no need to construct, 247 separation of duties, 616 SLOC per UFP values, 586
scenarios sequence diagram speaks, 245, 246 smart reference proxies, 436–438
communicating with users, 246 sequence diagrams, 218 smart reference proxy pattern, 558
converted into UML sequence diagrams, 228 for analysis and for design, 222–223 sniffing attack, 617
converting into a scenario table, 231–232 commonly seen Checkout Document, 256 software. See also working software
converting to a sequence diagram off-line by concerned with object interaction modeling assessing in levels, 473
one person, 247 and design, 163 demand for, 2
defined, 229 deriving from scenario tables, 225–226, as intangible, 576
defining, 225 236–245 reducing complexity of, 550
described, 228 examples, 220–222 software architectural design, 139
no need to construct, 247 formally defined, 222 software architecture
for nontrivial steps of expanded use cases, 225 identifying classes from, 280 examples of, 139
of object interaction, 237 to method code skeleton, 460 improving, 550
writing, 228–230, 232–236 modeling behavioral aspect of objects, 460 suggesting logical organization of the
SCM. See software configuration management modeling existing applications, 92 software artifacts, 458
(SCM) modeling notions and notations for, 218, 219 of a system or subsystem, 139
scriptlets, 642 no need to construct, 247 software artifacts
scripts. See process scripts not suitable for showing decision logic, 369 central repository of, 571
scroll pane, 297 notions and notations for, 219 extracting from the code, 548
scrollbars, 420 sequencing, Petri net modeling, 353 organizing, 159
Scrum, 36, 41, 42–43 server page, testing using HttpUnit, 656 quality of, 469
696 Index
software as a service (SaaS), 157 tool support for, 557, 559 software testing, 501–535
software attributes, 470 types of, 541 benefits of, 503
software capability maturity, levels of, 600 software measurement, 472 defined, 502
software configuration auditing (SCA), 566, software methodology, 37 described, 502
569–570 software metric, 472 in the life cycle, 529–532
software configuration change control (SCCC), Software Metrics utility, 549 purposes of, 502
565, 568–569 software operation and maintenance, reasons for, 503
software configuration identification, 565, conventional processes compared to agile, tool support for, 534
566–568 492 software tools, used during implementation and
software configuration items (SCIs), 563–564 software process, 5, 16, 18 testing, 647–664
software configuration management (SCM), 11, improving, 601 software verification and validation techniques,
562–573 models, 12, 21–37 483–487
described, 563, 564–565 specifying input and output of each phase, 37 software-hardware interfacing, illustration of, 70
functions, 565–570 software products, frequent delivery of, 36 software-only systems, 54
reasons for, 565 software project software-related security requirements, 608
tools, 570–572 managing as a wicked problem, 601 source code, 152, 510
software configuration status accounting, successful, 81 Source Code Control System (SCCS), 571
566, 570 software project management, 5, 10–11, specialization, 114
software deficiencies, 568 576–603 specialization substate, 327
software design software project risks, top 10, 596 specific assertions, 124–125
conventional processes compared to agile, 492 software quality, understanding of, 470 specification, making unnecessarily complex,
determining software architecture, 8–9 software quality assurance (SQA), 4, 9–10, 212–213
software design patterns, 252 469–499 spiral process, 22–23
software design phase, static testings activities, 491–492 sprints, in Scrum, 43
performed, 531 benefits of, 469–470 SQA. See software quality assurance (SQA)
software design principles control, 495 SQA-related data, collecting, 495
applying, 160–166 domain model, 495, 496 SQL (Structured Query Language), 634
defined, 161 functions, 490–497 stakeholders. See also collaborative and
secure, 609–610 in PSP, 632–633 cooperative approach
software development standards and procedures, 492–493 acquiring requirements from, 89
all about conceptualization, 106 tool support for, 498, 499 collaborative and cooperative approach
not a scientific process, 21 training, 495 between all, 37
as a wicked problem, 19–21, 83–84, 323 software quality attributes, 470–472 stamp coupling, defined, 241
software development documents, changes software reengineering, 549 startup use case, for every system, 180
to, 562 software requirements state, defined, 320
software development methodology, defined, 81 state behavior, 318
37–39, 491 deriving, 92–97 capturing at a high level, lightweight, and
software development problems, related to elicitation of, 80–103 visual, 344–345
requirements, 83 not specified definitely, 84–85 conventional approaches to implementing,
software development process, 4, 5–9 types of, 85–86 334–335
software engineer, personal software process software requirements analysis, 7–8, 276, 492 examples of, 318
of, 25 software requirements analysis phase, 531 visualizing, 322
software engineering, 2–3, 55, 549–552 software requirements specification (SRS), 7–8, state behavior information, collecting and
as application of computer science, 14 82, 97, 98, 99–100 classifying, 321, 322–324
case study, 551–552 software security, 606–630 state conditions, 323
compared to computer science, 13–14 best practices of, 612–613 state dependent, response by an event-driven
defined, 3 described, 607–608 system, 145
emphasizing software PQCT, 13 in the life cycle, 614–627 State Diagram class, 392
objectives of, 3, 550–551 proactive approach, 606 state diagram editor
reasons for, 3–4 requirements, 615–616 abstract factory skeleton code, 404, 407
Software Engineering Institute (SEI), 28, 600 testing, 626, 629 application of the visitor pattern to, 401–402
software engineering process, activities in, 551 tool support for, 628 applying patterns to design, 386–425
software engineering (SE) team, 71 Software Security: Building Security In design of, 390–391
software fault tolerance, 143, 157 (McGraw), 629 overall requirement of, 390
software implementation, conventional software size, in thousand source lines of code providing context-dependent help, 418–419
processes compared to agile, 492 (KSLOC), 585 user interface for, 301
software life cycle software systems State Diagram object, as an array of State
activities, 4–11 designed and implemented by teams, 3–4 objects, 391
baselines of, 563–564 getting larger and more complex, 3 state diagrams
software maintenance, 538–560 improving maintainability of, 550–551 automatic generation of, 330
defined, 539 large, complex, intellectual products, 576 cloning, 402–403
described, 539 maintaining different versions of, 565 consisting of states and transitions, 391
patterns for, 553–555, 556, 557, 558–559 restrictions on, 81 constructing, 327
process and activities, 542–547 subject to lifelong testing, 21 modeling existing applications, 92
Index 697
needed only if state behavior is complex, 345 strategy pattern, 389, 395, 397, 398, 559 Syntax Item class, functions of, 376–377
representing as a composite, 392, 394 stress testing, 528 syntax-checking visitors, applying, 401
for a Thermostat Control, 332 STRIDE (Spoofing, Tampering-with-Data, SysML block definition diagram (bdd), 68
state machine Repudiation, Information Disclosure, SysML internal block diagram (ibd), 68
finite, 522 Denial-of-Service, and system acceptance testing, 58
keeping track of editing states and Elevation-of-Privilege) attacks, 616 system aging period, 538
delegating GUI event-handling Strooper, P., 521 system allocation, 7
responsibilities, 640 structural patterns, 253–254, 386 system architectural design, 58, 60–71
mapping with pattern classes, 335, 337 structured analysis and structured design system architectural design diagram, 6
Mealy type, 339 (SA/SD), 39, 144 system architecture, visualizinig, 61
Subject class client interfaces corresponding structured methodologies, 39 system build capability, 571
to, 337 Structured Query Language (SQL), 634 system capabilities, facilitating delivery of, 294
timed, 342–343 structure-oriented widget, 299 system configuration management, 74–75
state modeling, review checklist, 334 Study Abroad Management System (SAMS), system decomposition, 61–64
state models, reviewing, 322 667–669 system design, 6, 7
state pattern, 334–339, 389, 559 processing an online application in, 350 system development
application of for the state diagram, 411 website, test model for, 525 challenges of, 17–18
applying, 337–339 stupid objects, 166, 420 as interdisciplinary effort, 56
as better alternative to conventional stupid objects principle, 261, 265 process, 5
approaches, 334 S-type of systems, 540 system displays, identifying major, 300
described, 335–337 subclasses, facilitating manipulation of system engineering
implementation of, 640 association relationships, 114 elements of, 56
implementation of subclasses, 640, 641 subject, with state behavior, 337 performed for embedded systems, 5–7
parts of, 337 subject and object acted upon, 237, 238, 239 system engineering phase, testing during, 531
specification of, 336 Subject class, defining with client system engineering process, 5, 276
State Specification Template, in PSP, 633 interfaces, 337 covering entire life cycle of the system, 56
state transition diagram, for the Reserve Flight subject is an actor/object case, 237, 238 phases and workflows of, 56–57
use case, 262 subsystem boundary, use case diagram phases of, 57–58
state transition tables showing, 188 system functions, decomposing a system
constructing, 321, 327–329 subsystem cohesion, improving, 177 according to, 62
converting to a state diagram, 331 subsystem development, 58, 71–73 system integration test plan, 71
documenting state behavior, 331 subsystem functions and interfaces, 58, 70–71 system integration testing, 73
usefulness of, 329–330 subsystem integration, facilitating, 62 system integration, testing, and deployment, 73
state-dependent behavior subsystems system integration, testing, deployment, and
of event-driven systems, 154 allocating system requirements to, 61 maintenance, 58
objects exhibiting, 520–521 compared to systems, 147 system maintenance security requirements, 609
requiring different design methods, 144 depicting, 6 system metrics, 479–480
statement coverage, goal to accomplish 100 deriving, 177–180 system modeling, 66, 67
states, bold face fonts indicating, 318 developed by separate engineering teams, 7 System Modeling Language (SysML),
static analysis, using the object-oriented of an even larger system, 54 67–68, 69
model, 526 identifying from functional requirements, system requirements
static analysis tools, 559, 626 179–180 assigning to the subsystems, 64–65
analyzing code, 528 integrated during system integration and defining, 60
detecting potential problems and violation of testing phase, 60 partitioning, 61
coding standards, 455 interfaces between, 142, 158 system requirements baseline, 74
static approaches meaningful names for, 193 system requirements definition, 5–6, 57, 58–60
limitations of, 503 rearranging use cases among, 180–183 system responses, 227
to software security, 626 as relatively independent, 61 system sequence diagram, 249
to user interface prototyping, 307 specifying functions and interfaces, 157–158 system testing phase, test cases specified, 531
static binding, 415, 417 Subversion (SVN), 571, 572 system types
static checking, during software development connection protocols, 660–661 determining, 143–147
process, 501 merging files, 662 mapping to architectural styles, 149
static model, 124 in NetBeans, 656, 658–659 systematic construction, of the state model, 329
static validation, 10, 484 performing version control tasks in NetBeans, systematic decision table construction method,
static verification and validation techniques, 484 659–661 370–371
steps, iterating to produce a good design, 167 setting up in NetBeans, 658–659 systems
stereotype mechanism, provided by UML, 66 superclass, 114, 129 compared to subsystems, 147
stereotyped instance, 219, 220 survey questionnaires, 89, 227, 358 consisting of subsystems, components, or
stereotyped message, 219, 237 survivability requirements, 609 elements, 54
stopping rule, 185 Swing, 636–641 defined, 54
story cards, for agile planning, 594–595 switch/case sequential blocks, 510 determining type of, 142
story point approach, issues, 591 synchronization, 353, 362 ever evolving, 54–55
story points, estimating size with, 590 syntax, for business rules, 376 partitioning into a hierarchy of subsystems, 62
strategies, to address risk items, 599 syntax analysis, 146, 153, 349 types of, 318
698 Index
20/80 rule unadjusted function point (UFP) value, 586 deriving from requirements, 172–198, 277
applying, 36, 168 unambiguity checks, 488 described, 173–174
identifying most used functionalities, 101 unauthorized access attack, 617 ending with the actor, 173–174
two-column table, initializing for modeling, uncontrolled goto statement, 13 example, 176
202–203 Understand for Java tool, 499 grouping, 181
type inconsistency, 99 undesired behavior, detecting, 502 with hostile intent, 619
type of system, influencing selection of undesired state, ability to recover from, 311 identifying, 176, 177–184
architectural style, 141 undoing and redoing operations, supporting, 434 implementing state-dependent behavior
type-based partition, of use cases, 181 undone command stack, storing commands, 433 of, 261
type-dependent operations, decoding from unified process (UP), 11, 23–25, 39 including another use case, 190
classes of a structure, 401 unit testing, 10 including other, 210
types universal project risks, 596 levels of abstraction, 200
classes as, 109 universe of discourse, 109 manually identifying, 197
missing, 124 unmarshalling, 427, 435 in modeling and design of interactive
unreachable state, 330 systems, 145
unstructured loops, 513, 514 not attempting to derive an optimal
U until sequential blocks, 510 set of, 196
UI Gestures Collector, 533 U.S. Department of Defense (DoD), 600 partitioning according to their common core
UI prototypes, 205, 207–208 use case contexts, visualizing, 176, 186–190 functionality, 163
UI prototyping exhibits, reusing, 205–206 use case controller, 261, 262 partitioning into groups of use cases, 193
UML (Unified Modeling Language), 4, use case derivation, guidelines for, 192–195 parts of, 172
11, 12 use case diagrams, 616 preconditions and postconditions, 209–210
applying separation of concerns, 162 for an ATM application, 186, 187 priorities of, 191
created for modeling software applications concerned with use cases and their properly assigning responsibilities to
and systems, 66 contexts, 163 process, 266
creation of, 39 defined, 186 rearranging among subsystems, 180–183
supporting system modeling, 67–68 incorrectly drawn, 195 relevant to a subsystem, 193
versions of, 404 modeling existing applications, 92 reviewing, 176
UML 1.0, 404 notions and notations for, 186–187 showing relationships between, 188–190
UML 2.0, 404 requirements derived from, 96 steps for deriving from requirements,
UML activity diagram, 351, 355–356 reviewing, 191 176–192
UML behavioral diagram, 186 use case driven approach, 24–25, 39 supporting more than one requirement, 183
UML class diagram Use Case Engineering, 12 team’s ability to develop and deploy, 192
classification result visualized by, 118 use case model, 24 use community resources secure software design
concerned with modeling and design, 163 use case modeling, tool support for, 196–198 principle, 612
defined, 108 use case priorities, determining priorities of the use relationship, 285
describing singleton pattern, 252, 253 functions, 465 user guide, 310
domain model using, 48 use case scenario, applying controller pattern user input and result display, widgets for,
not drawing during brainstorming and when writing, 265 298, 299
classification sessions, 134 use case scopes, specifying, 176, 184–186 user interaction, facilitating, 294
UML class diagram editor, 669–670 use case specifications, reviewing, 190–191 user interface
UML diagram editors, tools providing, 135 use case state, keeping track of, 261–263 consistent, 312
UML diagrams use case to iteration allocation matrix, 192 defects in look and feel of, 529
activity diagrams relationship to, 363 use case-based testing, 518–520 demonstration, 309
correct and incorrect notation, 224–225 use cases. See also expanded use cases design of, 8
creating and managing, 135 accomplishing a business task, 174, 193 experiment, 309
describing different aspects of the activity modeling useful in identifying, 363 interaction behavior of, 306
application, 277 of an actor subclass, 181 presentation, 309
modeling existing applications, 92 allocating to iterations, 176, 191–192 review meeting, 309
reverse-engineering source code to assigning functionally unrelated to a of a software system, 293
produce, 152 subsystem, 161 survey, 309–310
tool drawing, 136, 137 attributes of, 173 test tools, 529
visualizing different aspects of the existing automatic derivation of, 198 testing, 529
application, 91, 92 beginning with an actor, 173 user interface design
UML notation, for various multiplicity as business processes, 189, 200 described, 294–295
values, 112 as concatenation of two, 213 evaluating with users, 308–310
UML package diagram, 159, 288 continuing with other, 210–211 factors influencing acceptance of, 308–309
UML representation, of the grammar, 376 defined, 173, 187 guidelines for, 311–313
UML sequence diagrams, 218–225, dependencies among, 192 problems, solving, 387
228, 246 derived from and satisfying functional process, 300–310
UML state diagram, 330, 331 requirements, 192 reasons for, 295–296
UML stereotype, 66, 220, 285 derived from nonfunctional requirements, 192 review checklist, 310
UML use case diagrams, 176 deriving, 177–180 tool support for, 314
UML-defined stereotyped relationships, 285 deriving and specifying, 196 user-centric, 312
700 Index
user interface prototyping, 204–208 version number, of a configuration item, 567 white-box approach
approaches to, 307–308 versioning window, 661, 663 to fuzzing, 629
constructing, 301 vertical scroll bar, 297 for testing web applications, 525
user interface requirements, 86 Viega, John, 609 white-box testing, 510–516, 517, 528
determining, 205 virtual proxy, 436, 438 white-list, 617
making lightweight and visual, 314 virtual proxy pattern, 558 whole-part hierarchy, 54
user interviews, 59 visibility, increasing, 196 wicked problems
user involvement Visitor class, defining polymorphic visit architectural design as, 168
as imperative, 601, 627 functions, 402 properties of, 84, 184
required by many agile methods, 35 visitor hierarchy, 401–402 software development as, 19–21, 83–84, 323
user model, constructing, 528 visitor pattern, 389, 398 software project management as, 601
User object, 267, 268 skeleton code, 401 specification and implementation cannot be
user psychology, affecting user interface design, specification of, 400, 401 separated, 33, 291
308–309 visitors visit, 402 theory of, 19–21
user stories, as a requirements gathering visualization, of use case contexts, 186–190 widgets, 296
method, 90 window air conditioner, architectural design,
user support capabilities, designing, 310–311 154–155
user surveys, 59 W window-based multitasking, in GUIs, 294
user-defined type, 109 walkthrough, 485–486, 489 window-generated events, responses to, 411
user-friendly interface, specifying accurately war file, 645 windows
and adequately, 84–85 waterfall model, for software draft design of, 301
users development, 5, 6 identifying, 304
evaluating design with, 301 waterfall process in Java, 297
evaluating user interface design with, adopted partly due to its simplicity, 16 layout design for, 294
308–310 long development duration of, 12 minimizing the number of, 297
interviewing, 89–90, 358–359 merits and problems of, 19 WinRunner, 533
involving in user interface evaluation, 307 vertical slicing of, 45 wish lists, identifying needs from, 93
personal interview with, 227 weakest link, securing, 609 workflow management, 146, 349
testing a system, 73 web applications workflows, identifying, 357–360
working closely with, 134–135 building and deploying, 645 working software, valuing over comprehensive
user’s manual, 310 testing, 525–527 documentation, 33, 167–168, 291, 345,
user-submitted password, verifying, 625 testing with HttpUnit, 527, 655–656 364, 424, 498, 602
web server, installing with a JSP container, 643 workload, 527
web user interface (WUI), worksheet, for scenario development, 233, 234
V implementation, 297 workspace management, 571
valid input, for test cases, 519 web users, as actors, 179 write tests, in test-driven development, 463
validating, that a pattern is applied correctly, 390 web2Project tool, 603 writer, and reviewer, 462
validation, 10, 388, 484 web-based applications, relying on server writing, scenarios, 232–236
variable x of type X, 109 pages, 642
verb-noun phrases, 192, 197 website defacement attack, 617
verification, 9–10, 388, 484 Weighted Methods per Class (WMC), 481 X
verification and validation, in the life cycle, “what you see is what you get” XUnit family, of tools, 534, 648
487–490 (WYSIWYG), 314
Version Comparison utility, 549 while/for sequential blocks, 510
version control, objective of, 571 whiteboard, during brainstorming and Z
version control tools, 571, 656–664 classifying, 133–134 “zero failure” method, 533–534