Object Oriented Design With Java, C++ and UML
Object Oriented Design With Java, C++ and UML
SELF-STUDY
Introduction
COURSE PURPOSE
This coursebook was developed for self-study training and will assist in preparing for the
jCert Level two Object Oriented Design and Anaylysis Exam. Along with comprehensive
instructional text and objectives checklists, this coursebook provides easy-to-follow
hands-on lab exercises and a glossary of course-specific terms. It also provides Internet
addresses needed to complete some exercises, although due to the constantly changing
nature of the Internet, some addresses may no longer be valid.
Object-Oriented Analysis and Design is a course that teaches you object-oriented analysis
and design techniques using the Unified Modeling Language (UML). The course
provides an overview of object technology and object-oriented principles such as
encapsulation, abstraction, inheritance, and polymorphism. The course provides specific
examples of UML diagrams as well as techniques used in requirements gathering,
analysis, and design. The course also includes a discussion of proper design techniques
and the object-oriented design metrics you can use to evaluate the strength of a design.
The course concludes with a brief discussion of the implementation and testing processes.
This coursebook will assist you during the class and serve as a valuable resource when you
return to your office or home. After completing this course, you will have experience
using UML to perform analysis and design. You may also consider Martin Fowler’s book
UML Distilled 2nd ed. as an excellent companion to this course.
COURSE GOALS
This self-study course will provide you with the information you need to complete the
following:
● Define object technology and identify its place in the evolution of software
engineering.
● Describe the differences between a structured approach and an object-oriented
approach to software development.
● Identify the advantages and disadvantages of an object-oriented approach to
software development.
● Describe the need for analysis and design.
● Identify the benefits of abstraction and encapsulation.
2 Introduction
● Define a simple object model using the "has a" and "uses a" relationships.
● Describe Jacobson’s application object types.
● Identify the benefits of inheritance, polymorphism, and multiple inheritance.
● Define software development life cycle, and describe various life cycle models.
● Describe the Unified Process, and identify its phases and core workflows.
● Describe the Unified Modeling Language (UML) and its views.
● Identify the role of CASE tools in the software development process.
● Identify the benefits and limitations of CASE tools, as well as criteria for selecting
a CASE tool.
● Install and use Argo/UML.
● Describe the purpose, activities and deliverables of the requirements workflow.
● Identify the actors and use cases of a system.
● Describe the four types of use-case relationship.
● Develop a use-case model to capture project requirements.
● Interpret and create activity diagrams to describe use cases.
● Identify the major goals of user interface design.
● Describe the different types of prototypes.
● Design a system interface.Use the Backus-Naur Form to create an interface control
document.
● Define use-case realization-analysis.
● Interpret and create collaboration diagrams to illustrate a rough vision of system
design.
● Use CRC cards to aid in developing collaboration diagrams.
● Identify aggregation and generalization relationships.
● Identify design subsystems and design classes.
● Use interaction diagrams to assist in creating use-case realizations-design.
● Create a flow-of-events-design.
● Define implementation requirements.
● Create deployment diagrams to describe system architecture.
● Use class diagrams to illustrate system design.
● Identify when it is appropriate to use associations, aggregation, and composition.
Exercises 3
EXERCISES
The exercises in this manual are designed to give you hands-on practice working in both
stand-alone and network environments. It is suggested that you complete the exercises
when referenced. However, this may not always be convenient. If you need to skip an
exercise, you should plan on completing the exercise later when time and circumstances
allow.
You may find that there are some exercises that you are unable to complete due to
hardware or software requirements. Do not let this stop you from completing the other
exercises in this manual.
NOTICE:
The exercises in this self-study product are designed to be used on a system that is
designated for training purposes only. Practicing the exercises on a LAN or workstation
that is used for other purposes may cause configuration problems, which could require a
reinstallation and/or restoration from a tape backup of the original configuration. Please
keep this in mind when working through the exercises.
4 Introduction
SCENARIO-BASED LEARNING
This self-study manual uses a number of scenario-based learning exercises. In these, you
are presented with a situation similar to those you are likely to encounter in day-to-day
support and management. You will be provided with the information you need and
asked to determine the best solution. A suggested solution is provided at the back of the
self-study manual.
These exercises are being used to supplement hands-on practice and to help get you
started thinking critically about practical applications. In some cases, they have been
used as a replacement for hands-on practice for scenarios where it would be especially
difficult to emulate a real-world situation.
It is important that you take the time to work through the scenario-based exercises.
These are an important supplement to the training materials and are meant to reinforce
the text information in your manual.
MULTIMEDIA OVERVIEW
The Interactive Learning CD-ROM is a robust collection of learning tools designed to
enhance your understanding and prepare you for certification. You access these tools
from the Start menu: select Wave Interactive Learning and then select the appropriate
curriculum.
Simulations
Throughout the course, you will see icons asking you to practice the concepts you have
learned in that chapter using NEXTSim. NEXTSim is an interactive simulation product
that provides you with scenario-based training and hands-on experience in a safe
environment. This tool should be used strictly as a supplement to the course and not to
replace the course content.
Multimedia Overview 5
Videos
A key element of the Interactive Learning CD-ROM included with this course is digital
video. Digital video lessons describe key concepts covered in the manual. Often concepts
are best understood by drawing a picture. Digital video segments provide a graphical
illustration, accompanied by an instructor’s narration. These lessons are ideal both as
introductions to key concepts and for reinforcement.
Assessment
As reinforcement and review for certification exams, the Challenge! Interactive is
significantly helpful. The Challenge! contains sample test items for each exam. The
sample tests are comprised of multiple-choice, screen simulation, and scenario questions
to better prepare you for exams. It is a good idea to take the Challenge! test on a particular
exam, read the study guide and then take the Challenge! test again. It is useful to take the
Challenge! tests as frequently as possible because they are such excellent reinforcement
tools.
6 Introduction
Software Requirements
● Microsoft Windows 98, ME, 2000, NT 4.0 or higher.
● Netscape Navigator 4.5 or higher.
● Microsoft Internet Explorer 5.5 or higher
● Java Development Kit version 1.2.2 or higher ( http://java.sun.com )
1
MMAAJJOORR T O P IICCSS
Objectives ........................................................................ 8
Pre-Test Questions........................................................... 8
Introduction .................................................................... 9
Object Technology......................................................... 11
Summary ....................................................................... 16
OBJECTIVES
At the completion of this chapter, you will be able to:
● Define object technology and identify its place in the evolution of software
engineering.
● Describe the differences between a structured approach and an object-oriented
approach to software development.
● Identify the advantages and disadvantages of an object-oriented approach to
software development.
● Discuss the need for analysis and design.
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
Introduction 9
INTRODUCTION
The classical definition of software engineering given by F.L Bauer at a 1968 NATO
conference defines the practice as: “The establishment and use of sound engineering
principles in order to obtain economical software that is reliable and works efficiently on
real machines.” Today, software engineering tends to encourage the use of structured
development methods that promote ease in maintenence and provide viable
programming solutions. In the process of software development, the relationships
between the theoretical and functional stages require a variety of tools with which the
software engineer must be familiar. In application, each engineer may solve the same
problem with differerent tools; yet, common methodologies in which problems are solved
should be recognized. This chapter will discuss the initial steps taken by the software
engineer when approaching a problem and will also introduce the significance of the
analysis and design phase in object oriented programming.
As computers became more powerful, the demand for more complicated software systems
increased. Thus, software engineers looked for better ways to manage the design and
development of information systems. At the same time, structured and functional
programming languages were becoming available. By the early 1970s, analysis and design
methodologies became more formalized.
Shipment
Customer
Order
Order Report
Take Generate
Order Database Management
Order Report
Orders
Order
The flow of data is represented by arrows starting from a source, such as a customer, or
through processes, such as taking an order or generating a report, to information
consumers, such as management. By decomposing the system in this way, functional
subsystems can be developed individually. Many of the principles developed in these early
analysis and design models have been carried over into modern object-oriented analysis
and design methodologies.
Programmer vs. Engineer 11
O B J E C T TE C H N O L O G Y
Structured programming models focus their attention on the flow of information
through data-handling functions. Analysis and design allowed system designers and
developers to view software as a set of atomic functions that each performed a specific
task. This view allowed for more rapid development, fewer errors in code, and reduced
project risk. However, as computers became faster, smaller and cheaper, demand
developed for more complicated and less centralized information systems deployed over
multiple computer systems, operating environments, and locations.
Examine the data flow in Figure 1-1. As a customer places an order, the order
information passes through a "Take Order" function and a "Ship Order" function. In an
object-oriented model, the order information would be identified as an object, which
maintains properties about its state. For example, an order object might maintain a list of
items included in the order, a shipping address, and a billing method.
There are several differences between an object and the data in a structured program. In a
structured program, data is passed through functions that operate on it. In an object-
oriented program, messages are sent to objects that instruct the objects how to operate on
themselves. Figure 1-2 illustrates an order object with the properties that define it.
Instead of passing the order object through a function, however, it is sent a "Ship Order"
message, and the order ships itself.
The analysis and design of a functional program is in many ways structurally similar to a
program constructed in an object-oriented framework. The organization of program
behavior is similar since the levels of data abstraction in both languages may accomplish a
similar task. However, the steps to reach the goal in a functional program may require
added complexity, which may be simplified in the use of an object-oriented language.
The next section gives a structured overview of these benefits.
Maintainable
Object-oriented programming methods make code more maintainable. Identifying the
source of errors is easier because objects are self-contained. Later in this course, certain
principles of proper object-oriented design that contribute to a program's maintainability
will be introduced.
14 Chapter 1—Introduction to Software Engineering
Reusable
Because objects contain both data and methods that act on data, objects can be thought
of as self-contained black boxes. This feature makes it easy to reuse code in new systems.
Messages provide a predefined interface to an object's data and functionality. With this
interface, an object can be used in any context. Later in this course, you will learn how to
expand on the functionality of objects, even if you know very little about their
implementation.
Scalable
Object-oriented programs are also scalable. As an object's interface provides a road map
for reusing the object in new software, and provides all the information needed to replace
the object without affecting other code. This way aging code can be replaced with faster
algorithms and newer technology.
Retraining can also be an issue. Object-oriented programming has existed since the early
1980s. However, object-oriented principles did not appear in educational curriculum
until about 1995.
Analysis and Design 15
Design is the process of translating the output of analysis into a blueprint for the actual
coding of a software system. Like a blueprint for a building, the design will show enough
detail to allow a diverse group of managers and programmers to develop the system
concurrently.
The focus of this course is on analysis and design. However, analysis and design do not
exist in a vacuum; they are part of a larger process of developing object-oriented software.
A development methodology details the entire process of software development, from
gathering requirements to design, coding, and deployment. To fully understand the roles
of analysis and design in the software development process, they will be taught in the
context of the Unified Software Development Process, or Unified Process.
Software crisis
Analysis and design serve several purposes. They allow developers to foresee technical
difficulties. They help ensure that the product will match users' needs and expectations.
Most importantly, they help managers to minimize risk. Developing software is a time-
consuming and expensive process. Because software is intangible, it can be difficult to
assess development progress. When product deployment is delayed as a result of problems
in software development, a software crisis is said to exist. Analysis and design procedures
and development methodologies help to prevent the software crisis by providing
managers with a framework to measure a development organization's performance and
potential for success.
16 Chapter 1—Introduction to Software Engineering
1. Examine Figure 1-1. Identify possible objects that could form an object-oriented
system to perform the same task.
2. Identify the properties that define the objects found in Step 1 of this exercise.
3. Identify the messages that define the interface to objects found in Step 1.
SUMMARY
Software engineering is a relatively young discipline. Early analysis and design
methodologies focused on tracing the path of data through functional components.
Object-oriented analysis and design identifies objects, determines properties that define
objects, and determines messages to which objects should respond. Object-oriented
techniques make code more maintainable, reusable, and scalable. Analysis and design
help managers to minimize risk.
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. How do analysis and design help prevent a software crisis?
.....................................................................................................................................
.....................................................................................................................................
2
MMAAJJOORR T O P IICCSS
Objectives ...................................................................... 18
Pre-Test Questions......................................................... 18
Introduction .................................................................. 19
Classes ........................................................................... 19
Classes and Functions .................................................... 20
Abstraction .................................................................... 25
Adding and Naming Classes .......................................... 26
Operation Visibility ....................................................... 26
Class Responsibility ....................................................... 27
Instantiation .................................................................. 28
Object Communication ................................................. 28
Object Relationships...................................................... 28
Application Objects ....................................................... 30
Summary ....................................................................... 32
Post-Test Questions ....................................................... 32
18 Chapter 2—Understanding the Object Paradigm
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What three types of objects did Jacobson identify in object-oriented software
systems?
.....................................................................................................................................
.....................................................................................................................................
Introduction 19
INTRODUCTION
In object oriented software design, object dynamics and object communication are vital
to system integrity. The organization and accessibility of object properties can be
implemented by a variety of structures, including classes, methods, and functions. These
are manipulated by processes, such as data instantiation, encapsulation, and abstraction.
The classification of object relationships also plays a vital role in organizing object
abstraction and inter-system communication.
CLASSES
Objects are the building blocks of an object-oriented software system. They model real-
world collections of information (such as a purchase order) and are able to modify
themselves.
A class provides the blueprint for an object. For example, a library check-out system
manages the movement of thousands of books, as patrons check them out and return
them. Each book is represented by an object that maintains properties, such as the title,
the author, and the ISBN. A class provides a blueprint for these objects. Throughout this
chapter and the next, you will study short code examples written in Java and C++. The
following Java code is the class definition of a book:
class Book
{
String title;
String author;
String isbn;
}
20 Chapter 2—Understanding the Object Paradigm
As part of a specific class, a method is associated with any object of that class. While it is
possible for a class or object to have multiple methods, a method may only access
information pertaining to one object. This prevents the exchange of data among objects
and limits data corruption.
Classes and Functions 21
Two common types of methods are accessors and mutators, which are used to access and
modify member data. They are used as an alternative to accessing member data directly
using the dot notation discussed in the previous section.
22 Chapter 2—Understanding the Object Paradigm
Accessors
Accessor methods can be used to ask an object about itself. Rather than accessing member
data directly, accessors provide a safe interface to an object. Following is the Book class
definition with accessors added using Java:
class Book
{
String title;
String author;
String isbn;
String getTitle();
String getAuthor();
String getISBN();
}
The same class is defined using C++ as follows:
class Book
{
char *title;
char *author;
char *isbn;
char *getTitle();
char *getAuthor();
char *getISBN();
}
In the new class definition, prototypes are added for three accessor methods: getTitle,
getAuthor, and getISBN. These methods are used to access the member data.
Classes and Functions 23
Mutators
Mutators are member methods that are used to modify member data. Like accessors,
mutators prevent programmers from accessing member data directly. Following is the
Book class definition with mutators added using Java:
class Book
{
private String title;
private String author;
private String isbn;
public:
char *getTitle();
char *getAuthor();
char *getISBN();
void setTitle(char*);
void setAuthor(char*);
void setISBN(char*);
}
Three mutators have been added to the Book class: setTitle, setAuthor, and setISBN.
The public and private keywords set access privileges for the Book class. The member data
is declared as private, which prevents member data from being accessed directly from
outside the class. To access the member data, you must use the publicly declared accessors
and mutators.
Encapsulation
The use of accessors and mutators offers many advantages. By hiding the implementation
of the Book class, you can make changes to the implementation without disrupting the
design of other classes. Consider the C++ class definition in the previous example.
Replace the character arrays used to hold the title, author, and ISBN with a string class.
Provided that all access to Book data is restricted to accessors and mutators, the change
will be transparent to the rest of the program. This type of data protection is called
encapsulation. Accessors and mutators can be thought of as surrounding the data that
forms a class. Figure 2-1 illustrates the encapsulation of the Book class.
Abstraction 25
ge
N
SB
tTi
tI
tle
ge
title
author
isbn
getAuthor
ABSTRACTION
Encapsulation plays an important role in developing objects as black boxes. The process
of developing classes in terms of their interfaces and functionality, instead of their
implementation details, is called abstraction.
OPERATION VISIBILITY
In the above examples of mutators, the functions were grouped into two areas: private
and public. This exemplifies the used of object visibility. Object visibility specifies which
parts, if any, of a class are visible (i.e. modifiable or viewable) to other parts of a program.
There are three major classes of object visibility: public, protected, and private. Public
data are those that are visible from anywhere inside a program. In the above examples, the
mutators setTitle(), setAuthor(), and setISBN() are declared public. This occurs
because the entire program must be able to see and use those functions to modify the
Book class data.
Private data are only visible from within their class. The actual variables of Title, Author,
and ISBN in the above examples are private, because they do not need to be visible and/or
modifiable by the rest of the program. If users can use the publically declared mutators to
modify the private data, why make the variables private at all? Although there are many
reasons, safety is the most important. By making the data private and only modifiable by
the mutators, the data is not directly modifiable by other functions in the program. This
way, error checking can be performed before the data is modified, or there can be a log
recording which part of the program modified the data.
There is also the type of protected. Protected data will only be visible within a certain
hierarchy of classes. For example, in a class named Vehicle, which includes subclasses of
Car, Truck, and Van, protected data can be visible to the subclasses of Car, Truck, and Van.
Class Responsibility 27
CLASS RESPONSIBILITY
Each class has its own data and actions, which are known as the class’s responsibilities.
Anything that the class has knowledge of and/or performs is known as its responsibilities.
Using the above examples, the Book class has responsibilities in the form of its Name,
Author, and ISBN number. It also has the ability to be checked in or out. This is
graphically described in the following diagram.
INSTANTIATION
Class definitions can be used to create objects. This process is called instantiation, and the
objects created are called instances. These instances serve as realizations of the class
definitions. Following is the Java code to instantiate a Book object:
Book catcherInTheRye = new Book();
The code to instantiate a Book object using C++ is as follows:
Book catcherInTheRye = Book();
OBJECT COMMUNICATION
Due to the black box nature of objects, communication between objects is carried out
through messages. Classes not only define objects, but also determine which messages are
related to those particular objects. Because all communication and functions of objects
are possible with a message interface, no other form of communication is needed. One
doesn’t even need to know what is contained by an object to use it.
In this type of communication, an object cannot be directly modified. Since, code and
data are fused within an object in object-oriented software, it is best that the information
within an object be left undisturbed so as not to disrupt the normal functionality of the
object. Thus, by only allowing communication with objects through their messages, the
code and data within the object is protected. This is known as information hiding, or
encapsulation.
OBJECT RELATIONSHIPS
Objects do not exist in isolation, but as part of a larger system of objects that must
interact with each other. The most fundamental relationship between objects is the has a
relationship. The Java implementation of the Book class has three String attributes: title,
author, and ISBN. String is a class, and the relationship between the Book class and the
String class is illustrated in Figure 2-3.
Object Relationships 29
The preceding figure is an example of a Booch class diagram. Grady Booch developed
this notation for representing the relationships between the classes that comprise a
software system. The simplest relationship is the has a relationship. The filled-in circle at
one end of the connecting line indicates that it is the Book that has the String.
Objects are more than abstract data types. In addition to their attributes, objects exhibit
behavior. In a library check-out system, for example, a library card is issued, a book is
checked out, and a patron pays an overdue fine. Accessors and mutators provide an access
layer to member data, but other methods exist to give the object more specific behavior.
These methods can be denoted with a uses a relationship. Figure 2-4 illustrates the
relationship between the Patron, Book and Fine classes.
pays
Fine
APPLICATION OBJECTS
Ivar Jacobson identified three major types of objects that comprise an object-oriented
software system: entity objects, interface objects, and control objects. These types persist
in the Unified Process as entity classes, boundary classes, and control classes.
Entity objects
Entity objects model real-world objects. All of the objects you have studied thus far have
been examples of entity objects. The analysis process begins by identifying business
information entities, such as different types of reports, customer information, or
inventory information. Most of these information entities can be translated directly into
entity objects.
The business information entities of a library system include books, a book collection,
patrons, librarians, addresses, and fees. Each of these can be translated into an entity
object.
Interface objects
Interface objects bridge the gap between a system and its users. The objects that form a
graphical user interface are examples of interface objects. Interface objects often take the
form of window, terminal, or printer objects. Figure 2-5 illustrates the relationship
between interface objects and entity objects.
For example, patrons interact with a library's information system through a card catalog
terminal. In the preceding figure, the card catalog terminal is represented by an interface
object. In the completed software system, this interface object would implement the user
interface.
The Unified Process refers to interface objects as boundary classes because they act as the
boundary between a software system and its users.
Control objects
Control objects implement complex business logic that cannot be easily implemented in
either entity or interface objects. Control objects typically represent schedulers,
sequencers, and other concepts that can be used to tie a system together. Figure 2-6
illustrates the relationship between control objects and entity objects.
Book Collection
Database
Uses
Fine
Issues Fine Pays Patron
Scheduler
For example, fines are issued when a book is overdue. In the preceding figure, the Fine
Scheduler object uses information it collects from the Book Collection Database to
determine when to issue a fine.
32 Chapter 2—Understanding the Object Paradigm
SUMMARY
Objects are the building blocks of object-oriented software systems. Instantiation is the
creation of an object based on class definitions. Encapsulation provides a barrier between
users of an object and an object's implementation details. Accessors and mutators
accomplish the goal of encapsulation. Encapsulation is closely related to the concept of
abstraction. Objects communicate through a message interface. Objects relate to each
other in several different ways, and class diagrams are used to denote the relationships
between objects. Most objects can be classified as one of three major object types: entity
objects, interface objects, or control objects.
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. Why are class diagrams used?
.....................................................................................................................................
.....................................................................................................................................
3
MMAAJJOORR T O P IICCSS
Objectives ...................................................................... 34
Pre-Test Questions......................................................... 34
Introduction .................................................................. 35
Inheritance..................................................................... 35
Inheriting Methods........................................................ 38
Polymorphism ............................................................... 43
Summary ....................................................................... 49
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. How does polymorphism overcome some of the limits of inheritance?
.....................................................................................................................................
.....................................................................................................................................
Introduction 35
INTRODUCTION
This chapter examines two powerful components of object oriented programing,
inheritance and polymorphism. Inheritance takes advantage of the similarities that exist
between various classes; its benefits include data generalization and code reduction.
Inheritance can be compared to scientific classification, because science begins with a
large collection of objects which are then split into refined classes (this is called
encapsulation). These classes are then organized hierarchically into more abstract classes
(inheritance). In software development, the design of classes and of the inheritance
hierarchies occurs simultaneously. Polymorphism uses inheritance to gain system
extensibility. For example, a parent class may contain a virtual function, which can be re-
defined by its children. Using polymorphism, new objects can be defined without
introducing new code.
INHERITANCE
In the previous lesson, you learned that objects can relate to each other with either a has a
or uses a relationship. Inheritance is a third type of relationship between objects: the is a
relationship.
For example, a library lends more than just books; it also lends magazines, audiocassettes,
and microfilm. On some level, all of these items can be treated in the same manner, since
all four types represent lendable assets. However, also consider the differences: A book has
an ISBN and a magazine does not; audiocassettes have a play length; and microfilm
cannot be checked out overnight.
Each of these assets should be represented by its own class definition. However, without
inheritance, each class must independently implement the characteristics that are
common to all lendable assets. All assets are either checked out, or available for checkout.
All assets have a title, a date of acquisition, and a replacement cost. Rather than duplicate
functionality, inheritance allows you to inherit functionality from another class, called a
superclass.
36 Chapter 3—Inheritance and Polymorphism
LendableAsset
INHERITING ATTRIBUTES
LendableAsset is a superclass that maintains only the data and methods that are common
to all lendable assets. Book, Magazine, Audiocassette, and Microfilm are subclasses of the
LendableAsset class, and so they inherit these characteristics. The inheritance
relationship is called the is a relationship. A Book is a LendableAsset, as are a Magazine,
an Audiocassette, and Microfilm. Following are the class definitions for the
LendableAsset, Book, and Audiocassette classes using Java:
class LendableAsset
{
String title;
Date acquisitionDate;
float replacementCost;
boolean checkedOut;
}
In the previous example, the LendableAsset class defines properties relevant to all
lendable assets. The Book and Audiocassette classes inherit these properties. In Java, the
extends keyword is used to indicate inheritance. When these subclasses are instantiated,
the properties they inherit from the LendableAsset class can be accessed using dot
notation. For example:
Book catcherInTheRye = new Book();
catcherInTheRye.title = "Catcher in the Rye";
catcherInTheRye.author = "J. D. Salinger";
catcherInTheRye.isbn = "0-316-76948-7";
catcherInTheRye.checkedOut = false;
INHERITING METHODS
Methods can also be inherited. Figure 3-2 illustrates the relationships between the Patron,
LendableAsset, Book, and Audiocassette classes.
Book
Audiocassette
bookInPrint.checkOut();
bookOnTape.checkOut();
40 Chapter 3—Inheritance and Polymorphism
This class definition depicts only the publicly defined methods of the Date class. No
implementation details are known. The problem is that the Java Date class provides no
mechanism for determining the date three weeks in the future (when a LendableAsset is
due). Using inheritance, this functionality can be added in a derived class, called DueDate.
The following code defines the new DueDate class:
class DueDate extends Date
{
public void addDays(int days)
{
setDate(getDate() + days);
}
The new DueDate class inherits the functionality of the Java API Date class, and adds two
new methods to allow calculation of a due date. Figure 3-3 illustrates the relationship
between the LendableAsset class and the new DueDate class.
Book
Audiocassette
has
DueDate
Date
POLYMORPHISM
In the previous section, you learned that classes can inherit methods from other classes.
The Book and Audiocassette classes inherit the checkOut method from the
LendableAsset class. However, behavior may need to be modified depending on the
subclass. For example, all lendable assets have a due date. Books and audiocassettes can be
checked out for 21 days, but microfilm is due back within three hours. Polymorphism
allows subclasses to override methods defined in their base class. Because assets are
generally due in 21 days, the calculateDueDate method adds 21 days to the current date
to calculate a due date. Study the following code:
class LendableAsset
{
String title;
Date acquisitionDate;
float replacementCost;
boolean checkedOut;
DueDate dueDate;
The Microfilm class can use polymorphism to override the calculateDueDate method
defined in the LendableAsset class, as shown:
class Microfilm extends LendableAsset
{
public void calculateDueDate()
{
dueDate = new DueDate();
dueDate.addHours(3);
}
}
When calculateDueDate is called on a LendableAsset object, a decision is made. If the
object is of type Book or Audiocassette, the calculateDueDate method defined in the
base class LendableAsset is called. If the object is of type Microfilm, the
calculateDueDate method defined in the Microfilm class is called. This process is called
late binding.
ABSTRACT CLASSES
In the preceding section, you learned that subclasses can override methods defined in the
classes from which they are derived. In the example, the Microfilm class defines a
method, CalculateDueDate, that overrides the same method defined in the base class
LendableAsset.
From a design perspective, this relationship seems incorrect. The LendableAsset class
defines the CalculateDueDate method that assumes the due date to be three weeks in the
future. While all instances of LendableAsset have a due date, not all calculate that due
date in the same way. It becomes the responsibility of the derived class to identify itself as
a special case and override this method to calculate a correct due date.
Abstract Classes 45
The answer to this design issue is an abstract class. An abstract class declares methods
without providing any implementation. When a subclass inherits from an abstract base
class, it must override these methods to provide the requisite functionality. The abstract
class cannot be instantiated, it can only be extended. The following code is modified to
define LendableAsset as an abstract class:
abstract class LendableAsset
{
String title;
Date acquisitionDate;
float replacementCost;
boolean checkedOut;
DueDate dueDate;
MULTIPLE INHERITANCE
Early in this chapter, you learned that inheritance allows the Book, Magazine,
Audiocassette, and Microfilm classes to inherit common characteristics from a base
class, LenadableAsset. Occasionally, however, single inheritance is not enough.
For example, a magazine is a lendable asset, and it is also a subscribable asset. The library
system must be able to track magazine subscriptions and automate subscription renewal.
If Magazine were the only class that ever exhibited these characteristics, you could build
the subscribable functionality into the Magazine subclass. However, newspapers can be
added to the library system. Recent newspapers are available for reading in the library, but
they are not lent out. Since newspapers are subscribable assets, the library system must
also be able to track its newspaper subscriptions.
Multiple inheritance allows the Magazine class to inherit characteristics from both the
LenadableAsset class and the SubscribableAsset class. The following C++ code
demonstrates multiple inheritance using the Magazine class:
class SubscribableAsset
{
public:
float subscriptionPrice;
DaterenewDate;
void renewSubscription();
}
Subscribable
LendableAsset
Asset
Newpaper Magazine
SUMMARY
Inheritance is a third type of object relationship, known as the is a relationship.
Inheritance allows a class to inherit the attributes and functionality of a superclass, or base
class. Inheritance can be used to extend components even if very little is known about a
class's implementation. Polymorphism allows subclasses to override methods defined
higher in the class hierarchy. Abstract classes allow you to avoid making presumptions
about implementation before the design requires it. Multiple inheritance is available with
some object-oriented programming languages; it allows a class to inherit from two or
more superclasses.
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
1. What is the responsibility of all subclasses that inherit from an abstract class?
.....................................................................................................................................
.....................................................................................................................................
2. Is an intricate knowledge of the implementation of a class necessary in order to
inherit from it?
.....................................................................................................................................
.....................................................................................................................................
50 Chapter 3—Inheritance and Polymorphism
4
MMAAJJOORR T O P IICCSS
Objectives ...................................................................... 52
Pre-Test Questions......................................................... 52
Introduction .................................................................. 53
Summary ....................................................................... 63
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What are the four main phases of the general software development life cycle
model?
.....................................................................................................................................
.....................................................................................................................................
Introduction 53
INTRODUCTION
Software for business applications, whether it is intended to perform a single task or it is
intended for use as a company-wide, integrated system, should be tailored to fit the
company’s unique needs and goals. In the simplest terms, the software should be capable
of performing all the functions necessary to perform a task efficiently. While the software
should be inclusive, it should not be unduly cumbersome. Careful attention is required to
develop software that is both functional and efficient. Once the software is in use, it must
be maintained. In this chapter, we will discuss several processes which can serve as
guidelines for software development.
Each phase produces feedback that affects the next phase. For instance, the requirements
gathered during the requirements phase influence the design, which is translated into
working software code during the implementation phase. The software code is verified
against the requirements during the testing phase.
54 Chapter 4—Software Development Life Cycle
Requirements-gathering
During the requirements-gathering phase, the needs of the company are outlined.
Managers and users (and in some cases, clients) make their “wish-lists” about what they
would like the software to do. Analysts ask questions about the intended use of the
software, what type of data will be processed, how the software should handle the data,
and how the data can be accessed once in the system.
Following the requirements phase, the software development team should have a detailed
list of functions that the system will perform. Emphasis is on the system's goals, rather
than the way in which the system will achieve those goals.
Design
In the design phase, the results of the requirements-gathering phase are translated into a
software design plan. Focus shifts from the system's results to the way in which those
results will be achieved and how the ideas of the requirements-gathering phase are
accomplished. Designers consider many different criteria, from the hardware and
operating system platform that hosting the software to the way subsystems will
communicate with each other.
In essence, during the design phase, the designers attempt to turn the dreams of the
managers and users into reality. Emphasis during this phase is on making a practical,
working design for what has been outlined in the requirements-gathering phase.
Software Development Life Cycle Model 55
Implementation
In the implementation phase, the results of the design phase are translated into program
code. Software that does not meet the needs of the company is wasteful. During this
phase the programmers should make it their central goal to fulfill the requirements of the
company and to meet the design outlined in the design phase.
The classes and class interactions developed in the design phase are very explicit. They
translate directly into the code generated in the implementation phase. Later in this
course, design tools will be introduced that actually automate code generation from the
output of the design phase.
Testing
In the testing phase, the results of the implementation phase are run through a series of
tests to verify that it functions and that it meets goals of the requirements phase. A testing
plan is created to describe the unit tests and system tests that will be performed. Unit
testing is performed on individual software components. The process of integration
brings together all the software components to create a complete system. System testing is
performed on the software system as a whole.
56 Chapter 4—Software Development Life Cycle
Requirements
Design
Implementation
and Unit Testing
Integration and
System Testing
Operation
Following each phase is a formal review process that results in the decision to proceed to
the next phase. Testing is performed late in the development process, and phases do not
overlap. When one phase is completed, the entire development effort shifts to the next
phase. This cascading flow from one phase to another is the basis of the Waterfall model’s
name.
Waterfall Life Cycle Model 57
The Waterfall model is appropriate for small development projects in which the
requirements are well understood.
Due to these issues, the Waterfall model is inappropriate for complex projects. It should
not be used for developing object-oriented software, for long-term or ongoing projects, or
for projects in which requirements are unknown or subject to change.
58 Chapter 4—Software Development Life Cycle
System Test
Requirements System Testing
Planning
Implementation
The development effort begins with requirements gathering (in the upper-left point of
the V). During this phase, requirements are gathered and recorded as they are in the
Waterfall model. However, before development moves to the next phase, a system test
plan is created. The system test plan will focus on verifying the functionality specified in
the requirements definition.
V-Shaped Life Cycle Model 59
As the V-model moves down the left side, developers focus on high-level system
architecture and overall system design. The integration test plan developed in this phase
will test the abilities of pieces of the finished software system to operate together. The
low-level design phases focus on the design of individual software components, and the
corresponding unit test plans developed in this phase are used to test individual
components.
Coding is performed at the bottom of the V, during the implementation phase. Once
coding is complete, development progresses up the right side of the V, moving through
the test plans developed during the earlier phases. If a problem arises during a testing
phase, the life-cycle reverts back to its corresponding development phase.
Requirements
Design
Implementation
and Unit Testing
Integration and
System Testing
Operation
Development begins with requirements gathering and high-level design, and then
requirements are divided into iterations. The Incremental model is evolutionary meaning
that a working version of the software is created by the end of the first iteration, and
subsequent iterations build upon the work of earlier iterations. Low-level design is
performed during each iteration, and unit testing evaluates the functionality added
during the current iteration. System testing evaluates the way in which the new
functionality affects the functionality of the entire system.
Spiral Life Cycle Model 61
The Incremental model is an effective tool for managing risk. Chancy portions of
development can be identified and carefully managed in their own iteration. In addition
to being performed incrementally, each iteration represents a measurable milestone.
The Spiral model is represented by a spiral passing through four quadrants, which
represent the four phases of development. Requirements gathering is performed in the
planning phase. During the risk analysis phase, a formal process is undertaken to identify
alternative courses of action and their relative risks. A prototype is also developed during
this phase. Software is coded and tested during the engineering phase. During the
evaluation phase, the customer has an opportunity to evaluate the output before the
project proceeds to the next spiral. Notice that the angular component represents the
progress in the current spiral, and the radius represents the project cost. Figure 4-5
illustrates the Spiral life cycle model.
Risk
Requirements Analysis
Gathering
Prototyping
Cost
Project
Coding
Customer
Testing
Evaluation
Evaluation Engineering
SUMMARY
All software development life cycle models share common phases of development:
gathering of requirements, designing of the software system, coding of software, and the
testing of the system. The Waterfall life cycle model is one of the simplest and easiest to
use; it consists of five discrete phases that are executed sequentially. The V-Shaped life
cycle model adds an emphasis on testing to the Waterfall model. The Incremental life
cycle model applies a series of iterations to the Waterfall model. The Spiral life cycle
model builds upon the Waterfall and Incremental models and focuses on risk analysis.
64 Chapter 4—Software Development Life Cycle
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
1. Why are the Waterfall cycle model and V-shaped cycle model inappropriate for
large design projects?
.....................................................................................................................................
.....................................................................................................................................
2. How does the Spiral model overcome the limitation of the Waterfall cycle model
and the V-shaped cycle model?
.....................................................................................................................................
.....................................................................................................................................
3. Why is the Spiral model only appropriate for large-scale and mission critical
applications?
.....................................................................................................................................
.....................................................................................................................................
5
MMAAJJOORR T O P IICCSS
Objectives ...................................................................... 66
Pre-Test Questions......................................................... 66
Introduction .................................................................. 67
Aggregation ................................................................... 68
Generalization ............................................................... 69
Delegation ..................................................................... 70
Models........................................................................... 70
Views ............................................................................. 73
Summary ....................................................................... 74
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What is a UML view?
.....................................................................................................................................
.....................................................................................................................................
Introduction 67
INTRODUCTION
The Unified Modeling Language, UML, is a method used to specify all aspects of a
software system. UML prescribes syntax for describing the structures of classes,
components, programs, and software systems. UML also describes the interactions
between these items. While the Unified Process relies heavily on UML, UML was
developed separately from it. UML was designed to be used with any iterative software
development process.
The object-oriented movement began with the introduction of Smalltalk in the early
1980s. By the late 1980s, work had begun on developing methods and notations to
describe object-oriented software systems. By the early 1990s, a wide variety of object-
oriented development methods existed, each with its own notation and modeling
language. While working at Rational Software Corp., developers Booch, Jacobson and
Rumbaugh created UML in an attempt to unify the notations each had created earlier. In
November 1997, the Object Management Group (OMG) adopted UML as a standard.
UML NOTATION
UML is used to model a system as a set of static structures and dynamic behaviors. Static
structures are the classes and components that comprise a system. Booch notation was
introduced earlier in the course and is used to specify class types and class relationships.
UML has its own notation, UML class diagrams that specify the static structures of a
software system.
The dynamic behavior of a system describes the steps in completing a task. The dynamic
behavior can be viewed from two levels: the life cycle of a single object from instantiation
to release, and the interaction of objects within a system. UML statechart diagrams are
state diagrams of a single object. Sequence diagrams and collaboration diagrams describe
the interactions between objects.
68 Chapter 5—The Unified Modeling Language
AGGREGATION
Aggregation is used in UML to describe part-of relationships. This includes relationships
where the different components are related so that they are aggregated into a separate
whole. As an example, a personal computer contains a processor, RAM and a hard disk. A
diagram that provides an explanation of aggregation within the PC is below:
As shown, the RAM, hard disk and processor are all parts of a personal computer. These
parts aggregate to create a personal computer. The multiplicity indicators show that there
must be at least one component and there can be an unspecified number of components
per personal computer.
Having a variety of aggregates that make up one object can also be called composition.
Composition describes relationships between aggregates, and it also describes what
happens when the removal or addition of a certain component takes place. Will this lead
to the deletion or addition of other components? This is called cascading. Cascading
occurs when adding or removing elements of a composition affects other elements. For
instance, if there is a composition that includes employees, payroll and individual expense
accounts, then the removal of an employee will also lead to the removal of that employee’s
payroll entry and the employee’s expense account.
Generalization 69
GENERALIZATION
Another kind of relationship that is modeled within UML is the generalized relationship.
These include a general class of something and a specific class that resides within the
general class. In the object-oriented paradigm, this is known as inheritance. These are
commonly referred to as supertypes and subtypes. The supertype will include a
generalized description, an abstract, of a category of objects. The subtype must conform
to all rules and actions that can be performed on the supertype. However, the subtype can
have rules and perform actions that the supertype cannot. One example that can be used
is an animal. In the following listing, animals are broken down into mammals, which is
further broken into whales. The subtype of whales then becomes a supertype for the
subtype of blue whales.
Using the example from above, the method “breathe” is written for the animal supertype.
If the breathe method is called on the subtype whale, the whale should be able to perform
the action. However, the method “swim” that is written for the whale subtype cannot be
called on the supertype of animal because not all animals can swim.
70 Chapter 5—The Unified Modeling Language
DELEGATION
Another way to describe relationships is by delegation. Delegation is the ability of an
object to respond to a message that it receives and to issue a message to an object.
Consider a business model. When an employee finishes a project she will turn this project
in to a manager. That is, the employee object will send a message to the manager object.
The manager will then be able to take the message of the finished project and respond by
issuing another project to the employee. The employee can then take this new message
and begin work on the new project.
The delegation ability of the manager is important because it allows the manager to
respond to the employee. An extension of this example would be if the manager turned
the finished project over to a quality assurance department. The quality assurance
department would be able to respond to the project by beginning the process of editing
and testing the project. This would start a new process of delegation between the
manager and the quality assurance department.
MODELS
A model is a simplified representation of a complex idea or element. In the same way that
a blueprint is a model of a building, UML is a model of a software system or program.
The blueprint allows an architect to convey his or her vision to customers and
contractors, and UML serves the same purpose within the software domain. It allows a
developer to convey his vision to a programming team and management.
UML is a modeling language, and many different UML models can be used to describe
the elements of a software system. These elements include system requirements, user
interactions, system processing, system design, and system testing. UML is complete
enough to model most situations encountered in software development, but it is
extensible enough to handle unforeseen modeling issues.
The following examples of modeling levels will describe a trip to a grocery store,
beginning with the realization that a house is out of food and ending with the actual
purchasing of groceries.
Models 71
Modeling levels
Various modeling levels are appropriate during the development of a software system.
The level of detail included in each model is modified as development progresses from its
initial stages through analysis, design, implementation, and testing.
High-level models
High-level models are created during the early stages of development. These models
provide a framework for ideas and often diverge in many directions. High-level models
are incomplete and will be heavily revised. Their purpose is to simply explore possible
solutions.
If the problem is a lack of food, possible solutions include growing a garden, driving to a
grocery store, or even stealing food from a neighbor. Some of these solutions are
obviously more feasible than others. The point of high-level modeling is to brainstorm in
as many directions as possible and to include all possibilities.
Abstract models
Abstract models are developed toward the end of analysis and the beginning of the design
phase. These models describe the system architecture and provide an overview of the
eventual system design. The solution revealed by the high-level model is elaborated into a
more refined model. However, the design is still incomplete, since much of the
implementation detail is omitted from abstract models. The goal is to verify the overall
system design before designing individual components.
In this phase of modeling, a concise solution has been chosen, and the design of the
solution can begin. Certain checks are used to ensure that the solution will work. Assume
that, from the possible solutions to the food problem, making a trip to the grocery store
was selected. The specifications that would have to be met include:
VIEWS
UML includes a variety of diagrams that are used in the analysis and design of a system.
UML is divided into eight views. Each view is a set of diagrams that depict some aspect of
a system. These eight views are grouped into three major areas: structural, dynamic, and
model management.
The structural view describes the static structure of a software system, including the
classes, the components, and their relationships. The dynamic view describes the
implementation of business logic in the design of individual classes and the interaction of
classes and components. The model management view describes the relationships
between UML models. In the preceding section, you learned that partial models are used
to describe subsystems. The model management view describes the relationships between
subsystems. The specifics of each of the UML views and diagrams will be discussed
throughout this course. Table 5-1 lists the eight UML views and the diagrams used to
develop each view.
SUMMARY
Booch, Jacobson, and Rumbaugh developed the Unified Modeling Language (UML) to
provide a complete language for specifying object-oriented software systems. UML was
adopted as an official standard by the OMG in 1997. UML models both the static
structures and the dynamic behaviors of a software system. Various modeling levels are
used depending on the level of detail required by each stage in the development process.
UML is divided into eight views, which are grouped into three major areas: structural,
dynamic, and model management.
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What are the eight UML views?
.....................................................................................................................................
.....................................................................................................................................
6
MMAAJJOORR T O P IICCSS
Objectives ...................................................................... 76
Pre-Test Questions......................................................... 76
Introduction .................................................................. 77
Summary ....................................................................... 81
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What are the criteria should one consider in a CASE tool?
.....................................................................................................................................
.....................................................................................................................................
Introduction 77
INTRODUCTION
Computer-Aided Software Engineering (CASE) is the integration of software-based
modeling tools into the software development process. Analysis and design
methodologies and modeling notations were developed to formalize the software-
engineering process; CASE tools automate that process by assisting in each step. Some
types of CASE tools are analysis and design tools, automated code generation tools, and
software testing tools. Analysis and design tools aid in the creation of diagrams and
project documentation. Automated code generation assists in the implementation phases.
Testing tools lead to a more thorough evaluation of an application. Table 6-1 provides a
chronological list of CASE tool development.
Early CASE tools were used to create project documentation and to assist in the creation
of analysis and design diagrams. Later, CASE tools incorporated a type of intelligence
that assisted in validating designs and ensuring conformity of diagrams. By the late
1980’s, CASE tools were being used to automatically generate code, based on design
diagrams. In the early 1990’s, CASE tools had evolved into user-friendly interfaces that
could be used on multiple projects, but still contained the aspects that had made previous
CASE tools useful.
78 Chapter 6—Computer-Aided Software Engineering
S E L E C T I N G A C A S E TO O L
A wide variety of CASE tools exist to support different development environments.
Choosing the best tool for a project can be a challenging exercise. The criteria used to
select CASE tools include methodology, flexibility, collaboration, and diagram validation.
Methodology
Although a wide variety of software development methodologies exist, common themes
exist between all object-oriented methodologies. Most variations occur in their processes,
procedures, and notations. It is vital that the CASE tools selected support the
methodology followed by the project.
When using UML and the Unified Process as a methodology for software development, a
traditional process should be followed. This process consists of moving from high-level
models, through abstract models, and finally to the full specification model. High-level
models are general descriptions of the project, while abstract models include definitions
of the resources required and ensure the soundness system design. Finally, the full
specification model will completely describe the software and provide explicit directives
for the software design. Any CASE tool that is under consideration, must support this
methodology
Flexibility
It is impossible to foresee every project need before development has begun. For this
reason, choose tools that allow customization. The tool should allow custom
documentation and should provide support for multiple programming languages. The
best tools allow construction of custom schemas that can be used to generate code in
several programming languages. Even with a detailed methodology, unforeseen problems
and needs may arise throughout software development. Thus, the CASE tool cannot
force users to use a fixed design.
Selecting a CASE Tool 79
Common CASE tool flexibilities include the ability to modify the target operating
system, language used, modeling language, size of the software, and the entire process.
Developers should not have to change the entire design of the software simply because
specific parts of the CASE tool must be modified. Experienced development teams are
flexible enough to deal with unforeseen problems and changes. The tools used by these
developers should be just as flexible.
Collaboration
One of the principal purposes of any software development methodology is to facilitate
collaboration. It is vital that CASE tools allow collaboration among developers; multiple
developers should be able to work on the project simultaneously. The tool should also
support distribution across multiple computers and multiple work areas.
There are two parts to collaboration, both of which can heavily influence the selection of
the CASE tool. The first is the prerequisites of the design. The second is the knowledge
of the organization producing the code.
Sometimes the programmers on a team may have different visions of what the project
should accomplish. Having common project prerequisites will allow cleaner collaboration
within the team.
The actual organization that will be producing the code is also an important
consideration when choosing a CASE tool. The development team can range in maturity,
experience, and knowledge. These factors can heavily influence the CASE tool needed. A
highly evolved CASE tool might be too intimidating for some inexperienced teams, while
a simpler CASE tool could limit the efforts of a very experienced software organization.
80 Chapter 6—Computer-Aided Software Engineering
Diagram validation
Although diagrams are used to simplify the design of a complex system, diagrams
themselves can become fairly complex. Tools are available to validate analysis and design
diagrams. These tools help diagrams conform to the modeling syntax, and ensure
consistency across sets of diagrams.
1. Download and install a Java2-compliant virtual machine software, such as the Sun
Java2 Runtime Environment. You can download the Java2 Runtime Environment
from the following URL:
http://www.java.sun.com/products/jdk/1.2/jre/index.html
2. Download Argo/UML from the Tigris Web site at http://argouml.tigris.org/. You
will need two files: argouml070.jar and xml4j.jar. Place both files in the same
directory.
3. If you are using Microsoft Windows, double-click the argouml070.jar file to
launch Argo/UML. If you are using another system or you experience difficulty
with this method, create a batch file or shell script to execute Argo/UML. The file
should contain one line that uses the Java virtual machine to run the uci.uml.Main
class. Be sure to include the argouml070.jar and xml4j.jar files in the class path.
Use the following example as a guide:
java -classpath %CLASSPATH%;argouml070.jar;xml4j.jar uci.uml.Main
You may need to include the full paths to the Java interpreter and .jar files.
Summary 81
4. Execute the batch file or shell script you created in Step 3 to start using
Argo/UML.
5. Open the projects included on the supplemental disk, and browse the diagrams
included in the projects.
SUMMARY
Computer-Aided Software Engineering (CASE) is the integration of software-based tools
into the software development process. These tools began appearing in the early 1980’s.
Today, CASE tools are used by software developers to create project documentation,
analysis and design diagrams, to perform analysis and design validation, and to create
program code from design diagrams. The criteria for selecting a CASE tool include the
methodology it supports, the flexibility it affords developers, the degree to which it
facilitates collaboration between developers, and its ability to validate analysis and design.
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What were mid 1980’s CASE tools used for?
.....................................................................................................................................
.....................................................................................................................................
3. What were late 1980’s CASE tools used for?
.....................................................................................................................................
.....................................................................................................................................
82 Chapter 6—Computer-Aided Software Engineering
7
Use-Case Modeling
MMAAJJOORR T O P IICCSS
Objectives ...................................................................... 84
Pre-Test Questions......................................................... 84
Introduction .................................................................. 85
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What is a use-case?
.....................................................................................................................................
.....................................................................................................................................
Introduction 85
INTRODUCTION
The principal medium for capturing requirements in the Unified Process is the use-case
diagram. Use-case diagrams illustrate the relationship between a software system and its
users. They also describe how each type of user will interface with the system. For
example, consider a library system. The librarian will check books in and out, and the
library patron will search the database. These relationships are illustrated with use-case
diagrams. The set of all use-case diagrams and their associated use-case descriptions
constitute the use-case model. The use-case model is one of the four principal deliverables
of the requirements workflow.
Actors
Users of a software system are represented as actors in a use-case diagram. Actors represent
specific users, groups of users, organizational users and even external software systems.
For example, a library may employ several librarians. Because all of these librarians will
access the system in the same manner, a single actor (Librarian) represents them. An actor
is represented by a labeled stick figure. Figure 7-1 is an example of a Librarian actor.
Librarian
Multiple users may assume the role of a single actor. For example, all of the librarians will
play the role of the Librarian actor. In addition, a single user may assume the role of
multiple actors. For example, an actor may represent a Head Librarian who has the ability
to purchase new books and run audits on the system. A user acts as a Head Librarian only
while executing the special tasks of this position; in other instances, the same user will
assume the role of the Librarian actor.
86 Chapter 7—Use-Case Modeling
Organizational users of the library system include book publishers and other libraries.
The Web site interface to the library system is an external software system that can be
represented as an actor.
Use cases
Actors maintain relationships with use cases. A use case is a description of some software
activity that an actor may initiate. For example, a librarian can check out an asset, such as
a book. This activity is represented as a use case. Use cases are represented by an oval with
a label inside or beneath that identifies the use case. Figure 7-2 is an example of a Check
Out Asset use case.
check out
asset
Use-case relationships
Use cases can participate in four types of relationships: association, generalization,
include and extend. Each relationship has its own purpose and notation. Table 7-1 lists
the four types of use-case relationships, their purposes and their notations.
Association
The association relationship is the interface between an actor and a use case. It is
represented by a line between an actor and a use case. For example, a librarian will use the
library system to check assets out. Figure 7-3 illustrates this interface using an association
relationship. The box around the Check Out Asset use case represents the system
boundary.
Library System
check out
asset
Librarian
Generalization
The generalization relationship is a link between use cases. Use cases often share common
characteristics. Suppose you identified a second use case: Check In Asset. This second use
case shares certain features with the Check Out Asset use case. Both use cases perform a
transaction that affects the library's inventory. A generalization allows you to represent
this shared functionality in a third use case (the Perform Transaction use case) and inherit
its functionality in both the Check In Asset and the Check Out Asset use cases.
88 Chapter 7—Use-Case Modeling
Library System
perform
transaction
check out
asset
Librarian
Include
The include relationship allows one use case to include the functionality of another.
Before an asset can be checked out, the system must verify that the patron does not owe
any overdue fines. An include relationship allows the Perform Transaction use case to
include the functionality of a Check Account Balance use case.
Introduction 89
The include relationship is represented by a dashed line with an arrowhead. The word
<<include>> is superimposed above the line to distinguish an include relationship from an
extend relationship. The arrow points from the use case that includes the additional
functionality to the use case being included. Figure 7-5 illustrates the include relationship
between the Check Account Balance use case and the Perform Transaction use case.
Library System
<<include>> check
perform
account
transaction
balance
check out
asset
Librarian
Extend
The extend relationship combines the functionality of one use case with the functionality
of another, if certain conditions exist. For example, if a library patron owes an overdue
fine, the system requires that the fine be paid before another asset can be checked out.
The Pay Overdue Fine use case extends the functionality of the Perform Transaction use
case only if an overdue fine is owed.
90 Chapter 7—Use-Case Modeling
The extend relationship is represented by a dashed line with an arrowhead. The word
<<extend>> is superimposed above the line. The arrow points from the use case that
provides the additional functionality to the use case that accepts the functionality. Figure
7-6 illustrates the extend relationship between the Pay Overdue Fine use case and the
Perform Transaction use case.
Library System
check out
asset
Librarian
The first step in developing a use-case model is identifying top-level use cases. Top-level
use cases are those use cases that interface directly with one or more actors. Candidate
requirements that are being formalized as use cases usually translate directly into top-level
use cases. Pages 2 and 3 of Figures 7-7 are top-level use-case diagrams.
Developing a Use-Case Model 91
At a minimum, use-case descriptions for the top-level use cases should be included. They
are often included for sub-level use cases as well. Use-case descriptions provide a brief
narrative of the steps in executing a use case. Any special considerations that are not
adequately described in the use-case diagrams should also be included. Pages 4 and 5 of
Figures 7-10 and 7-11 are the top-level use-case descriptions for the library system.
Sub-level use-case diagrams include all use cases and any relationships between use cases.
Pages 6 and 9 of Figures 7-12 and 7-15 are the sub-level use-case diagrams.
SUMMARY
Use-case diagrams illustrate the relationships between a software system and its users.
Actors are used to represent specific users, groups of users, organizational users and
external software systems. Actors maintain relationships with use cases. Use cases exist
within the system and represent specific ways the system can be used. Use cases can
participate in four types of relationships: association, generalization, include and extend.
An association is a relationship between an actor and a use case. A generalization is a
relationship between use cases that denotes inheritance. An include relationship allows
one use case to include the functionality of another use case. An extend relationship
extends the functionality of one use case to another if certain conditions are met.
Post-Test Questions 101
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What are the four types of use-case relationship?.
.....................................................................................................................................
.....................................................................................................................................
3. What three things are typically included in a use-case model?
.....................................................................................................................................
.....................................................................................................................................
102 Chapter 7—Use-Case Modeling
8
Activity Diagrams
MMAAJJOORR T O P IICCSS
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
INTRODUCTION
A use-case diagram describes the relationships between actions and discrete units of a
system's functionality. A use-case description provides a brief overview of the purpose of
each use-case and the steps required to complete that purpose. An activity diagram can be
used to expand on a use-case description. Activity diagrams are similar to flow charts:
they describe the order of activity and the branch logic of a process. However, they differ
from traditional flow charts by allowing the representation of concurrent operations.
Activities that take place simultaneously (such as threads) can be represented using
activity diagrams. Activity diagrams can be used to supplement the use-case descriptions
within a use-case model.
Introduction 105
scan asset
Boxes with rounded corners represent activity states. Each activity state is labeled with a
brief description of the activity it represents. The arrows between states, called transitions,
represent the shift from one activity state to the next.
106 Chapter 8—Activity Diagrams
CONDITIONALS
A conditional action in an activity diagram is an action that depends on one or more
defined requirements. For instance, in the above Check Out Asset use-case, before an
asset can be checked out, the system checks the patron's account balance. If the patron's
account information indicates an unpaid overdue fine, the system enters an alternative
thread of execution in which the library fine is paid. If no overdue fine is due, execution
continues along the primary path. Conditionals are represented in activity diagrams with
branches and merges.
CONCURRENCY
While branches are useful for describing when there are two or more options to take,
there are also situations where the action will flow along two or more paths at the same
time. This is known as concurrency. For instance, considering the Check Out Asset use-
case, when an asset is being checked out, there are two actions that must be performed at
the same time: adding that asset to the patron's account information and marking that
asset as checked out. These situations are described in Activity Diagrams through forks
and joins.
Consider the Check Out Asset use-case described above. This sequence can be
represented using a fork. Figure 8-3 adds a fork, represented by a horizontal bar, with two
concurrent threads. After an asset is scanned, execution continues along each of these
threads simultaneously. The threads converge at a join, also represented by a horizontal
bar.
Forks and Joins 109
check account
balance
scan asset
enter asset
[asset checked
out]
access account
database
access asset
database
generate report
print report
check account
balance
[pay fine]
scan asset
scan unissued
library card
enter patron
information
create account
record
access account
database
display account
information
ITERATIONS
While all of the above activity diagrams describe situations which follow a direct path
with no stops from beginning to end, there are situations which will require certain
actions to be performed more than once before an entire process can be completed. These
situations can be described using iterations. An iteration is a step in a process which will
repeat until a certain requirement is met.
In the following example, consider a student working on a test. Until all the problems on
the test are completed, the student will not be finished working on the test. The loop
above the activity state of Completing Test Questions indicates that this step will be
iterated until all the questions are answered.
A major advantage of using activity diagrams is the ability to describe parallel behavior, or
how behaviors in more than one use-case will interact. But activity diagrams are not
designed to describe which specific objects will perform which actions. Rather, an activity
diagram can be used to show that the actions taken will influence other actions. Other
types of diagrams, such as interaction or state transition diagrams, should be used when
attempting to describe objects and methods of messaging used between the objects.
SUMMARY
Activity diagrams are similar to flow charts. They describe a process: the order of activities
and the branching logic. They can also represent concurrent operations. One common
use for activity diagrams is to supplement the description of use-cases. Activity diagrams
flow from top to bottom through a series of activity states. Branches are used to represent
the logic involved in a process. The paths exiting a branch represent alternative threads of
execution. Branches converge at a merge. Forks are used to indicate the beginning of
concurrent threads of execution. Forks converge at a join.
Post-Test Questions 121
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What are the initial and final states of an Activity diagram represented by?
.....................................................................................................................................
.....................................................................................................................................
122 Chapter 8—Activity Diagrams
9
MMAAJJOORR T O P IICCSS
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. In designing a user interface, what are some things that should be considered?
.....................................................................................................................................
.....................................................................................................................................
Introduction 125
INTRODUCTION
Object modeling languages are becoming increasingly expressive and complex. The use of
a language like UML can increase the abilities of user interface designers for modeling
application domains and interactive systems. The recent development of techniques
which assist in user interface design during the object-oriented development process
provide programmers with the tools necessary to develop robust, user friendly
applications. Some of the better techniques include task analysis or preliminary user
interface analysis using interface prototyping, which has proven significant in object
identification.
A good user interface follows user interface conventions. These may vary between
operating systems. For example, Microsoft publishes a manual of user interface design
guidelines, which describes the ways in which users expect a Windows application to
react. Other environments, such as the World Wide Web, have their own informal
conventions. Programmers often assume they understand these conventions, but
experience shows that applications do not conform without a well-established process for
user interface design.
In this chapter, you will learn to design user interfaces that accommodate ergonomic and
accessibility considerations. Later, you will learn to determine an interface design's
potential for success through user testing.
126 Chapter 9—Interface Design and Prototyping
Metaphor
It is often beneficial to design a user interface as a metaphor of a real-world object. The
Windows desktop is a good example. The desktop has folders that lie on top of it, and
folders contain documents. If you choose to use a metaphor in developing a user
interface, be sure to use it consistently across the entire project. Do not create a metaphor
that applies only to a very narrow aspect of the program. Also, realize that while
metaphors provide one way to design user interfaces, not all software systems employ
metaphors. Thus, a good balance must be struck between the arcane and useless
metaphors and a complete lack of designing interfaces that relate to the actual world.
As stated above, the desktop has become a very successful metaphor, and there are other
real-world objects that are being implemented for programs. For instance, there is work
being done on many platforms to have a file system explorer that is a metaphor for a real
storage area. Thus, directories with larger size on the hard disk will appear as larger
structures within the program. There are many other metaphors used in user interfaces,
but it is important to remember that not every situation will warrant a real-world object
metaphor.
Self-evidence
The most critical feature to build into a user interface is self-evidence. The function of
various user interface components should be readily apparent to even slightly experienced
users. However, in most cases, a large number of users will use a system, and each of these
users will approach the system from a different perspective.
User Interface Design 127
Experienced computer users will look for controls that are common among applications.
Many Windows applications have a standard Windows toolbar that contains buttons to
execute common functionalities, such as opening a new or existing document or saving a
document. Experienced users will recognize these icons from other applications and feel
confident to explore the features specific to your application.
Novice users are often fearful of making mistakes. They may not recognize these icons.
Their hesitance may hinder their ability to use a system, which can leave many powerful
and useful aspects of a program unused. Making the user interface self-evident eases this
fear and facilitates learning. Figure 9-1 shows the standard Windows toolbar. Some of the
icons on the toolbar are intuitive. Most people will understand immediately that clicking
on the image of a printer will cause the current document to be printed.
For instance, in the example below, two pieces of paper on top of each other may indicate
“Paste” to experienced users, but may mean nothing at all to new users of a system.
However, the Paste Icon is not threatening and seems to imply that no harm will come to
a novice user for using that command. Thus, while the exact meaning of the icon may
not be grasped by every user, the knowledge that pressing that icon will not cause serious
harm to a program should be evident to all users.
Library System
File Edit View Insert Format Tools
ABC
Consistency
User interfaces should be consistent. There are two types of consistency: internal
consistency and external consistency. Internal consistency is consistency within the
interface of a single software system. For example, if the library system allows users to
access a patron's account information by either scanning her library card or manually
entering her library card number, it should allow users to do the same when checking out
a book to a patron. This type of consistency makes learning the system easier and using
the system faster.
128 Chapter 9—Interface Design and Prototyping
know that programs can be accessed through the Start Menu for any version of Windows
that has been produced since Microsoft Windows 95. This external consistency in the
operating system allows for smoother transitions for users when they switch between
different Microsoft products.
A well-designed user interface will follow the conventions of the operating environment
in which it resides, making sure to use the internal and external consistencies which are
already used.
State visualization
In the preceding chapter, you created activity diagrams for each of your top-level use
cases. These activity diagrams illustrate the life cycle of a use-case and the various states in
which it can exist, from initiation to completion. Often, these states correspond to a
request for input from the user. State visualization is the principle that visual cues should
be offered to illustrate the transition from one state to another.
For example, when a librarian checks a book out to a patron, he must first scan the
patron's library card. Following this state, the librarian will either be notified that the
patron owes an overdue fine, or he will begin scanning the book to be checked out. All of
these states should be visually distinct so that the librarian can learn to quickly identify
each. If the screen notifying the librarian of an overdue fine looks too similar to the screen
requesting the assets to be checked out, the process will be slowed down while the
librarian examines the screen to determine the new state.
Figure 9-2 is based on the activity diagram for the Check Out Asset use case. A dialog box
alerts the librarian if the patron owes an overdue fine. The screen used to pay an overdue
fine is visually different from the screen to used enter the assets being checked out. These
visual representations of state allow the librarian to work more efficiently.
User Interface Design 129
State visualization is important, but be sure to avoid creating a modal interface. A modal
interface can exist in only one state at a time. For example, a modal interface might
restrict a librarian's ability to check out books if he is using the system to perform a time-
consuming task, such as generating overdue notices. Modal interfaces can be easy to use,
but they are inflexible.
Library System
Account Number:
Name:
Address:
Library Assets
OK
Library System
Patron
Address:
Pay Fine
Library System
Patron
Account Number:
Name:
Address:
Library Assets
Done
Rapid prototyping
Rapid prototyping is a process by which a working demonstration version of a piece of
software is created in a very short period of time. When designing a user interface, several
rapid software prototypes may be developed and tested with users before a final user
interface is agreed upon.
A software prototype is never developed into a fully operational system. The prototype is
used only for demonstration purposes. It communicates a vision of the final product's
appearance, and it serves as a catalyst for new ideas. Software prototypes are often
developed using Rapid Application Development (RAD) techniques. No emphasis is
placed on performance. Software prototypes are developed using RAD tools such as
Visual Basic or Delphi even if the actual software system will be developed using another
language.
User Interface Prototyping 131
Paper prototyping
Paper prototyping is used to communicate the same information as a software prototype
without the expense of developing a working piece of software. Paper prototypes use
screen shots and storyboards to illustrate the system's appearance and functionality. Paper
prototypes may be part of a formal interface requirements document. Figures 9-3
through 9-9 are the interface requirements document for the library system, based on a
paper prototype process.
You can express the syntax of this communication using a metasyntax. The Backus-Naur
Form (BNF) is the most widely used metasyntax for expressing context-free grammars.
You can use BNF to define the syntax of a programming language, a configuration file, or
a communications protocol. Table 9-1 summarizes the Backus-Naur Form.
Interface prototyping is a very important part of the interface design process because it
actually allows users and developers to study the interface being implemented and test the
interface for problems or unforeseen complications. Without prototyping there would
not be a way for the interface design process to receive feedback and testing, which would
nullify the entire purpose of interface design.
140 Chapter 9—Interface Design and Prototyping
SUMMARY
A good user interface is transparent to the user. Poorly designed user interfaces can be a
significant obstacle to users. It is often beneficial to design user interfaces as a metaphor
of some real-world object. User interface components should be self-evident, as well as
both internally and externally consistent. A well-designed user interface will provide
visual cues of the software's current state. Interface prototypes provide tools for defining
and refining requirements. Software prototypes implement the interface and basic
functionality in a simple software application. Paper prototypes utilize non-software tools
to describe a user interface. The interface between a software system and external software
systems can be defined using the Backus-Naur Form.
Post-Test Questions 141
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. Describe the two types of software interface consistency.
.....................................................................................................................................
.....................................................................................................................................
3. Contrast Vertical and Horizontal prototyping.
.....................................................................................................................................
.....................................................................................................................................
142 Chapter 9—Interface Design and Prototyping
10
Analysis Modeling
MMAAJJOORR T O P IICCSS
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What is a sequence diagram?
.....................................................................................................................................
.....................................................................................................................................
3. What are CRC cards?
.....................................................................................................................................
.....................................................................................................................................
Introduction 145
INTRODUCTION
In the preceding chapter, you were introduced to the three UML class stereotypes:
boundary, entity, and control. Boundary classes form the interface between a system and
its users. Entity classes represent data and real-life objects, and control classes represent
the actions and processes not represented in boundary or entity classes. In this chapter,
you will learn to combine these class types into collaboration diagrams. UML
collaboration diagrams describe, in a precise manner, the dynamics of a software’s
function and represent this information using automated processes. As a programmer,
collaboration diagrams provide simplified access to the functionality of a program,
therefore, providing timely and robust error analysis with improved options for system
upgrades.
COLLABORATION DIAGRAMS
Collaboration diagrams are a form of an interaction diagram that are used within the
analysis workflow to provide an overview of a system's design. They describe the
interaction between users and boundary classes and between classes themselves. Figure
10-1 is a portion of a collaboration diagram for the Check Out Asset use case. In this
example, a Librarian actor interacts with a boundary class, Check Out UI.
1: Select patron(patronID)
: Check Out UI
: Librarian
The labels associated with each of the actors and classes comprising a collaboration
diagram use the object : class notation, in which the class name appears after a colon. In
the preceding figure, the single boundary class is labeled Check Out UI. This notation
indicates that this class is of type Check Out UI. If you intend to specify an instance of a
class, you can use the object field to specify the name of the instance. For example, if the
activity depicted in the preceding figure could only be initiated by a librarian named
Mark, you could specify Mark by labeling the actor Mark : Librarian. Notice that at this
stage you need not be concerned with creating class names that conform to program
syntax or coding standards. Check Out UI is not a valid class name. The Check Out UI
boundary class actually represents a collection of classes representing windows, scroll bars,
and all the elements that form the user interface. For now, you are developing an
overview of the system, and details can be addressed later.
The line between the Librarian actor and the Check Out UI boundary class associates the
two. It provides a pathway for communication, which is in the form of messages. In this
case, a single message is passed from the Librarian to the boundary class. An arrow
illustrates the direction of this message.
: Check Out
: Check Out UI
: Librarian Controller
The message to the Check Out Controller class is to select a patron. In order to perform
this action, the Check Out Controller class will need information about the patron being
selected. The patron's identification number (which is scanned or entered from the
library card) is passed as an argument to the Check Out Controller class. This notation is
intentionally formatted to the syntax of most programming languages. In most cases, the
messages sent between classes take the form of method calls.
Return values
Figure 10-3 expands on the preceding collaboration diagram. A third class, Patron
Account, has been added and is an entity class. A third message, Get Account Balance,
has been added between the Check Out Controller class and the Patron Account class.
This message takes no arguments because, in the final system, this message will be sent to
a specific instance of the Patron Account class. As noted previously, the Get Account
Balance can be thought of as a message call. The diagram can capture the return value for
use by the calling object. In this case, the return value is stored in a variable balance.
: Check Out
: Check Out UI
: Librarian Controller
: Patron Account
Message conditions
Figure 10-4 adds a second control class, the Pay Overdue Fine class. If the patron owes an
overdue fine, that fine must be paid before any library assets can be checked out. Thus a
condition is placed on message 4. The condition indicated by brackets indicates that the
Pay Overdue Fine message will only be sent if the account balance is greater than zero, or
balance > 0.
: Patron Account
Multiplicity
Once a patron has been selected and any outstanding overdue fines have been paid, the
librarian enters a cycle of adding assets to the list of assets to be checked out. This cycle
continues until all the assets being checked out have been added to the list. Figure 10-5
adds the Asset List class and the messages required to add assets to the list. The asterisk
next to message 5 indicates multiplicity; this message may be executed multiple times as
assets continue to be added.
Figure 10-6 is the complete collaboration diagram for the Check Out Asset use case.
: Asset Database
The collaboration diagrams created within the analysis workflow provide a rough
overview of how each use case will be implemented. Using an expanded notation,
collaboration diagrams can provide a more complete view of system design.
Collaboration diagrams during the design phase will be revisited.
Flow of Events and Special Requirements 151
Analysts can employ two methods to better communicate the sequence of message
passing within a collaboration diagram. One method is to create a second type of
interaction diagram called a sequence diagram. It contains all the same information
contained in a collaboration diagram, yet in a form that places greater emphasis on the
sequence of events than on specific object relationships. Creating sequence diagrams will
be discussed in a later chapter.
A librarian uses a bar code scanner or the keyboard to input a patron identification
number (1). The user interface dispatches the patron identification number to the
Check Out Controller (2). The Check Out Controller queries the Patron Account
for the patron's account balance (3). If the balance > 0, control is transferred to the
Pay Overdue Fine Controller (4). Once the patron's account balance is resolved,
the librarian may begin entering asset identification numbers, using a bar code
scanner or the keyboard. The asset identification number is dispatched from the
Check Out UI to the Check Out Controller, which adds the asset to a list of assets
being checked out. This process continues until all assets being checked out have
been added to the list (5, 6, 7). When the librarian has completed the process of
entering assets, he indicates to the Check Out UI that he wants to complete the
transaction (8). This message is relayed to the Check Out Controller (9). The
Check Out Controller adds the assets to the patron's account information and
marks the assets as checked out (10, 11, 12).
In addition to the flow-of-events description, each collaboration diagram may also be
accompanied by a special-requirements description. The special-requirements description
is a brief list of any non-functional requirements that should be considered.
152 Chapter 10—Analysis Modeling
CLASS-RESPONSIBILITY-COLLABORATION CARDS
Creating collaboration diagrams can be difficult, and the first design is rarely the final
design. Class-Responsibility-Collaboration (CRC) cards are a tool used to simplify the
analysis and design process.
Analysts use index cards to represent each prospective class. Each card is labeled with the
name of the class. A group of analysts and designers meet to discuss how the classes might
interact, and a list of fundamental responsibilities is created for each class. These
responsibilities are listed on the card. Next to each responsibility is the name of a second
class with which the class must collaborate to fulfill the responsibility. Figure 10-7
illustrates a sample CRC card for the Check Out Controller class. Responsibilities are
listed in the left column, and the collaborating classes are listed in the right column.
Rather than continually redrawing collaboration diagrams, CRC cards can be shuffled
around a table as new scenarios are discussed. When analysts come to a consensus for a
particular use-case realization—analysis, they can begin translating the CRC cards into a
collaboration diagram. The resulting diagrams are then re-evaluated, perhaps several
times, until the team is satisfied with the design of the class interaction.
Class Analysis 153
CLASS ANALYSIS
After completing collaboration diagrams, analysts take a closer look at individual analysis
classes. CRC cards and collaboration diagrams provide information about the classes in a
use-case realization—analysis, their responsibilities, and the classes with which they
collaborate. During class analysis, each class is analyzed more closely to identify class
attributes, aggregations, and generalizations.
Attributes
Class attributes are properties of a class. In Chapter 2, class member variables were
introduced. Think about member variables in terms of their data types. Within the
analysis workflow, analysis classes are assigned properties. Unlike programmers, analysts
are not concerned with specifics of implementation such as data type. Analysis class
attributes can be defined in more general terms. For example, a book has an ISBN; the
specifics of whether the ISBN will be stored as a string or as a set of integers can be
addressed in design.
Aggregation is the "has a" relationship. A patron's account information includes a list of
assets currently checked out. Within the system, a patron's account and the list of assets
are both represented by classes. The patron's account "has an" asset list. This relationship
is called an aggregation because an asset list is part of a patron's account. In many ways,
this relationship is identical to attributes.
154 Chapter 10—Analysis Modeling
Generalization is the "is a" relationship. You will recall from Chapter 3 that the "is a"
relationship denotes inheritance. A book "is a" lendable asset. In that way, a book inherits
all the attributes and functionality of a lendable asset.
A few disadvantages of the way collaboration diagrams work include a lack of a clear
sequence of the process, or description of what happens when operations occur in
parallel. Thus, collaboration diagrams should be used only when a description of the
classes interacting is needed. When combined with the use of CRC cards, collaboration
diagrams provide a easy and efficient way to test class interactions as well as providing a
clear view of who will be involved with a process and how they will be involved.
Summary 155
1. Identify high-level classes and create CRC cards for each class.
2. Using the CRC cards you created in Step 1, consider how the various classes might
interact. Determine responsibilities and collaborations for each class and write
them on the CRC cards.
3. Create a collaboration diagram to depict the relationships between classes.
4. Create a flow-of-events description.
5. If any special requirements exist, consider creating a special-requirements
description.
6. Identify attributes of the analysis classes you identified in Step 1.
7. Identify associations, aggregations, and generalizations of the analysis classes you
identified in Step 1.
SUMMARY
Collaboration diagrams are a form of interaction diagram used to describe the interaction
between classes in a use-case realization—analysis. A second type of interaction diagram,
called a sequence diagram, conveys the same information as a collaboration diagram, with
an emphasis on the sequence of events. A flow-of-events description can accompany a
collaboration diagram to better communicate the sequence of message passing. A special-
requirements description listing any nonfunctional requirements may also accompany a
collaboration diagram. CRC cards are a tool used to simplify the analysis and design
process.
156 Chapter 10—Analysis Modeling
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What is the purpose of a flow-of-events description?
.....................................................................................................................................
.....................................................................................................................................
11
Class Diagrams
MMAAJJOORR T O P IICCSS
Association................................................................... 160
Composition................................................................ 165
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What three things does a UML class define?
.....................................................................................................................................
.....................................................................................................................................
Introduction 159
INTRODUCTION
In the previous chapter, you were introduced to the UML class notation. This class
notation is used to represent a class name, variables, and the methods that comprise a
class's interface. Figure 11-1 illustrates the UML class notation for the Asset class.
Asset
title: String
acquisitionDate: Date
replacementCost: float
dueDate: DueDate
public checkOut()
public calculateDueDate()
The UML classes, as illustrated in the preceding figure, are the building blocks of UML
class diagrams. They define a class' name, its attributes, and its public interface. These
elements are translated directly into program code. The static relationships also translate
into program code. Classes participate in four principal relationships:
● Association
● Aggregation
● Composition
● Generalization
160 Chapter 11—Class Diagrams
In this chapter, you will learn to define these static relationships between classes and
illustrate your design using class diagrams.
ASSOCIATION
The simplest relationship is an association. An association illustrates a "uses a"
relationship between instances of a class. An association provides a path for
communication between objects. In its most basic form, an association is represented by a
line between two classes. The examples in this chapter build upon the collaboration
diagram developed in Chapter 13. Figure 11-2 illustrates an association between the
CheckOutController class and the Patron class.
Patron
CheckOutController
name: String
accountID: String
The collaboration diagrams you developed earlier illustrated a relationship between the
CheckOutController and a Patron. This relationship is realized using a class diagram.
The association between them is a path for communication. The CheckOutController
class defines a pointer to a Patron object. The pointer will be used to communicate with
the patron.
Association 161
Navigability
Note from the earlier analysis that a Patron does not need to communicate back to the
CheckOutController; the association between these classes is unidirectional. This
relationship is known as navigability and is represented using an arrowhead. Figure 11-3
illustrates the one-way association relationship between the CheckOutController class
and the Patron class.
Patron
CheckOutController
name: String
accountID: String
This figure clearly shows that the CheckOutController class must communicate with a
Patron but a Patron need not communicate with a CheckOutController. In the program
code, the CheckOutController will have a pointer to a Patron, but a Patron will not have
a pointer to a CheckOutController.
162 Chapter 11—Class Diagrams
Multiplicity
Multiplicity is used to denote the number of instances of a class involved in a
relationship. During the check-out process, the CheckOutController handles only one
patron at a time. Therefore the CheckOutController maintains an association with a
single Patron object. The multiplicity of a relationship is denoted by labeling its ends.
Figure 11-4 illustrates the multiplicity of the association relationship between the
CheckOutController class and the Patron class.
Patron
CheckOutController 1
name: String
accountID: String
Multiplicity can be represented by a single cardinal number, such as the example in the
preceding figure. It can also be represented using a range of numbers or an asterisk.
Aggregation 163
AGGREGATION
Aggregation is used to show that one class is part of another class. Figure 11-5 illustrates
the aggregation relationship between the AssetList class and the Asset class. An asset list
contains assets; this is an aggregation relationship. This relationship is denoted using an
open diamond and a line between the classes. The open diamond on the AssetList side of
the relationship tells you that the AssetList "has an" Asset. The multiplicity indicator on
the Asset side of the relationship tells you that an asset list can have any number of assets,
from zero to infinity.
Asset
It can be difficult to determine when aggregation is appropriate. Examine the Asset class
in the preceding figure. The Asset class has four attributes: title, acquisitionDate,
replacementCost, and dueDate. When this class diagram is translated into program code,
each of these attributes will translate into a class member variable. Each of these attributes
participates in a "has a" relationship. Just as an AssetList "has an" Asset, so too an Asset
"has a" String, a Date, and so on.
The difference between the two relationships is subtle. Instances of Asset are treated as
reference objects by the AssetList class. The attributes of the Asset class are treated as
value objects.
164 Chapter 11—Class Diagrams
Reference objects
An instance of Patron is an example of a reference object. Reference objects are said to
have identity. A patron named James Smith will be represented within the system by a
Patron object. Only one James Smith object will exist, and the classes that interact with
the James Smith object will pass object references to each other. In this way, any class with
a reference to the James Smith object can make changes to the object and the changes will
be reflected in all classes.
Value objects
Attributes are value objects. Value objects are a part of one, and only one, class. The Asset
class has an attribute dueDate. Many of the assets checked out on the same day will have
the same due date, but these objects do not have identity. If one asset is checked in the
following day and checked out by another patron, its dueDate will be changed to a new
dueDate. Even though multiple assets have the same original due date, only the dueDate
for the Asset being checked out will change because each maintains its own dueDate
value object. The dueDate object will exist only as long as the Asset object that owns it
exists. If the Asset object is destroyed, the dueDate will be destroyed along with it. Also,
queries about the due date of an Asset object will return a copy of the dueDate object, not
a reference.
COMPOSITION
Composition is a second type of "has a" relationship between a class and a value object. It
is represented by a closed diamond and a line between classes. Figure 11-6 illustrates the
composition relationships between the Patron class and the AssetList class, and between
the CheckOutController class and the AssetList class. The CheckOutController
maintains a list of assets being checked out. Therefore, it must contain an AssetList. A
Patron also contains an AssetList. The Patron always maintains a list of the assets he has
checked out. These lists are not the same. The CheckOutController’s list contains only
those assets currently being checked out. The Patron may already have assets checked out
and so his list is maintained separately. The AssetList class is included in the class diagram
because of the relationship it maintains with the Asset class.
Asset
title: String
acquisitionDate: Date
replacementCost: float *
dueDate: DueDate
public checkOut()
public calculateDueDate()
Patron AssetList
name: String
1
accountID: String
public addAsset()
public deleteAsset()
1 1
CheckOutController
Patron
name: String
accountID: String
AssetList
public addAsset()
public deleteAsset()
CheckOutController
AssetList
public addAsset()
public deleteAsset()
GENERALIZATION
Generalization is the "is a" relationship. It is used to denote inheritance within a class
diagram. A generalization is represented by a line and an open arrowhead. Figure 11-8
illustrates the generalization relationship between the Book and AudioCassette classes and
the Asset class. Notice that the name of the Asset class is in italic print. This indicates that
the Asset class is an abstract class. The AssetList class maintains an aggregation
relationship with the Asset class. Because the Book and AudioCassette classes inherit from
the Asset class, either class can be substituted in this relationship.
Book AudioCassette
Asset
title: String
acquisitionDate: Date
replacementCost: float
dueDate: DueDate
public checkOut()
public calculateDueDate()
*
AssetList
public addAsset()
public deleteAsset()
Book AudioCassette
Asset
AssetDB
title: String
1 acquisitionDate: Date
* replacementCost: float *
public getAsset()
public updateAsset() dueDate: DueDate
public addAsset()
public deleteAsset() public checkOut()
public calculateDueDate()
1
Database
PatronDB
Patron AssetList
1 * name: String
1
public getPatron()
accountID: String public addAsset()
public updatePatron()
public addPatron() public deleteAsset()
public deletePatron()
1 1
1
CheckOutController
PayOverdueFineController
In the next few chapters, you will learn how to create two new types of diagrams:
sequence diagrams and statechart diagrams. You will use sequence diagrams to illustrate
the flow of messages between design classes, and you will use statechart diagrams to
illustrate the design of individual classes.
SUMMARY
Class diagrams illustrate the static relationships between classes in a system. Classes
participate in four principal relationships: association, aggregation, composition, and
generalization. Association is the "uses a" relationship. Aggregation and composition are
"has a" relationships. Aggregations are relationships between a class and a reference
object. Compositions are relationships between a class and a value object. Generalization
is the "is a" relationship, which is used to denote inheritance.
170 Chapter 11—Class Diagrams
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. Which of the four principal relationships illustrates a “uses a” relationship, which
illustrates a “has a” relationship, and which illustrates an “is a” relationship
between instances of a class.
.....................................................................................................................................
.....................................................................................................................................
12
Sequence Diagrams
MMAAJJOORR T O P IICCSS
Deletion....................................................................... 176
Multiplicity.................................................................. 176
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. In a sequence diagram, what does a box depict? What does a dashed line depict?
What does a arrow between boxes depict?
.....................................................................................................................................
.....................................................................................................................................
INTRODUCTION
In an earlier chapter, you were introduced to collaboration diagrams and you used them
to illustrate the flow of messages between objects. Sequence diagrams are a second type of
interaction diagram. Sequence diagrams convey the same information as collaboration
diagrams, but the sequence of events is more specific. You used collaboration diagrams
within the analysis workflow to illustrate the relationships between instances of analysis
classes. In this chapter, you will learn to use sequence diagrams to illustrate similar
relationships between instances of design classes.
Introduction 173
Figure 12-1 is a simple sequence diagram. Objects are depicted using boxes across the top
of the diagram. A vertical dashed line called a lifeline extends down from each object.
Messages are passed from one object to another, depicted by an arrow. Each message is
labeled. At this stage in the development process, the labels should correspond directly
with class methods defined in the class diagram. In this example, a CheckOutController
object calls the PatronDB object's getPatron method. The patronID variable is passed as
an argument.
: CheckOutController : PatronDB
getPatron(patronID)
RETURN VALUES
The sequence of events proceeds down the diagram. Figure 12-2 includes a second
message between the CheckOutController object and the Patron object. You can see that
this message is delivered after the getPatron message because it appears lower in the
diagram.
getPatron(patronID)
balance := getBalance()
As with collaboration diagrams, messages within a sequence diagram can have return
values. The getBalance method returns a patron's account balance. This value is stored as
a variable called balance. This variable can be used to set conditions on methods, or it can
be passed as an argument to subsequent methods.
The dotted arrow between the Patron object and the CheckOutController illustrates a
return from the getBalance method call. Returns could be included for all method calls
(including those without return values), but they are generally added only where they
contribute to the clarity of the diagram.
Message Conditions 175
MESSAGE CONDITIONS
Example 12-3 adds a third message, the payFine message. The payFine message is a call to
the PayOverdueFineController object. It transfers control to the portion of the system
that handles overdue fines. This message should only be passed if the patron owes an
overdue fine. To illustrate this, a condition is placed on the message. The condition is
indicated between brackets. In this example, the payFine message will only be passed if
the patron's account balance is greater than zero (balance > 0).
getPatron(patronID)
balance := getBalance()
DELETION
Notice the large X along the PayOverdueFineController lifeline in the preceding figure.
This X is called a deletion. A deletion indicates the death of an object. In this example,
the PayOverdueFineController is instantiated by the CheckOutController. Control is
transferred to the PayOverdueFineController object through the message payFine. Once
the overdue fine has been paid, the PayOverdueFineController deletes itself. The object
no longer exists and no additional messages can be sent to it. Objects may also be deleted
by other objects. A message arrow from one object's lifeline to a deletion on another
object's lifeline indicates that the deletion is performed by the first object.
MULTIPLICITY
Some messages may be sent multiple times. A patron may check out multiple assets
simultaneously. Figure 12-4 is the complete sequence diagram for the Check Out Asset
use case. The CheckOutController must add multiple assets to its AssetList object. The
addAsset method is called multiple times using a flow-control structure such as a while
loop. The multiplicity of this message is indicated with an iteration marker. The asterisk
next to the addAsset message indicates that this message may be sent multiple times.
controllerList
: CheckOutController : PatronDB : Patron : PayOverdueFineController patronList : AssetList : AssetDB : Asset
: AssetList
getPatron(patronID)
balance := getBalance()
* addAsset(assetID)
getAsset(assetID)
checkoutAssets(controllerList)
* addAsset()
RETURN STACK
As one class's method makes a call to another class's method, a reference is placed on the
return stack so the CPU knows where to return to when the called method is complete. If
the called method calls a third method, a second reference is placed on top of the first. As
execution of each method completes, the references are removed from the stack in reverse
order and control is passed back to calling methods in reverse order. This process is
illustrated using the boxes (called activation boxes) along the lifelines of objects in a
sequence diagram. An activation box indicates a reference to one of the object's methods
on the return stack.
In the preceding figure, the CheckOutController makes a call to the Patron object's
checkoutAssets method. Notice that the activation box along the Patron object's lifeline
extends down the diagram past the checkOut message. This notation indicates that this
calling method remains active and on the stack until the methods it calls have returned.
SUMMARY
Sequence diagrams are a form of interaction diagram. Like collaboration diagrams,
sequence diagrams illustrate the flow of messages between objects. Sequence diagrams are
used within the design workflow to illustrate the flow of messages between design classes.
Post-Test Questions 179
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. How does one go about illustrating the return stack’s processes in a sequence
diagram.
.....................................................................................................................................
.....................................................................................................................................
180 Chapter 12—Sequence Diagrams
13
Statechart Diagrams
MMAAJJOORR T O P IICCSS
Superstates................................................................... 185
OBJECTIVES
At the completion of this chapter, you will be able to:
PRE-TEST QUESTIONS
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. When is a superstate used in a statechart diagram?
.....................................................................................................................................
.....................................................................................................................................
INTRODUCTION
In an earlier chapter, you used class diagrams to illustrate how individual use cases will be
realized by a set of classes and static relationships. In this chapter, you will learn how
statechart diagrams can be used to illustrate the complete life cycle of a single object as it
exists throughout all use cases.
Statechart diagrams are similar to the activity diagrams you learned about in an earlier
chapter. As with activity diagrams, a closed circle represents the start of a sequence
diagram. Objects transition through a series of states until they destruct. States are
represented by rectangles with rounded corners, and transitions between states are
represented by arrows.
States 183
STATES
States are represented by rectangles with rounded corners. Each state is labeled with a
state name. States may also be labeled with an activity. Figure 13-1 is an example of a
state. The state name is Adding Assets. Below the state name, the activity "do/add assets"
means that as long as the object remains in this state, it will be in the process of adding
assets.
Adding Assets
do/add assets
TR A N S I T I O N S
The transition from one state to another is represented by an arrow. Figure 13-2 is a
statechart diagram for the CheckOutController class. The transition from the starting
point to the first state, Adding Assets, is automatic. As soon as a new
CheckOutController object is instantiated, it is moved into the Adding Assets state. Two
transitions exit the Adding Assets state; these transitions are labeled to indicate when each
will be followed.
The labels associated with transitions take the form of Event [Guard] / Action. All three
sections of the label are optional. The Event portion of the label describes an event that
will precipitate the transition. A Guard condition is a true-or-false condition that must be
true in order for the transition to be followed. The Action is a description of the action
that is taken following a transition.
184 Chapter 13—Statechart Diagrams
In Figure 13-2, two transitions exit the Adding Assets state. Notice that the Guard
conditions associated with these transitions are mutually exclusive: Only one can be true
at a time.
Adding Assets
[not all assets added]
do/add assets
Complete
SUPERSTATES
Situations often arise in which multiple states want to transition to the same state
through a single transition type. In the library system example, a librarian may choose to
cancel the check-out process at any time before the CheckOutController object reaches
the Complete state. All three of the states (Adding Assets, Verifying, and Checking Out
Assets) can transition to the Cancelled state if the user decides to cancel. Figure 13-3
illustrates the difficulty in diagramming this situation.
Adding Assets
[not all assets added]
do/add assets
cancelled
cancelled
cancelled
Cancelled Complete
Instead, you can use a superstate. A superstate contains other states. Figure 13-4 is the
CheckOutController class statechart diagram using a superstate. The Adding Assets,
Verifying, and Checking Out Assets states are contained within a superstate called Active.
As substates, they inherit any transition in which the Active superstate can participate. A
single transition between the Active state and the Cancelled state makes this diagram
functionally equivalent to Figure 13-3.
Active
Adding Assets
[not all assets added]
do/add assets
cancelled
Cancelled Complete
SUMMARY
Statechart diagrams are used to illustrate the complete life cycle of a single object as it
exists throughout all use cases. Statechart diagrams illustrate the series of state through
which an object will transition between its instantiation and destruction. States are
represented by rectangles with rounded corners. Transitions are represented by arrows.
Superstates can be used to make a statechart diagram easier to read.
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What do you use to represent a transition in a statechart diagram?
.....................................................................................................................................
.....................................................................................................................................
188 Chapter 13—Statechart Diagrams
14
MMAAJJOORR T O P IICCSS
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What is encapsulation?
.....................................................................................................................................
.....................................................................................................................................
INTRODUCTION
Every project should have a quality assurance process. This chapter will discuss common
quality assurance issues involved with creating software systems. The process should not
be thought of as something that occurs after most of the work is finished; it is an ongoing
process that occurs every step of the way.
Elements of Good Design 191
To achieve these goals, software designers must be mindful of proper design techniques.
Writing code for an object-oriented language does not guarantee an object-oriented
design. The language is only a tool. Indeed, it is possible to write object-oriented software
using non-object-oriented programming languages. You must pay attention to object-
oriented design principles to ensure that a proper object-oriented system is created. Well-
designed object-oriented software systems will exhibit the following characteristics:
● Encapsulation
● Abstraction
● High cohesion
● Loose coupling
Encapsulation
Earlier in this course, you learned how accessors and mutators are used to hide
implementation details. Accessors and mutators are intended to surround the data that
comprises a class. This technique is known as encapsulation, and it is critical to proper
object-oriented design.
192 Chapter 14—Design Quality Issues
Abstraction
Abstraction is closely related to encapsulation. In the first chapter, you learned that
software engineers think of objects as black boxes. Accessors and mutators provide an
interface to member data. Additional methods are defined to provide an interface to a
class’s functionality. The process of developing a class in terms of its interface and
functionality, rather than its implementation details, is called abstraction. No
implementation work is performed within the design workflow. The purpose of the
design workflow is to identify classes, define class interfaces, and describe class
interactions.
Cohesion
Classes are comprised of data and methods. Cohesion is a measure of how well these
pieces fit together. A cohesive class definition defines only the data and methods that are
relevant to the class. Consider the Book class. In the real world, a book has certain
attributes such as a title, an author, and an ISBN. A book can be checked out and then
checked back in. The class definition of a Book defines attributes for title, author, and
ISBN, as well as methods that allow a book to be checked in and out. The attributes
properly define a book, and the methods represent appropriate responsibilities for a book.
However, there may be a temptation to have the Book class perform less relevant
functions (such as verify a patron's account balance) before allowing itself to be checked
out. This represents an inappropriate responsibility of a Book and should be delegated to
another class.
Object-Oriented Design Metrics 193
Coupling
Coupling is the degree to which classes are interdependent. Class relationships such as
"has a" and "uses a" tighten coupling. The more a class must interact with other classes,
the tighter its coupling; this means it can be more difficult to make changes to the system,
replace classes, or export class definitions for use in new software systems.
50%
% of Classes
40
20
10 8 7 6 5 4
0 1 2 3 4 5 6 7 8 9
50%
% of Classes
45
35
15
10
5
0 1 2 3 4
1 2 3 4 5 6 7 8 9 10
Number of Children
50%
% of Methods
30
25
20
10 10
5
10 20 30 40 50 60 70 80 90 100%
Invisibility
SUMMARY
Properly designed object-oriented systems closely model the real world. A well-designed
object-oriented software system will exhibit encapsulation, abstraction, high cohesion,
and loose coupling. Encapsulation is the technique of wrapping data behind methods.
Abstraction is the process of developing a class in terms of its interface and functionality,
rather than its implementation details. Cohesion is a measure of how well the data and
methods that comprise a class fit together. Coupling is the degree to which classes are
interdependent. A variety of objective measures of design quality have been developed.
Chidamber and Kemerer identified six such metrics. The coupling between object classes
is a measure of how tightly coupled a class is. The depth of inheritance tree (DIT) metric
measures the depth of a class within the inheritance hierarchy. The number of children
(NOC) metric measures the number of subclasses that inherit directly from a class.
Another popular set of metrics is the metrics for object-oriented design (MOOD), which
provides a system-level perspective on design quality. The method hiding factor (MHF)
and attribute hiding factor (AHF) are measures of encapsulation. The method
inheritance factor (MIF) and attribute inheritance factor (AIF) are measures of
inheritance. The polymorphism factor (PF) is a measure of dynamic binding. The
coupling factor (CF) is a measure of coupling.
Post-Test Questions 201
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
1. What is abstaction?
.....................................................................................................................................
.....................................................................................................................................
2. What is cohesion?
.....................................................................................................................................
.....................................................................................................................................
3. What is coupling.
.....................................................................................................................................
.....................................................................................................................................
202 Chapter 14—Design Quality Issues
15
MMAAJJOORR T O P IICCSS
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
1. What are some variables to consider when configuring the process needed for a
project?
.....................................................................................................................................
.....................................................................................................................................
2. What are Use Cases?
.....................................................................................................................................
.....................................................................................................................................
3. The UML is divided into what application views?
.....................................................................................................................................
.....................................................................................................................................
Introduction 205
INTRODUCTION
By this point in the text, you should be familiar with the process involved with OOAD,
as well as its functional capabilities. The goal of this chapter is to suggest real life areas of
application of the processes learned throughout this book.
DETAIL LEVEL
Why does someone need to bother to learn about OOAD? Are there any practical
benefits to using any non-UML based techniques? The main purpose of UML is to take
advantage of object-oriented languages. One might argue that a considerable goal of
software development is to develop programs with code that is completely functional and
objectively easy to maintain. If a programmer can accomplish these tasks in a timely
manner, then they may be considered a “successful programmer.” But there are other
points to consider rather than just delivery of software on time. OOAD provides the
software engineering practices that ensure that software accomplishes its tasks while
permitting easy reuse and maintenance. A development process that introduces one
abstraction at a time until the entire approach to the process has been painted allows the
process to be handled at levels necessary for understanding the components of each. Once
you’ve grasped the function of the essential components, you can configure the process
needed for each project. Some of the variables to consider are: team size, project size,
project complexity, timeline, skill levels, domain type, and organizational maturity.
206 Chapter 15—Putting It All Together
TR A C I N G F O R W A R D A N D B A C K W A R D T H R O U G H O O A D
ARTIFACTS
Throughout this book, we will learn about each OOAD level, as well as tools and utilities
to apply to each of these levels. To make good software, all artifacts must be combined
and put together according to their logically flowing connections to each other. The first
technique incorporates use cases. Use cases are the external picture of your system that
explain the system’s capabilities. A good collection of use cases is central to understanding
what the users want. Use cases are also good for interacting with the clients and getting
feedback. One of the prevailing theories of object-oriented analysis is that a use case
model is the glue that holds a development together. We should also consider the
significance of the domain model, which provides a definition of the environment or
framework where the program resides. The third technique is logical architecture, which
is best defined as the apparent structure of the system in a language that can be used to
communicate with the user*.
The traditional use case treats the system as a black box and shows how the entities in its
environment interact with it. These may be referred to as external use cases, as they show
how external entities in the domain model interact with the system. They are called use
cases because they establish how the external entities use the system to accomplish
planned processes.
A P P L Y I N G O O A D TO S I T U A T I O N S
Situational OOAD seems to be the reason why many people study the details of object-
oriented programming. One can apply the methodologies taken from experience in
OOAD and incorporate them into solving problems in larger groups.
Organizing Teams 207
O R G A N I Z I N G TE A M S
Organizing software development teams is an essential task in producing well structured,
robust, and functional programs in a timely manner. Software development teams are
common in the software engineering profession. In most cases, the productivity of teams
using OOAD produce significant improvements over strict individual software
development methods. Companies often organize teams that perform specific tasks then
integrate this work to produce a single working model or program. Large projects often
consist of quality checking teams, testing teams, and managers within programming
groups, teams that take advantage of the combined resources that OOAD has to offer.
Ultimately, we can recognize the application of patterns as powerful and effective tools.
DEPLOYMENT DIAGRAMS
The UML is divided into three application views: the static view, which is modeled using
the use-case and class diagrams; the dynamic view, which is modeled using state
transition diagrams; and a view called the architectural view, which is modeled using
deployment diagrams.
Deployment diagrams help in the visualization of how the software will be implemented
onto the hardware. Often projects fail to keep in mind the types of hardware that the
products will run on. A maintenence of platform independence and hardware use is
helped with the development of deployment diagrams. These are easy to create and
navigate because they have similar diagram notations.
208 Chapter 15—Putting It All Together
REFACTORING
Consider the principle of Software Entropy. This principle simply applies when a
program begins with a successful OO structure and, by adding functionality to the
program, results in a relatively complex mass of code. Part of this is problem depends
upon the scale of the program, often smaller programs become unnecessarily complex in
a short amount of time. For example, adding new features to a program is like building
on top of a structure that was initially unable to support certain functionality, but is now
“modified” to support what is needed. In such situations your options may be to redesign
the entire program or to only work on rewriting the new additions. Gradually added
complexity provides a small hurdle in the development timeline but often produces long-
term benefits of increased functionality.
Refactoring is used as a technique that reduces the smaller redesign problems. Refactoring
focuses not on redesigning the functionality of a program but in redesigning the
structure. Refactoring changes are usually done in small steps such as renaming a method,
moving a field from one class to another, or consolidating two similar methods in a
superclass. Martin Fowler has defined the following as successful refactoring principles.
(“UML Distilled” 2000)
● “Do not do both refactoring and adding functionality at the same time. Put a clear
separation between the two when you are working. You might swap between them
in short steps: half an hour refactoring, an hour adding new function, half an hour
refactoring the code you just added.
● Make sure you have good tests before you begin refactoring. Run the tests as often
as possible. That way you will know quickly if your changes have broken anything.
● Take short deliberate steps: moving a field from one class to another, fusing two
similar methods into a superclass. Test after each step. This may sound slow, but it
avoids debugging, and thus speeds you up.”
In application, one should consider refactoring their programs when older code becomes
exhaustive to navigate and maintain. Refactoring old code often results in overall
program efficiency and often reinforces overall understanding of program function.
OOAD Artifacts and Implementation 209
APPLYING PATTERNS
The pattern is a fool-proof, repeated design that many programmers can use in similar
programming situations. Patterns give programmers a series of solutions and show
programmers what makes a good model and how to construct that model. It is similar to
a programmer's handbook that shows programmers how to do common things. Patterns
tend to look at the results of processes and example models, then describe common ways
of replicating the process. When teams are used for project design, it si an asset to have
knowledge about how to apply certain patterns and methods. It is not uncommon for
corporations to have a repository of documented patterns from the company’s history. A
software development group may then take each of these themes and describe them so
that other people can read the pattern and see how to apply it.
An important distinction to make between patterns and models is that a pattern must
include a description of its purpose and function. Patterns may consist of well
documented solutions, and they go beyond the basics of understanding a language or a
technique in modeling. Patterns provide not only solutions, but they establish proper
model construction and function. They tend to teach by example. Whenever someone
approaches a problem and implements OOAD, patterns often provide successful
solutions.
Combining layers
Pattern and model architecture is usually presented in a layered form. One should
consider combining similar layers when looking for simplicities in complex models or
patterns.
Brokering 211
BROKERING
Brokering has become popular with the distribution of the CORBA architecture.
CORBA enables programs to communicate with each other, despite a difference in
programming languages or operating systems. The Object Request Broker (ORB), as
defined by the Object Management Group, is a component in the CORBA
programming model. The brokering of information acts as middleware between
networks. In the CORBA model, a client may request specific services without having a
specifically designated server. ORBs receive the requests and act as an interface to forward
appropriate information to the appropriate servers and send any relevant results back to
the client.
SUMMARY
The main purpose of UML is to take advantage of object-oriented languages. OOAD
provides the software engineering practices that ensure the software accomplishes its tasks
while permitting easy reuse and maintenance. Some of the variables to consider when
configuring the process needed for a project are: tean size, project size,project complexity,
timeline, skill levels, domain type, and organizational maturity. To make good software,
all artifacts must be combined and put together according to their logically flowing
connections to each other. The UML is divided into three application views: the static
view, which is modeled using the use-case and class diagrams; the dynamic view, which is
modeled using state transition diagrams; and the architectural view, which is modeled
using deployment diagrams.
Refactoring is the technique that reduces the smaller redesign problems. Refactoring
focuses on redesigning the structure of the program and not redesigning the functionality
of the program. Refactoring should be considered when the programs older code
becomes exhausting to navigate and maintain. Refactoring old code results in overall
efficiency and reinforces overall understanding of program function.
212 Chapter 15—Putting It All Together
The primary artifacts of the UML can be defined from two perspectives: The definition
of UML and its use. The UML metamodel models elements and is similar to an object
model. Its main purpose is to provide common semantics of the elements of the UML.
The UML notation guide describes graphical UML notation and outlines the syntax
needed for model systems. Complex systems are constructed best by an organization of
small models working in a corresponding relationship with other models. A pattern is a
full-proof, repeated design that several programmers can use in similar programming
situations. Pattern and model architecture is usually presented in a layered form.
P O S T TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
1. What is refactoring?
.....................................................................................................................................
.....................................................................................................................................
2. What is the purpose of the UML metamodel?
.....................................................................................................................................
.....................................................................................................................................
3. What is the purpose of the UML notation guide?
.....................................................................................................................................
.....................................................................................................................................
16
MMAAJJOORR T O P IICCSS
OBJECTIVES
At the completion of this chapter, you will be able to:
P R E - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What three elements does a test model consist of?
.....................................................................................................................................
.....................................................................................................................................
INTRODUCTION
Within the test workflow, test designers develop a test model. The test model describes
how each build will be integration-tested and system-tested. The test model may also
describe tests to ensure that the system’s user interface components comply with the
interface requirements document. The test model consists of test cases, test procedures,
and test components. In this chapter, you will learn the purpose of each of the
components and how each is used to test the system before release.
Test Cases 215
TE S T C A S E S
A test case describes one way of testing the system. It specifies the input to the system, the
conditions under which the test should be conducted, and the output expected. There are
two general types of test cases: black-box test cases and white-box test cases.
Black-box test cases do not involve the internal workings of the system. A black-box test
case verifies that the interaction between the system and its users complies with the use-
case model. Each black-box test case corresponds to a single use case (although a single
use case may have several black-box test cases associated with it). White-box test cases
verify the interaction between components of the system. These interactions were already
specified by use-case realizations-design, and each white-box test case corresponds to a
single use-case realization-design. Figure 16-1 illustrates the relationship between test
cases and the model elements that they verify.
X
Use Case Black-Box Test Case
X
Use-Case Realization--Design White-Box Test Case
Table 16-1: Test case for the Check Out Asset use case
Input The account number 987654321 is entered into the Account Number
Field.
Output The name "James Smith" appears in the Name field.
The address "14 Red Robin Ln, Orange, CA" appears in the Address
field.
Conditions Account number 987654321 exists in the account database.
The account record for account number 987654321 reflects the name
"James Smith" and the address "14 Red Robin Ln, Orange, CA."
While each black-box test case relates to a single use case, each use case is tested by
numerous test cases. Additional test cases may test other aspects of the Check Out Asset
use case. Some may be nearly identical to the preceding example (except for differences in
the specific inputs, outputs and conditions). For example, a second test case may be
created to ask test engineers to enter the account number 123456789.
Each test case is evaluated on a pass/fail basis. If the outputs exactly match those
described by the test case, then it is said to pass. Any deviation results in a failure. A
document detailing test results will reference each test case individually and describe
system performance in each case as "pass" or "fail."
Test Procedures 217
TE S T P R O C E D U R E S
A test procedure describes the method for performing one or more tests. A test procedure
describes how input is entered into the system using the user interface, and how the user
interface reveals the results to the user. A single test procedure may apply to several test
cases, and each test case may be governed by multiple test procedures. Following is an
example of a test procedure that applies to the test case example presented earlier.
1. Begin execution of the librarian client by double-clicking the Library System icon.
2. From the opening screen, select the Accounts tab.
3. Click the Create New Account button.
4. In the dialog box that appears, enter the account number and information
provided by the test case.
5. Click the Done button.
6. Exit the librarian client by clicking the Close Window button (X) in the upper-
right corner of the window.
7. Reboot the client machine.
8. Begin execution of the librarian client by double-clicking the Library System icon.
9. From the opening screen, select the Check Out tab.
10. Enter the account number provided by the test case in the Account Number field,
and press ENTER.
11. The output should be displayed in the Name and Address fields on the same
screen.
Notice that the preceding test procedure is a general description of how the test case
should be implemented. This test procedure may be applied to all test cases designed to
verify the system’s ability to locate and display a patron’s account information.
218 Chapter 16—The Test Workflow
TE S T C O M P O N E N T S
Test components are used to automate the testing process. Test components are programs
or scripts that are executed against the system to perform testing. They may be developed
using scripting languages, proprietary test languages as part of a test-automation tool, or
as test classes that will be temporarily integrated with the system to perform testing.
Automated testing allows test engineers to more thoroughly test the system.
SUMMARY
The test model describes how each build will be integration-tested and system-tested.
The test model consists of test cases, procedures, and components. A test case describes
one way of testing the system. Each test case specifies the input to the system, the
conditions under which the test should be conducted, and the output expected. A test
procedure describes the method for performing one or more tests. A test procedure
describes how inputs are entered into the system using the user interface and how the user
interface reveals the results to the user. Test components are used to automate the testing
process. Test components are programs or scripts executed against the system to perform
testing.
Post-Test Questions 219
P O S T - TE S T Q U E S T I O N S
The answers to these questions are in Appendix A at the end of this manual.
.....................................................................................................................................
.....................................................................................................................................
2. What does a test procedure describe?
.....................................................................................................................................
.....................................................................................................................................
3. What are test components used for?
.....................................................................................................................................
.....................................................................................................................................
220 Chapter 16—The Test Workflow
231
SELF-STUDY
Glossary
<APPLET></APPLET>
HTML (Hyper Text Markup Language - the language used to code web pages) tags used to embed an
applet.
abstract
A class or method that is incompletely defined, used to collect shared properties, behaviors, or
attributes in a single superclass.
Abstract Windowing Toolkit (AWT)
A package of Java classes that support GUI (Graphical User Interface) programming - part of the JFC
(Java Foundational Classes).
abstraction
The consideration of an object in terms of its functionality and not its implementing details (see also
abstract).
accessor
A method designed to allow outside classes to access information about an object while maintaining
the principles of encapsulation and information hiding.
add()
A method of Container used to add components to a GUI container.
addItemListener()
One of a series of methods that register a listener object with its source for notification of some
specified change of state; this method is always of the form addSomeListener().
ALIGN
Optional attribute which can be imbedded within APPLET tags in HTML code; specifies the
position of the applet.
allocate
Java sets aside (allocates) enough space in memory for a data structure as soon as it is fully defined;
connected with the idea of instantiation.
ALT
Optional information to embed an applet; allows you to display a comment to a Java-disabled
browser.
anonymous inner class
An inner class defined within an expression; not a top level class which is part of a package.
applet
A small Java program that must be run from a Web browser or the Appletviewer; more restricted in
permitted activities than applications for security reasons.
232 Application Programming Interface (API)
Color
A class of the AWT that represents colors.
concatenation
The act of adding Strings together.
constructor
A special method having the same name as its class. It returns an instance of its class.
Container
An abstract, high-level component that offers JFrame and JPanel much of their functionality.
cooperative multitasking
A system of multitasking in which one task must willingly yield to another task.
coupling
The level of interdependency between objects.
daemon thread
A thread designed to service user threads. Daemon threads terminate after the last user thread
terminates.
dead
The state of a thread once it has been stopped or the run() method has exited.
deadlock
A condition that occurs when two or more threads reach an impasse due to competition for object
monitors.
default constructor
A constructor without parameters; Java assumes a default constructor until you define your own.
destroy()
The last method called in the life cycle of an applet; should be used to release system resources.
Domain Name System (DNS)
A system that converts domain names into corresponding IP addresses.
dot notation
A reference used to access a member of an object.
drawRect()
A method of the Graphics class.
encapsulation
The wrapping of variables and methods together; variables can only be accessed through the methods
provided.
entry condition/ exit condition
Condition based on whether the boolean expression is evaluated at the beginning or the end of the
loop.
Error
An inoperable condition that can occur in a program and cause it to terminate.
event
An occurrence or happening such as a pre-defined change of state in a component.
234 event delegation model
import
A statement that makes a package available for use within a class.
index
A numeric reference to a specific element of an array; the only way to access elements of an array.
inheritance
Properties or attributes of a class which are not explicitly stated but passed down from its
superclass(es).
init()
The first method called in the life cycle of an applet; it resembles a constructor.
inner class
A class defined within the body of another class.
InputStream
The abstract class from which all other input byte streams are derived.
InputStreamReader
A utility stream that converts a byte stream into a character stream for input.
instance and class variables
Variables defined outside of any method; they are available throughout the class.
instance member
A variable or method unique for each object (instance of the class).
instantiation
The use of a class definition to create an object.
interface
Term used to define a collection of method definitions and constant values which can be
implemented by classes that define this interface with the "implements" keyword.
IP (Internet Protocol) address
A numeric configuration used to identify a unique computer on the Internet.
java
The command given to execute bytecode (*.class) file.
Java 2 Software Development Kit (SDK)
A set of Java tools available from Sun for free; includes the Java compiler, interpreter and debugger,
along with documentation.
Java Virtual Machine (JVM)
The artificial computer that runs Java programs.
javac
The command that compiles a Java source file (*.java) into a bytecode file (*.class).
JButton
A simple clickable widget.
JComponent
A high-level Swing class from which many other components receive their core functionality.
236 JDK 1.0
JDK 1.0
The original release of the Java Software Development Kit, whose event model has now been
deprecated.
JFileChooser
A Swing component used to retrieve the names of files.
JFrame
The fundamental Window in Java; it cannot be contained in another container.
JLabel
A Swing widget used to place text in relation to an icon.
JPanel
A low–level Container used to hold other Containers; can also be used as a drawing surface.
JScrollBar
A Swing widget used to visually select a single value from a range.
JScrollPane
A Swing text-entry widget that adds scrolling functionality to other components.
JTextArea
A multiline text-entry widget in Swing
JTextField
A single-line text-entry widget in Swing.
label
An identifier that points to a specific line of the code to where a loop can break or continue.
layout managers
Objects used to control the positioning of Components within a Container.
length property
A characteristic of an array; more specifically, how many elements it contains.
life cycle
The life of an applet as defined by the init(), start(), stop() and destroy() methods.
listeners
Classes that listen for, and usually process, the events generated by an event source. Such classes will
implement an appropriate listener interface.
literal
A representation of an actual value for a data type. For example; 12 is a literal integer.
local variable
Variables defined inside of a method; they are not available when the method is not running.
logical operators
Operators &, |, ^, and ~ used on primitive data types to perform bitwise operations.
lower-level container
A Container that must be contained in another Container as in a JPanel.
main thread
The user thread created by the JVM from which all other user threads are generated.
object 237
member
A general term for both methods and variables.
member inner class
An inner class defined at the same scope as a method or instance variable.
method
A “callable” block of code defined within a class.
method signature
The method name and parameter types; the return type is not included in the signature.
modal
A property designating that a component blocks its parent Component until properly responded to.
monitor
In essence, the lock and key for an object
multiprocessing
The ability to run multiple processes (applications) in parallel.
multitasking
The ability to perform more than one function simultaneously.
multithreading
The ability to perform multiple lines of instruction within a single process.
mutator
A method that modifies a variable.
MyCloseableFrame$ MyButtonListener.class
The $ is the notation that the Java Compiler uses to identify an inner class.
nesting
The use of Containers within Containers to achieve sophisticated layouts or the use of conditionals
within other conditionals.
networking
Computer-to-computer communication across a distance.
new
A keyword that signals the JVM to allocate space for an object.
new
The state of a thread once it has been instantiated.
no-arguments constructor
A constructor for a class having no parameters; the default constructor is an example.
not runnable
The state of a thread when it is removed from the runnable queue but is not dead.
object
A generic term for non-primitive data types; objects represent data and the operations on data.
object
An instance of a class, with unique data and operations.
238 OutputStream
OutputStream
The abstract class from which all other output byte streams are derived.
OutputStreamWriter
A utility stream that converts a character stream into a byte stream for output.
overloading
Two or more methods with the same name and different parameter types; they usually implement
similar types of operations.
overridden method
A method in a derived class with the same method signature as that of a method in the superclass; it
replaces the superclass method for the subclass.
package
A collection of classes designated by the package keyword; Java stores the classes in a directory
structure based on the package.
paint()
An inherited method from Container that allows painting to the applet surface.
paintComponent
(Graphics g)
A method inherited from JComponent that is passed a reference to the graphics context of that
component.
parameter
Information sent to a called method which includes data type and local name.
parameter tags
Optional name/value tags that send information to an applet from within the HTML page.
pass by reference
A pointer to the data is passed to a method; changes made to the data by a method are also made to
the original data. Although Java always uses pass by value for primitive data types, pass by reference is
used for non-primitive data types because the value for a non-primitive type is a reference.
pass by value
A copy of the value of the variable is available to the method; changes to the copy do not affect the
original value; used by Java for primitive data types.
persistent
The ability to maintain a prior state.
polymorphism
Using one method name to invoke many different methods.
port
An integer from 0 to 65535 representing a particular path for information flow, a specific protocol is
typically associated with a particular port; usually associated with networking.
pre-emptive multitasking
A system of multitasking in which one task can pre-empt another task if it has a higher priority.
primitive data types
The basic data building blocks of the language; all the primitives consist of a single value.
servlet 239
private
Access modifier that is applied to the member only; restricts access to the class in which it is defined.
protected
Access modifier that allows the class to be seen by classes in the same package or subclasses in other
packages.
public
Access modifier that allows the class or member to be seen by every part of the program.
Reader
The abstract class from which all other input character streams are derived.
reference
Java stores the location of a non-primitive type in the variable; the actual memory for the type exists at
the pointed-to-memory location.
relational operators
Operators that compare values of variables; all evaluate to the boolean data type (false or true).
repaint()
A method of Component that is used to indirectly call paintComponent() for a graphics update.
run()
The method that contains the body of a thread.
runnable
The state of a thread once it has been started.
Runnable interface
An interface that prototypes the run() method, targeting it as a thread.
RuntimeException
A set of possible conditions that can occur in a program and cause an illegal operation.
sandbox
The strict security restrictions placed on applets.
scope
The range over which a variable is available for use.
SDK 1.2
The current release of SDK with a much improved event model.
SecurityManager
A Java class used by browsers to set security restrictions on an applet.
Serializable interface
An interface that marks an object to be serialized.
serialization
The process of maintaining an object's state by converting it into a byte stream.
ServerSocket
A class in Java that represents the socket model for servers.
servlet
A small Java application that runs on a server.
240 setColor()
setColor()
An overloaded method of the Graphics class that establishes the current color of the graphics
context.
short-circuit operators
Operators that do not evaluate all the relational operations unless necessary.
signed applet
A digitally signed applet; if accepted by the user, security limitations are reduced.
Socket
A class in Java that represents the socket model for clients.
source
The Component that generates the event object.
stand-alone application
A Java program that need not be run in a browser.
start()
The second method called in the life cycle of an applet.
start()
The method that starts a thread by calling the run() method.
static
A keyword used to designate a class variable (and also a class method). Class methods and variables
exist only one time, as opposed to instance methods and variables that exist for each object of the
class.
stop()
A method that works in conjunction with start(); should be used to suspend resource-draining code.
stream
A path of information from a source to a destination.
StringBuffer
A peer class to the String class; it is not immutable.
strongly typed
Requiring that the programmer specify the kind of information that each variable can hold; used to
describe a language.
super
The keyword used to refer to the superclass object; it allows you to call a method defined in the
superclass.
super
A keyword referring to the superclass of the current class.
superclass/subclass
The superclass is extended by the subclass. The subclass is derived from the superclass.
Swing
A GUI toolkit used by Java.
switch statement
A more complex conditional statement; chooses from multiple options.
Writer 241
synchronization
Controlling the flow of multiple, simultaneous threads.
synchronized
The keyword used to access an object's monitor.
System.in
Java's version of standard input (usually the keyboard).
System.out
Java's version of standard output (usually the monitor).
tag an object
Implementing a dummy interface on an object for the sole purpose of giving that object a type.
TCP/IP
The premier set of networking protocols used for the Internet.
this
A keyword that refers to the current object.
thread
A division of execution within a program. Each thread can be started and stopped and can wait for
other threads to suspend or run concurrently with them.
thread racing
Competition between two or more threads for the same resource.
thread states
The various ways of describing the current state of a thread.
top-level container
A Container that cannot be contained in another Container as in a JFrame.
transient
A member marked as transient will not be serialized.
type
Identifies the kind of information that a variable can store.
user thread
A thread created by other user threads with the purpose of being controlled by the programmer.
widgets
A term used to refer to visual Components of a GUI.
WIDTH/HEIGHT
Essential information needed to embed an applet; determines the size of the applet.
WindowListener
One of many interfaces that allow an object to receive certain events.
wrapper
A class that wraps around other stream classes to add functionality.
Writer
The abstract class from which all other output character streams are derived.
242
393
SELF-STUDY
Index
Symbols Applet .......................... 18, 39, 44, 57-59, 85,
93-95, 109, 111, 137, 198, 207, 239, 311
- ............................................................... 239 Applet features................................. 150, 160
"Event-to-property"................................. 144 Applet viewer............................................. 32
"Faux" variables ......................................... 70 Applet() .................................... 150, 159-160
% ............................................................. 239 Application programming interfaces
( ) ............................................................. 239 (apis) .................................................... 290
(Pme) paradigm ......................................... 14 Application template ............................... 190
* ............................................................... 239 Applications......................................... 17, 54
+............................................................... 239 Arranging and copying components........ 108
/ ............................................................... 239 Arranging components ............................ 109
=............................................................... 239 Array..........................283, 285-286, 300-301
= Null ........................................................ 46 Au, aiff, midi and wav ............................. 174
A Authentication......................................... 194
Awt ............................................................ 67
A project ......................................... 24-25, 35
Abstract...................................................... 45 B
Abstract windowing toolkit (awt) .............. 67 Background ............................................... 69
Action performed..................................... 127 Basic containers ......................................... 87
Actioncommand ................................ 73, 200 Bean........ 26, 63, 76, 225, 292, 296, 301-303
Actionevent.............................................. 131 Beaninfo ........................................... 297-298
Actionlistener................................... 127, 130 Beanname .................................................. 69
Actionperformed............... 126, 146-148, 200 Beans list......................................... 27-28, 35
Actionperformed feature.......................... 204 Beans list window................................ 28, 35
Actionperformed() ................................... 131 Block header .............................................. 41
Activex ..................................................... 291 Blue ........................................................... 43
Add ............................................................ 50 Body ........................................................ 161
Add (string) ............................................. 148 Boolean............................................ 234, 240
Add method ............................................... 93 Border...................................................... 100
Add(action).............................................. 154 Border layout........................................... 104
Adding new windows to an application... 206 Bound ...................................................... 299
Additem(string) ....................................... 149 Box .......................................................... 100
Addition................................................... 239 Box layout................................................ 107
Alignment.................................... 71, 99, 102 Break ....................................................... 280
All problems ............................................ 307 Browser.................................................... 208
An applet .............................................. 24-25 Bufferedreader ......................................... 216
Append(string)......................................... 153 Button ............................. 68, 73, 78, 86, 146
Button and checkbox components ............ 73
394 Index
H J
P R