OOAD-lecture Notes
OOAD-lecture Notes
OOAD-lecture Notes
ON
2018 – 2019
1
UNIT-1
Introduction: The Structure of Complex Systems, The Inherent Complexity of software, Attributes of
Complex System, Organized and Disorganized Complexity, Bringing Order to Chaos, Designing
Complex Systems, Evolution of Object model, Foundation of Object Model, Elements of Object Model,
Applying the Object model.
Complexity: Complexity depends on the number of the components embedded in them as well as the
relationships and the interactions between these components which carry;
• Impossible for humans to comprehend fully
• Difficult to document and test
• Potentially inconsistent or incomplete
• Subject to change
• No fundamental laws to explain phenomena and approaches.
2
3. The flexibility possible through software .
4. The problems of characterizing the behavior of discrete systems.
The software development is different: most of the software companies develop every single
component from scratch. Flexibility also triggers more demanding requirements which make products
even more complicated.
Software offers the ultimate flexibility. It is highly unusual for a construction firm to build an on site
steel mill to forge (create with hammer) custom girders (beams) for a new building. Construction industry
has standards for quality of raw materials, few such standards exist in the software industry.
3
The five Attributes of a complex system:
There are five attributes common to all complex systems. They are as follows:
1. Hierarchic Structure
Frequently, complexity takes the form of a hierarchy, whereby a complex system is
composed of interrelated subsystems that have in turn their own subsystems and so on, until some
lowest level of elementary components is reached.
The fact that many complex systems have a nearly decomposable, and hierarchic structure
is a major facilitating factor enabling us to understand, describe, and even "see" such systems their
parts.
2. Relative Primitives
The choice of what components in a system are primitive is relatively arbitrary and is
largely up to the discretion of the observer of the system class structure and the object
structure are not completely independent each object in object structure represents a specific
instance of some class.
3. Separation of Concerns
Hierarchic systems decomposable because they can be divided into identifiable parts; he
calls them nearly decomposable because their parts are not completly independent. This leads to
another attribute common to all complex systems:
Intra-component linkages are generally stronger than inter-component linkages. This fact
has the involving the high frequency dynamics of the components-involving the internal structure
of the components – from the low frequency dynamic involving interaction among components.
4. Common Patterns
Hierarchic systems are usually composed of only a few different kinds of subsystems in
various combinations and arrangements. In other words, complex systems have common patterns.
These patterns may involve the reuse of small components such as the cells found in both plants or
animals, or of larger structures, such as vascular systems, also found in both plants and animals.
5. Stable intermediate Forms
A complex system that works is invariably bound to have evolved from a simple system
that worked ……….. A complex system designed from scratch never works and can't be patched
up to make it work. You have to start over, beginning with a working simple system.
4
system take on the same (canonical) form as shown in figure. There are two orthogonal hierarchies of
system, its class structure and the object structure.
The figure represents the relationship between two different hierarchies: a hierarchy of objects
and a hierarchy of classes. The class structure defines the 'is-a' hierarchy, identifying the commonalities
between different classes at different levels of abstractions. Hence class C4 is also a class C1 and
therefore has every single property that C1 has. C4, however, may have more specific properties that C1
does not have; hence the distinction between C1 and C4. The object structure defines the 'part- of'
representation. This identifies the composition of an object from component objects, like a car is
composed from wheels, a steering wheel, a chassis and an engine. The two hierarchies are not entirely
orthogonal as objects are instances of certain classes. The relationship between these two hierarchies is
shown by identifying the instance-of relationship as well. The objects in component D8 are instances of
C6 and C7 As suggested by the diagram, there are many more objects then there are classes. The point in
identifying classes is therefore to have a vehicle to describe only once all properties that all instances of
the class have.
5
1. The Role of Abstraction: Abstraction is an exceptionally powerful technique for dealing with
complexity. Unable to master the entirely of a complex object, we choose to ignore its inessential details,
dealing instead with the generalized, idealized model of the object. For example, when studying about
how photosynthesis works in a plant, we can focus upon the chemical reactions in certain cells in a leaf
and ignore all other parts such as roots and stems. Objects are abstractions of entities in the real world.
In general abstraction assists people's understanding by grouping, generalizing and chunking
information. Object- orientation attempts to deploy abstraction. The common properties of similar objects
are defined in an abstract way in terms of a class. Properties that different classes have in common are
identified in more abstract classes and then an ‘is-a’ relationship defines the inheritance between these
classes.
2. The role of Hierarchy: Identifying the hierarchies within a complex software system makes
understanding of the system very simple. The object structure is important because it illustrates how
different objects collaborate with one another through pattern of interaction (called mechanisms). By
classifying objects into groups of related abstractions (for example, kinds of plant cells versus animal
cells, we come to explicitly distinguish the common and distinct properties of different objects, which
helps to master their inherent complexity.
Different hierarchies support the recognition of higher and lower orders. A class high in the ‘is-a’
hierarchy is a rather abstract concept and a class that is a leaf represents a fairly concrete concept. The ‘is-
a’ hierarchy also identifies concepts, such as attributes or operations, that are common to a number of
classes and instances thereof. Similarly, an object that is up in the part-of hierarchy represents a rather
coarse-grained and complex objects, assembled from a number of objects, while objects that are leafs are
rather fine grained. But note that there are many other forms of patterns which are nonhierarchical:
interactions, ‘relationships’.
3. The role of Decomposition: Decomposition is important techniques for copying with complexity
based on the idea of divide and conquer. In dividing a problem into a sub problem the problem becomes
less complex and easier to overlook and to deal with. Repeatedly dividing a problem will eventually lead
to sub problems that are small enough so that they can be conquered. After all the sub problems have
been conquered and solutions to them have been found, the solutions need to be composed in order to
obtain the solution of the whole problem. The history of computing has seen two forms of decomposition,
process-oriented (Algorithmic) and object-oriented decomposition.
Algorithmic (Process Oriented) Decomposition: In Algorithmic decomposition, each module in the
system denotes a major step in some overall process.
6
Object oriented decomposition: Objects are identified as Master file and check sum which derive
directly from the vocabulary of the problem as shown in figure. We know the world as a set of
autonomous agents that collaborate to perform some higher level behavior. Get formatted update thus
does not exist as an independent algorithm; rather it is an operation associated with the object file of
updates. Calling this operation creates another object, update to card. In this manner, each object in our
solution embodies its own unique behavior .Each hierarchy in layered with the more abstract classes and
objects built upon more primitive ones especially among the parts of the object structure, object in the
real world. Here decomposition is based on objects and not algorithms.
Algorithmic versus object oriented decomposition: The algorithmic view highlights the ordering of
events and the object oriented view emphasizes the agents that either cause action or are the subjects
upon which these operations act. We must start decomposing a system either by algorithms or by objects
then use the resulting structure as the framework for expressing the other perspective generally object
oriented view is applied because this approach is better at helping us organize the inherent complexity of
software systems. object oriented algorithm has a number of advantages over algorithmic
decomposition. Object oriented decomposition yields smaller systems through the reuse of common
mechanisms, thus providing an important economy of expression and are also more resident to change
and thus better able to involve over time and it also reduces risks of building complex software systems.
Object oriented decomposition also directly addresses the inherent complexity of software by helping us
make intelligent decisions regarding the separation of concerns in a large state space.
Process-oriented decompositions divide a complex process, function or task into simpler sub
processes until they are simple enough to be dealt with. The solutions of these sub functions then need to
be executed in certain sequential or parallel orders in order to obtain a solution to the complex process.
Object-oriented decomposition aims at identifying individual autonomous
objects that encapsulate both a state and a certain behavior. Then communication among these objects
leads to the desired solutions.
Although both solutions help dealing with complexity we have reasons to believe that an object-
oriented decomposition is favorable because, the object-oriented approach provides for a semantically
richer framework that leads to decompositions that are more closely related to entities from the real
world. Moreover, the identification of abstractions supports (more abstract) solutions to be reused and
the object-oriented approach supports the evolution of systems better as those concepts that are more
7
likely to change can be hidden within the objects.
On Designing Complex Systems
Engineering as a Science and an Art: Every engineering discipline involves elements of both science
and art. The programming challenge is a large scale exercise in applied abstraction and thus requires the
abilities of the formal mathematician blended with the attribute of the competent engineer. The role of
the engineer as artist is particularly challenging when the task is to design an entirely new system.
The meaning of Design: In every engineering discipline, design encompasses the discipline approach
we use to invent a solution for some problem, thus providing a path from requirements to
implementation. The purpose of design is to construct a system that.
1. Satisfies a given (perhaps) informal functional specification
2. Conforms to limitations of the target medium
3. Meets implicit or explicit requirements on performance and resource usage
4. Satisfies implicit or explicit design criteria on the form of the artifact
5. Satisfies restrictions on the design process itself, such as its length or cost, or the available for
doing the design.
According to Stroustrup, the purpose of design is to create a clean and relatively simple internal
structure, sometimes also called as architecture. A design is the end product of the design process.
The Importance of Model Building: The buildings of models have a broad acceptance among all
engineering disciplines largely because model building appeals to the principles of decomposition,
abstraction and hierarchy. Each model within a design describes a specific aspect of the system under
consideration. Models give us the opportunity to fail under controlled conditions. We evaluate each
model under both expected and unusual situations and then after them when they fail to behave as we
expect or desire. More than one kind of model is used on order to express all the subtleties of a complex
system.
The Elements of Software design Methods: Design of complex software system involves an
incremental and iterative process. Each method includes the following:
1. Notation: The language for expressing each model.
2. Process: The activities leading to the orderly construction of the system's mode.
3. Tools: The artifacts that eliminate the medium of model building and enforce rules about the
models themselves, so that errors and inconsistencies can be exposed.
The models of Object Oriented Development: The models of object oriented analysis and design
reflect the importance of explicitly capturing both the class and object hierarchies of the system under
design. These models also over the spectrum of the important design decisions that we must consider in
developing a complex system and so encourage us to craft implementations that embody the five
attributes of well formed complex systems.
The elements of the object oriented technology collectively known as the object model. The object
model encompasses the principles of abstraction, encapsulation, modularity, hierarchy, typing,
concurrency and persistency. The object model brought together these elements in a synergistic way.
9
6. Emergence of Frameworks (1990 – today)
- Visual Basic – Eased development of the graphical user interface (GUI) for windows
applications
- Java – Successor to Oak; designed for portability
- Python – Object oriented scripting language
- J2EE – Java based framework for enterprise computing
- .NET – Microsoft’s object based framework
- Visual C# - Java competitor for the Microsoft .NET framework
- Visual Basic .NET – VB for Microsoft .NET framework
Fig : The Topology of Late Second- and Early Third-Generation Programming Languages
10
The topology of late third generation programming languages
- Larger project means larger team, so need to develop different parts of same program independently,
i.e. complied module.
- Support modular structure.
Fig : The Topology of Small- to Moderate-Sized Applications Using Object-Based and Object-
Oriented Programming Languages
11
Fig : The Topology of Large Applications Using Object-Based and Object-Oriented
Programming Languages. 4
4. Hierarchy
Hierarchy is a ranking or ordering of abstractions Encapsulation hides company inside new of
abstraction and modularity logically related abstraction & thus a set of abstractions form hierarchy.
Hierarchies in complex system are its class structure (the "is a" hierarchy) and its object structure (the
"part of" hierarchy).
In this case, FruitGrowingPlan is more specialized, and GrowingPlan is more general. The same
could be said for GrainGrowingPlan or VegetableGrowingPlan, that is, GrainGrowingPlan “is a” kind
of GrowingPlan, and VegetableGrowingPlan “is a” kind of GrowingPlan. Here, GrowingPlan is the
more general superclass, and the others are specialized subclasses. 8
Figure 2.9: The Rose Class, Which Inherits from Multiple Superclasses (Multiple Inheritance)
9
Hierarchy: Aggregation
1. Typing
A type is a precise characterization of structural or behavioral properties which a collection of
entities share. Type and class are used interchangeably class implements a type. Typing is the
enforcement of the class of an object. Such that object of different types may not be interchanged.
Typing implements abstractions to enforce design decisions. E.g. multiplying temp by a unit of force
does not make serve but multiplying mass by force does. So this is strong typing. Example of strong and
weak typing: In strong type, type conformance is strictly enforced. Operations can not be called upon an
object unless the exact signature of that operation is defined in the object's class or super classes.
Static typing (static binding/early binding) refers to the time when names are bound to types i.e.
types of all variables are fixed at the time of compilation. Dynamic binding (late binding) means that
types of all variables and expressions are not known until run time. Dynamic building (object pascal,
C++) small talk (untyped).
2. Concurrency
OO-programming focuses upon data abstraction, encapsulation and inheritance concurrency
focuses upon process abstraction and synchronization. Each object may represent a separate thread of
actual (a process abstraction). Such objects are called active. In a system based on an object oriented
design, we can conceptualize the word as consisting of a set of cooperative objects, some of which are
active (serve as centers of independent activity) . Thus concurrency is the property that distinguishes an
active object from one that is not active. For example: If two active objects try to send messages to a
third object, we must be certain to use some means of mutual exclusion, so that the state of object being
acted upon is not computed when both active objects try to update their state simultaneously. In the
preserve of concurrency, it is not enough simply to define the methods are preserved in the presence of
multiple thread of control.
Examples of Concurrency
Let’s consider a sensor named ActiveTemperatureSensor, whose behavior requires periodically
sensing the current temperature and then notifying the client whenever the temperature changes a certain
number of degrees from a given setpoint. We do not explain how the class implements this behavior.
That fact is a secret of the implementation, but it is clear that some form of concurrency is required.
There are three approaches to concurrency in object oriented design
• Concurrency is an intrinsic feature of languages. Concurrency is termed as task in ada, and class
process in small talk. class process is used as super classes of all active objects. we may create
an active object that runs some process concurrently with all other active objects.
• We may use a class library that implements some form of light weight process AT & T task
library for C++ provides the classes’ sched, Timer, Task and others. Concurrency appears
15
through the use of these standard classes.
• Use of interrupts to give the illusion of concurrency use of hardware timer in active Temperature
sensor periodically interrupts the application during which time all the sensor read the current
temperature, then invoke their callback functions as necessary.
3. Persistence
Persistence is the property of an object through which its existence transcends time and or space i.e.
objects continues to exist after its creator ceases to exist and/or the object's location moves from the
address space in which it was created. An object in software takes up some amount of space and exists
for a particular amount of time. Object persistence encompasses the followings.
• Transient results in expression evaluation
• Local variables in procedure activations
• Global variables where exists is different from their scope
• Data that exists between executions of a program
• Data that exists between various versions of the program
• Data that outlines the Program.
16
UNIT II
Classes and Objects
Classes and Objects: Nature of Object, Relationships among objects, nature of a class, Relationship
among classes, interplay of classes and objects, Identifying classes and objects, Importance of proper
classification, Identifying classes and objects, Key abstractions and mechanisms
An object has state, behavior, and identity; the structure and behavior of similar objects are defined
in their common class; the terms instance and object are interchangeable.
State
The state of an object encompasses all of the (usually static) properties of the object plus the current
(usually dynamic) values of each of these properties.
Consider a vending machine that dispenses soft drinks. The usual behavior of such objects is that
when someone puts money in a slot and pushes a button to make a selection, a drink emerges from the
machine. What happens if a user first makes a selection and then puts money in the slot? Most vending
machines just sit and do nothing because the user has violated the basic assumptions of their operation.
Stated another way, the vending machine was in a state (of waiting for money) that the user ignored (by
making a selection first). Similarly, suppose that the user ignores the warning light that says, “Correct
change only,” and puts in extra money. Most machines are user-hostile; they will happily swallow the
excess money.
1
17
Behavior
Behavior is how an object acts and reacts, in terms of its state changeable state of object affect its
behavior. In vending machine, if we don't deposit change sufficient for our selection, then the machine
will probably do nothing. So behavior of an object is a function of its state as well as the operation
performed upon it. The state of an object represents the cumulative results of its behavior.
An operation is some action that one object performs on another in order to elicit a reaction.
For example, a client might invoke the operations append and pop to grow and shrink a queue object,
respectively. A client might also invoke the operation length, which returns a value denoting the size of
the queue object but does not alter the state of the queue itself.
Message passing is one part of the equation that defines the behavior of an object; our definition for
behavior also notes that the state of an object affects its behavior as well.
Operations
An operation denotes a service that a class offers to its clients. A client performs 5 kinds of operations
upon an object.
In practice, we have found that a client typically performs five kinds of operations on an object
The three most common kinds of operations are the following:
Examples:
1. A bank account may have the role of a monetary asset to which the account owner may deposit or
withdraw money. However, to a taxing authority, the account may play the role of an entity whose
dividends must be reported on annually.
2. To a trader, a share of stock represents an entity with value that may be bought or sold; to a lawyer, the
same share denotes a legal instrument to which are attached certain rights.
3. In the course of one day, the same person may play the role of mother, doctor, gardener, and movie
critic.
Identity
Identity is that property of an object which distinguishes it from all others.
Example:
Consider a class that denotes a display item. A display item is a common abstraction in all GUI-centric
systems: It represents the base class of all objects that have a visual representation on some window and
so captures the structure and behavior common to all such objects. Clients expect to be able to draw,
select, and move display items, as well as query their selection state and location. Each display item has a
18
location designated by the coordinates x and y.
First declaration creates four names and 3 distinct objects in 4 diff location. Item 1 is the name of a
distinct display item object and other 3 names denote a pointer to a display item objects. Item 4 is no such
objects, we properly say that item 2 points to a distinct display item object, whose name we may properly
refer to indirectly as * item2. The unique identity (but not necessarily the name) of each object in
preserved over the lifetime of the object, even when its state is changed. Copying, Assignment, and
Equality Structural sharing takes place when the identity of an object is aliased to a second name.
A link denotes the specific association through which one object (the client) applies the services
of another object (the supplier) or through which are object may navigate to another.
A line between two object icons represents the existence of pass along this path.
Messages are shown as directed lines representing the direction of message passing between two
objects is typically unidirectional, may be bidirectional data flow in either direction across a link.
19
Figure :Links
In the above figure, FlowController acts as a controller object, DisplayPanel acts as a server object,
and Valve acts as a proxy.
Visibility
Consider two objects, A and B, with a link between the two. In order for A to send a message to
object B, B must be visible to A. Four ways of visibility
• The supplier object is global to the client
• The supplier object is a programmer to some operation of the client
• The supplier object is a part of the client object.
• The supplier object is locally declared object in some operation of the client.
Synchronization
Wherever one object passes a message to another across a link, the two objects are said to be
synchronized. Active objects embody their own thread of control, so we expect their semantics to be
guaranteed in the presence of other active objects. When one active object has a link to a passive one, we
must choose one of three approaches to synchronization.
1. Sequential: The semantics of the passive object are guaranteed only in the presence of a single
active object at a time.
2. Guarded: The semantics of the passive object are guaranteed in the presence of multiple
threads of control, but the active clients must collaborate to achieve mutual exclusion.
3. Concurrent: The semantics of the passive object are guaranteed in the presence of
multiple threads of control, and the supplier guarantees mutual exclusion.
2.Aggregation
Figure : Aggregation
20
Whereas links denote peer to peer or client/supplier relationships, aggregation denotes a whole/part
hierarchy, with the ability to navigate from the whole (also called the aggregate) to its parts.
Aggregation is a specialized kind of association. Aggregation may or may not denote physical
containment. E.g. airplane is composed of wings, landing gear, and so on. This is a case of physical
containment. The relationship between a shareholder and her shares is an aggregation relationship that
doesn't require physical containment.
Figure Association
Multiplicity/Cardinality
This multiplicity denotes the cardinality of the association. There are three common kinds of multiplicity
across an association:
1. One-to-one 2. One-to-many 3. Many-to-many
2. Aggregation
2.
Aggregation is a special kind of association, representing a structural relation ship
between a whole and its parts. Aggregation relationships among classes have a direct parallel to
aggregation relationships among the objects corresponding to these classes.
21
Figure : Aggregation
As shown in Figure, the class Temperature Controller denotes the whole, and the class
Heater is one of its parts.
3. Inheritance
Inheritance, perhaps the most semantically interesting of the concrete relationships, exists
to express generalization/specialization relationships. Inheritance is a relationship among classes wherein
one class shares the structure and/or behavior defined in one (single inheritance) or more (multiple
inheritance) other classes. Inheritance means that subclasses inherit the structure of their superclass.
Single Inheritence:
The derived class having only one base class is called single inheritance. It is a relationship among
classes where in one class shares the structure and/or behavior defined one class.
22
Figure illustrates the single inheritance relationships deriving from the superclass TelemetryData.
Each directed line denotes an “is a” relationship. For example, CameraData “is a” kind of SensorData,
which in turn “is a” kind of TelemetryData.
Multiple Inheritence:
The derived class having more than one base class is known as multiple inheritance. It is a
relationship among classes where in one class shares the structure and/or behavior defined more classes.
Polymorphism
Polymorphism is an ability to take more than one form. It is a concept in type theory wherein a
name may denote instances of many different classes as long as they are related by some common
superclass. Any object denoted by this name is thus able to respond to some common set of operations in
different ways. With polymorphism, an operation can be implemented differently by the classes in the
hierarchy.
23
Figure : Polymorphisms
Consider the class hierarchy in Figure, which shows the base class DisplayItem along with three
subclasses named Circle, Triangle, and Rectangle. Rectangle also has one subclass, named
SolidRectangle. In the class DisplayItem, suppose that we define the instance variable theCenter
(denoting the coordinates for the center of the displayed item), along with the following operations:
■ draw: Draw the item.
■ move: Move the item.
■ location: Return the location of the item.
The operation location is common to all subclasses and therefore need not be redefined, but we
expect the operations draw and move to be redefined since only the subclasses know how to draw and
move themselves.
12
24
The Role of Classes and Objects in Analysis and Design
During analysis and the early stages of design, the developer has two primary tasks
1. Identify the classes that form the vocabulary of the problem domain
2. Invent the structures whereby sets of objects work together to provide the behaviors that satisfy
the requirements of the problem
Collectively, we call such classes and objects the key abstractions of the problem, and We
call these cooperative structures the mechanisms of the implementation.
Part-II(Classification)
Classification is the means whereby we order knowledge. There is no any golden path to
classification. Classification and object oriented development: The identification of classes and objects is
the hardest part of object oriented analysis and design, identification involves both discovery and
invention. Discovery helps to recognize the key abstractions and mechanisms that form the vocabulary of
our problem domain. Through invention, we desire generalized abstractions as well as new mechanisms
that specify how objects collaborate discovery and inventions are both problems of classifications.
Intelligent classification is actually a part of all good science class of should be meaningful is
relevant to every aspect of object oriented design classify helps us to identify generalization,
specialization, and aggregation hierarchies among classes classify also guides us making decisions about
modularizations.
In word processing system, is character class or words are class? Intelligent classification is
difficult e.g. problems in classify of biology and chemistry until 18th century, organisms were arranged
from the most simple to the most complex, human at top of the list. In mid 1970, organisms were
classified according to genus and species. After a century later, Darwin's theory came which was
depended upon an intelligent classification of species. Category in biological
taxonomy is the kingdom, increased in order from phylum, subphylum class, order, family, genus and
finally species. Recently classify has been approached by grouping organisms that share a common
generic heritage i.e. classify by DNA. DNA in useful in distinguishing organisms that are structurally
similar but genetically very different classify depends on what you want classification to do. In ancient
times, all substances were through to be sure ambulation of earth, fire, air and water. In mid 1960s –
elements were primitive abstractive of chemistry in 1869 periodic law came.
1. Classical categorizations
All the entities that have a given property or collection of properties in common forms a
category. Such properties are necessary and sufficient to define the category. i.e. married people
constitute a category i.e. either married or not. The values of this property are sufficient to decide to
which group a particular person belongs to the category of tall/short people, where we can agree to some
absolute criteria. This classification came from Plato and then from Aristotle's classification of plants
and animals.
This approach of classification is also reflected in modern theories of child development. Around
the age of one, child typically develops the concept of object permanence, shortly thereafter, the child
acquires skill in classifying these objects, first using basic category such as dogs, cats and toys.
2. Conceptual clustering
It is a more modern variation of the classical approach and largely derives from attempts to
explain how knowledge is represented in this approach, classes are generated by first formulating
conceptual description of these classes and then classifying the entities according to the descriptions. e.g.
we may state a concept such as "a love song". This is a concept more than a property, for the "love
songness" of any song is not something that may be measured empirically. However, if we decide that a
certain song is more of a love song than not, we place it in this category. thus this classify represents
more of a probabilistic clustering of objects and objects may belong to one or more groups, in varying
degree of fitness conceptual clustering makes absolute judgments of classify by focusing upon the best
fit.
3. Prototype theory
It is more recent approach of classify where a class of objects is represented by a prototypical
object, an object is considered to be a member of this class if and only if it resembles this prototype in
significant ways. e.g. category like games, not in classical since no single common properties shared by
all games, e.g. classifying chairs (beanbag chairs, barber chairs, in prototypes theory, we group things
according to the degree of their relationship to concrete prototypes.
There approaches to classify provide the theoretical foundation of objected analysis by which we identify
classes and objects in order to design a complex software system.
Classical approaches
It is one of approaches for analysis which derive primarily from the principles of classical categorization.
e.g. Shlaer and Mellor suggest that classes and objects may come from the following sources:
• Tangible things, cars, pressure sensors
26
• Roles – Mother, teacher, politician
• Events – landing, interrupt
• Interactions – meeting
From the perspective of database modeling, ross offers the following list:
(i) People – human who carry out some function
(ii) Places – Areas set for people or thing
(iii) Things – Physical objects (tangible)
(iv) Organizations – organized collection of people resources
(v) Concepts – ideas
(vi) Events – things that happen
Coad and Yourdon suggest another set of sources of potential objects.
(i) Structure
(ii) Dences
(iii) Events remembered (historical)
(iv) Roles played (of users)
(v) Locations (office, sites)
(vi) Organizational units (groups)
Behavior Analysis
Dynamic behavior also be one of the primary source of analysis of classes and objects things
can are grouped that have common responsibilities and form hierarchies of classes (including
superclasses and subclasses). System behaviors of system are observed. These behaviors are assigned to
parts of system and tried to understand who initiates and who participates in these behaviors. A function
point is defined as one and user business functions and represents some kind of output, inquiry, input file
or interface.
Domain Analysis
Domain analysis seeks to identify the classes and objects that are common to all applications
within a given domain, such as patient record tracking, compliers, missile systems etc. Domain analysis
defined as an attempt to identify the objects, operations and, relationships that are important to particular
domain.
More and Bailin suggest the following steps in domain analysis.
i) Construct a strawman generic model of the domain by consulting with domain expert.
ii) Examine existing system within the domain and represent this understanding in a
common format.
iii) Identify similarities and differences between the system by consulting with domain
expert.
iv) Refine the generic model to accommodate existing systems.
Horizontal domain Analysis: Applied to related parts of the same application domain expert is like
doctor in a hospital concerned with conceptual classification.
CRC cards
CRC are a useful development tool that facilitates brainstorming and enhances communication
among developers. It is 3 x 5 index card (class/Responsibilities/collaborators i.e. CRC) upon which the
analyst writes in pencil with the name of class (at the top of card), its responsibilities
(on one half of the card) and its collaborators (on the other half of the card). One card is created for each
class identified as relevant to the scenario. CRC cards are arranged to represent
generalization/specialization or aggregation hierarchies among the classes.
Structured Analysis
Same as English description as an alternative to the system, many CASE tools assists in
modeling of the system. In this approach, we start with an essential model of the system, as described by
data flow diagrams and other products of structured analysis. From this model we may proceed to identify
the meaningful classes and objects in our problem domain in 3 ways.
• Analyzing the context diagrams, with list of input/output data elements; think about what they tell
you or what they describe e.g. these make up list of candidate objects.
• Analyzing data flow domains, candidate objects may be derived from external entities, data
stores, control stores, control transformation, candidate classes derive from data flows and
candidate flows.
• By abstraction analysis: In structured analysis, input and output data are examined and followed
inwards until they reach the highest level of abstraction.
Identification of Abstractions:
identification of key abstraction involves two processes. Discovery and invention through
discovery we come to recognize the abstraction used by domain experts. If through inventions, we create
new classes and objects that are not necessarily part of the problem domain. A developer of such a
system uses these same abstractions, but must also introduce new ones such as databases, screen
managers, lists queues and so on. These key abstractions are artifacts of the particular design, not of the
problem domain.
28
subclass difficult because of the large semantic gap. This is called a grain size conflict.
Naming conventions are as follows:
- Objects should be named with proper noun phrases such as the sensor or simply shapes.
- Classes should be named with common noun phrases, such as sensor or shapes.
- Modifier operations should be named with active verb phrases such as draw, moveleft.
- Selector operations should imply a query or be named with verbs of the form "to be" e.g. is open,
extent of.
Identifying Mechanisms
A mechanism is a design decision about how collection of objects cooperates. Mechanisms
represent patterns of behavior e.g. consider a system requirement for an automobile: pushing the
accelerator should cause the engine to run faster and releasing the accelerator should cause the engine to
run slower. Any mechanism may be employed as long as it delivers the required behavior and thus which
mechanism is selected is largely a matter of design choice. Any of the following design might be
considered.
- A mechanical linkage from the acceleration to the (the most common mechanism)
- An electronic linkage from a preserve sensor below the accelerator to a computer that
controls the carburetor (a drive by wire mechanism)
- No linkage exists; the gas tank is placed on the roof of the car and gravity causes fuel to
flow to the engine. Its rate of flow is regulated by a clip around the fuel the pushing on the
accelerator pedal eases tension on the clip, causing the fuel to flow faster (a low cost
mechanism)
Examples of mechanisms:
Consider the drawing mechanism commonly used in graphical user interfaces. Several objects
must collaborate to present an image to a user: a window, a new, the model being viewed and some
client that knows when to display this model. The client first tells the window to draw itself. Since it may
encompass several subviews, the window next tells each if its subviews to draw them. Each subview in
turn tells the model to draw itself ultimately resulting in an image shown to the user.
PREVIOUS QUESTIONS
1. Discuss about possible relationships formed among the objects with example.
2. Describe how to identify classes and objects in detail.
3. Explain interplay of classes and objects.
4. State importance of proper classification using an example.
5. Describe Key abstraction.
22
29
UNIT-III
Introduction to UML: Why we model, Conceptual model of UML, Architecture,
Classes, Relationships, Common mechanisms, Class diagrams, object diagrams.
Why we model
The importance of Modeling:
A model is a simplification of reality. A model provides the blueprints of a system. Every
system may be described from different aspects using different models, and each model is
therefore a semantically closed abstraction of the system.
A model may be structural, emphasizing the organization of the system, or it may be
behavioral, emphasizing the dynamics of the system. We build models so that we can better
understand the system we are developing.
Through modeling, we achieve four aims.
1. Models help us to visualize a system as it is or as we want it to be.
2. Models permit us to specify the structure or behavior of a system.
3. Models give us a template that guides us in constructing a system.
4. Models document the decisions we have made.
Modeling is not for big systems. Even the software equivalent of a dog house can
benefit from some modeling. For example if you want to build a dog house ,you can start with a
pile of lumber, some nails, and a basic tools, such as a hammer,saw,and a tape measure. In few
hours, with little prior planning, you will likely
end up a with a dog house that's reasonably functional. finally your will happy and get a less
demanding dog.
if you want to build a house for your family , you can start with a pile of lumber, some
nails, and a basic tools. But it's going to take you a lot longer, and your family will certainly be
more demanding than the dog. If you want to build a quality house that meets the needs of
your family and you will need to draw some blue prints.
Principles of Modeling:
UML is basically a modeling language; hence its principles will also be related to
modeling concepts. Here are few basic principal of UML.
First: "The choice of what models to create has a profound influence on how a problem is
attacked and how a solution is shaped"
In other words ,choose your models well. The right models will brilliantly illuminate the
most wicked development problems. The wrong models will mislead you, causing you to focus
on irrelevant issues.
30
Second: " Every model may be expressed at different levels of precision ".
Best approach to a given problem results in a best model. If the problem is complex
mechanized level of approach & if the problem is simple decent approach is followed.
The model built should have strong resemblance with the system.
Fourth: " No single model is sufficient. Every nontrivial system is best approached through a
small set of nearly independent models."
If you constructing a building, there is no single set of blueprints that reveal all its
details. At the very least, you will need floor plans,elevations,electical plans, heating plans, and
plumbing plans.
Object-Oriented Modeling:
In software , there are several ways to approaches a model. The two most common
ways are
1. Algorithmic perspective
2. Object-Oriented perspective
1. Algorithmic perspective:
In this approach, the main building blocks of all software is the procedure or
functon.This view leads developers to focus on issues of control and decomposition of larger
algorithms into smaller ones.
2. Object-Oriented perspective:
In this approach, the main building blocks of all software is the object or class. Simply
put, an object is a thing. A class is a description of a set of common objects. Every object has
identity, state and behavior.
For example, consider a simple a three-tier -architecture for a billing system, involving a
user interface ,middleware, and a data base. In the user interface, you will find concrete
objects, such as buttons, menus, and dialog boxes. In the database, you will find concrete
objects ,such as tables. In the middle layer ,you will find objects such as transitions and business
rules.
31
1. Things in the UML
2. Relationships in the UML
3. Diagrams in the UML
1.Things in the UML: -
Things are the abstractions that are first-class citizens in a model. There are four kinds of
things in the UML:
1. Structural things
2. Behavioral things
3. Grouping things
4. Annotational things
1. Structural things:
Structural things are the nouns of UML models. These are the mostly static parts of a
model. There are seven kinds of structural things. They are a. Class
b. Interface
c. Collaboration
d. Use case
e. Activity Class
f. Component
g. Node
a) Class:
A class is a description of a set of objects that share the same attributes, operations,
relationships, and semantics. A class implements one or more interfaces. Graphically, a class is
rendered as a rectangle, usually including its name, attributes, and operations.
b) Interface:
An interface is a collection of operations that specify a service of a class or component.
Graphically, an interface is rendered as a circle together with its name.
C) Collaboration:
Collaboration defines an interaction and is a society of roles and other elements that
work together to provide some cooperative behavior that's bigger than the sum of all the
elements. Graphically, a collaboration is rendered as an ellipse with dashed lines, usually
including only its name.
32
d) Use case:
A use case is a description of set of sequence of actions that a system performs that
yields an observable result of value to a particular actor. A use case is used to structure the
behavioral things in a model. A use case is realized by a collaboration. Graphically, a use case is
rendered as an ellipse with solid lines, usually including only its name.
e)Active class
An active class is a class whose objects own one or more processes or threads and
therefore can initiate control activity.Graphically, an active class is rendered just like a class, but
with heavy lines, usually including its name, attributes, and operations.
f) Component:
A Component is a physical and replaceable part of a system that conforms to and
provides the realization of a set of interfaces. Graphically, a component is rendered as a
rectangle with tabs, usually including only its name.
g) Node:
A node is a physical element that exists at run time and represents a computational
resource, generally having at least some memory and, often, processing capability.Graphically,
a node is rendered as a cube, usually including only its name.
33
2. Behavioral things:
Behavioral things are the dynamic parts of UML models. These are the verbs of a model,
representing behavior over time and space. There are two primary kinds of behavioral things.
They are
a) Interaction
b)State machine
a) Interaction
Interaction is a a behavior that comprises a set of messages exchanged among a set of
objects within a particular context to accomplish specific purpose. An interaction involves a
number of other elements, including messages, action sequences (the behavior invoked by a
message), and links (the connection between objects). Graphically, a message is rendered as a
directed line, almost always including the name of its operation.
b)State machine
A State machine a number of other elements, including states, transitions (the flow
from state to state), events (things that trigger a transition), and activities (the response to a
transition).Graphically, a state is rendered as a rounded rectangle, usually including its name
and its sub states.
3. Grouping things:
Grouping things are the organizational parts of UML models. These are the boxes into
which a model can be decomposed. There is one primary kind of grouping thing, namely,
packages.
package:
A package is a general-purpose mechanism for organizing elements into groups.
Structural things, behavioral things, and even other grouping things may be placed in a
package.Graphically, a package is rendered as a tabbed folder, usually including only its name
and, sometimes, its contents.
34
4.Annotational things:
Annotational things are the explanatory parts of UML models. These are the comments
you may apply to describe, illuminate, and remark about any element in a model. There is one
primary kind of annotational thing, called a note.
Note:
A note is simply a symbol for rendering constraints and comments attached to an
element or a collection of elements. Graphically, a note is rendered as a rectangle with a dog-
eared corner, together with a textual or graphical comment.
1. Dependency:
A dependency is a semantic relationship between two things in which a change to one
thing (the independent thing) may affect the semantics of the other thing (the dependent
thing). Graphically, a dependency is rendered as a dashed line, possibly directed, and
occasionally including a label.
2. Association:
An association is a structural relationship that describes a set of links, a link being a
connection among objects. Aggregation is a special kind of association, representing a
structural relationship between a whole and its parts. Graphically, an association is rendered as
a solid line, possibly directed, occasionally including a label, and often containing other
adornments, such as multiplicity and role names.
3. Generalization:
A Generalization is a specialization/generalization relationship in which objects of the
specialized element (the child) are substitutable for objects of the generalized element (the
parent). In this way, the child shares the structure and the behavior of the parent. Graphically,
35
a generalization relationship is rendered as a solid line with a hollow arrowhead pointing to the
parent.
4.Realization:
A Realization is a semantic relationship between classifiers, wherein one classifier
specifies a contract that another classifier guarantees to carry out. Graphically, a realization
relationship is rendered as a cross between a generalization and a dependency relationship.
2.Object diagram:
An object diagram shows a set of objects and their relationships. Object diagrams
represent static snapshots of instances of the things found in class diagrams. These diagrams address
the static design view or static process view of a system .
4. Sequence diagram:
A sequence diagram is an interaction diagram that emphasizes the time-ordering of messages;
Interaction diagrams address the dynamic view of a system. Sequence diagrams and collaboration
diagrams are isomorphic, meaning that you can take one and transform it into the other.
36
5.collaboration diagram:
A collaboration diagram is an interaction diagram that emphasizes the structural organization of
the objects that send and receive messages. Interaction diagrams address the dynamic view of a system.
Sequence diagrams and collaboration diagrams are isomorphic, meaning that you can take one and
transform it into the other.
6. statechart diagram:
A statechart diagram shows a state machine, consisting of states, transitions, events,
and activities.Statechart diagrams address the dynamic view of a system.
7. Activity diagram
An activity diagram is a special kind of a state chart diagram that shows the flow from
activity to activity within a system. Activity diagrams address the dynamic view of a system.
8. component diagram:
A component diagram shows the organizations and dependencies among a set of
components. Component diagrams address the static implementation view of a system.
2.Adornments
Most elements in the UML have a unique and direct graphical notation that provides a
visual representation of the most important aspects of the element. A class's specification may
include other details, such as whether it is abstract or the visibility of its attributes and
operations. Many of these details can be rendered as graphical or textual adornments to the
class's basic rectangular notation.
For example, Figure shows a class, adorned to indicate that it is an abstract class with
two public, one protected, and one private operation.Every element in the UML's notation
starts with a basic symbol, to which can be added a variety of adornments specific to that
symbol.
3.Common Divisions
In modeling object-oriented systems, the world often gets divided in at least a couple of
ways.
In this figure, there is one class, named Customer, together with three objects: Jan
(which ismarked explicitly as being a Customer object), :Customer (an anonymous Customer
object),and Elyse (which in its specification is marked as being a kind of Customer object,
although it‘snot shown explicitly here).Graphically, the UML distinguishes an object by using the
same symbol as its class and then simply underlying the object's name.
2. interface and implementation.:
38
An interface declares a contract, and an implementation represents one concrete
realization of that contract, responsible for faithfully carrying out the interface's complete
semantics. In the UML, you can model both interfaces and their implementations, as shown in
Figure
In this figure, there is one component named spellingwizard.dll that implements two
interfaces, IUnknown and Ispelling.
4.Extensibility Mechanisms
The UML provides a standard language for writing software blueprints, but it is not
possible for one closed language to ever be sufficient to express all possible nuances of all
models across all domains across all time. The UML's extensibility mechanisms include
1. Stereotypes
2. Tagged values
3. Constraints
1. Stereotypes
A stereotype extends the vocabulary of the UML, allowing you to create new kinds of
building blocks that are derived from existing ones but that are specific to your problem.For
example, if you are working in a programming language, such as Java or C++, you will often
want to model exceptions.In these languages, exceptions are just classes, You can make
exceptions first class citizens in your models, meaning that they are treated like basic building
blocks, by marking them with an appropriate stereotype, as for the class Overflow in Figure.
2. Tagged values
A tagged value extends the properties of a UML building block, allowing you to create
new information in that element's specification. For example, if you want to specify the version
and author of certain critical abstractions. Version and author are not primitive UML concepts.
o For example, the class EventQueue is extended by marking its version and author
explicitly.
39
3. Constraints
A constraint extends the semantics of a UML building block, allowing you to add new
rules or modify existing ones. For example, you mght want to constrain the EventQueue class so
that all additions are done in order. As Figure shows, you can add a constraint that explicitly
marks these for the operation add.
Architecture:-
Software architecture is not only concerned with structure and behavior, but also with
usage, functionality, performance, resilience, reuse, comprehensibility, economic and
technology constraints. Below Figure shows, the architecture of a software-intensive system
can best be described by five interlocking views. Each view is a projection into the organization
and structure of the system, focused on a particular aspect of that system.
40
1. Design view:
The design view of a system encompasses the classes, interfaces, and collaborations
that form the vocabulary of the problem and its solution. This view primarily supports the
functional requirements of the system, meaning the services that the system should provide to
its end users. With the UML, the static aspects of this view are captured in class diagrams and
object diagrams; the dynamic aspects of this view are captured in interaction diagrams,
statechart diagrams, and activity diagram.
2. Process view:
The process view of a system encompasses the threads and processes that form the
system's concurrency and synchronization mechanisms. This view primarily addresses the
performance, scalability and throughput of the system. With the UML, the static aspects of this
view are captured in class diagrams and object diagrams; the dynamic aspects of this view are
captured in interaction diagrams, statechart diagrams, and activity diagram.
5. Deployment view:
The deployment view of a system encompasses the nodes that form the system's
hardware topology on which the system executes.This view primarily addresses the
distribution, delivery, and installation of the parts that make up the physical system.With the
UML, the static aspects of this view are captured in deployment diagrams; the dynamic aspects
of this view are captured in interaction diagrams, statechart diagrams, and activity diagrams.
Classes:-
Terms and Concepts
A class is a description of a set of objects that share the same attributes, operations,
relationships, and semantics. Graphically, a class is rendered as a rectangle
Names:
Every class must have a name that distinguishes it from other classes.. That name alone
is known as a simple name; a path name is the class name prefixed by the name of the package
in which that class lives. A class may be drawn showing only its name, as shown in Figure.
41
Class name may be text consisting of any number of letters, numbers, and certain
punctuation marks (except for marks such as the colon, which is used to separate a class name
and the name of its enclosing package) and may continue over several lines.
Attributes:
For example, every wall has a height, width, and thickness; we might model our
customers in such a way that each has a name, address, phone number, and date of
birth.
Graphically, attributes are listed in a compartment just below the class name. Attributes
may be drawn showing only their names.
Operations
An operation is the implementation of a service that can be requested from any object
of the class to affect behavior. A class may have any number of operations or no operations at
all.
42
For example, all objects of the class Rectangle can be moved, resized, or queried for
their properties. Graphically, operations are listed in a compartment just below the class
attributes. Operations may be drawn showing only their names, as in Figure.
To better organize long lists of attributes and operations, we can also prefix each group
with a descriptive category by using stereotypes, as shown in Figure
Responsibilities
Other Features
43
Attributes, operations, and responsibilities are the most common features you'll need when we
create abstractions. In fact, for most models we build, the basic form of these three features will
be all we need to convey the most important semantics of your classes.
Sometimes, we'll need to visualize or specify other features, such as the visibility of
individual attributes and operations; language-specific features of an operation, such as
whether it is polymorphic or constant; or even the exceptions that objects of the class
might produce or handle.
These and many other features can be expressed in the UML, but they are treated as
advanced concepts.
Finally, classes rarely stand alone. Rather, when we build models, we will typically focus
on groups of classes that interact with one another.
In the UML, these societies of classes form collaborations and are usually visualized in
class diagrams.
Figure shows a set of classes drawn from a retail system, including Customer, Order, and
Product. This figure includes a few other related abstractions drawn from the vocabulary of the
problem, such as Shipment (used to track orders), Invoice (used to bill orders), and Warehouse
(where products are located prior to shipment). There is also one solution-related abstraction,
Transaction, which applies to orders and shipments.
44
2. Modeling the Distribution of Responsibilities in a System
For example, Figure shows a set of classes drawn from Smalltalk, showing the
distribution of responsibilities among Model, View, and Controller classes. Notice how
all these classes work together such that no one class does too much or too little.
As Figure shows, these things can be modeled in the UML as types or enumerations,
which are rendered just like classes but are explicitly marked via stereotypes. Things like
integers (represented by the class Int) are modeled as types, and we can explicitly indicate the
range of values these things can take on by using a constraint. Similarly, enumeration types,
such as Boolean and Status, can be modeled as enumerations, with their individual values
provided as attributes.
Relationships:
A relationship is a connection among things. In object-oriented modeling, the three
most important relationships are dependencies, generalizations, and associations. Graphically,
a relationship is rendered as a path, with different kinds of lines used to distinguish the kinds of
relationships.
1.Dependency
46
2.Generalization
A class that has exactly one parent is said to use single inheritance; a class with more
than one parent is said to use multiple inheritance.
3.Association
47
Name
An association can have a name, and you use that name to describe the nature of the
relationship. So that there is no ambiguity about its meaning, you can give a direction to the
name by providing a direction triangle that point in the direction you intend to read the
name, as shown in Figure.
Role
When a class participates in an association, it has a specific role that it plays in that
relationship;
A role is just the face the class at the near end of the association presents to the class at the
other end of the association.
Aggregation
Other Features
48
abstractions. In fact, for most of the models you build, the basic form of these three
relationships will be all you need to convey the most important semantics of your
relationships.
Sometimes, you'll need to visualize or specify other features, such as composite
aggregation, navigation, discriminates, association classes, and special kinds of
dependencies and generalizations.
These and many other features can be expressed in the UML, but they are treated as
advanced concepts.
Dependencies, generalization, and associations are all static things defined at the level
of classes.
In the UML, these relationships are usually visualized in class diagrams.
When you start modeling at the object level, and especially when you start working with
dynamic collaborations of these objects, you'll encounter two other kinds of
relationships, links (which are instances of associations representing connections among
objects across which messages may be sent) and transitions (which are connections
among states in a state machine).
For example, Figure shows a set of classes drawn from a system that manages the
assignment of students and instructors to courses in a university. This figure shows a
dependency from CourseSchedule to Course, because Course is used in both the add and
remove operations of CourseSchedule.
The dependency from Iterator shows that the Iterator uses the CourseSchedule; the
CourseSchedule knows nothing about the Iterator. The dependency is marked with a
stereotype, which specifies that this is not a plain dependency, but, rather, it represents a
friend, as in C++.
49
Given a set of classes, look for responsibilities, attributes, and operations that are common
to two or more classes.
Elevate these common responsibilities, attributes, and operations to a more general class. If
necessary, create a new class to which you can assign these elements (but be careful about
introducing too many levels).
Specify that the more-specific classes inherit from the more-general class by placing a
generalization relationship that is drawn from each specialized class to its more-general
parent.
For example, Figure shows a set of classes drawn from a trading application. You will
find a generalization relationship from four classes• CashAccount, Stock, Bond, and Property,
to the more-general class named Security. Security is the parent, and CashAccount, Stock,
Bond, and Property are all children. Each of these specialized children is a kind of Security.
You'll notice that Security includes two operations: presentValue and history. Because Security
is their parent, CashAccount, Stock, Bond, and Property all inherit these two operations, and for
that matter, any other attributes and operations of Security that may be elided in this figure.
You can also create classes that have more than one parent. This is called multiple
inheritance and means that the given class has all the attributes, operations, and associations of
all its parents.
Figure shows a set of classes drawn from an information system for a school The
aggregation relationship between School and Department is composite aggregation, The
relationships between School and the classes Student and Department are a bit different. Here
you'll see aggregation relationships. A school has zero or more students, each student may be a
registered member of one or more schools, a school has one or more departments, each
department belongs to exactly one school. You could leave off the aggregation adornments and
use plain associations, but by specifying that School is a whole and that Student and
Department are some of its parts, you make clear which one is organizationally superior to the
other. Thus, schools are somewhat defined by the students and departments they have.
Similarly, students and departments don't really stand alone outside the school to which they
belong. Rather, they get some of their identity from their school.
You'll also see that there are two associations between Department and Instructor. One
of these associations specifies that every instructor is assigned to one or more departments and
that each department has one or more instructors. This is modeled as an aggregation because
organizationally, departments are at a higher level in the school's structure than are instructors.
The other association specifies that for every department, there is exactly one instructor who is
the department chair. The way this model is specified, an instructor can be the chair of no more
than one department and some instructors are not chairs of any department.
Common Mechanisms
51
UML is made simpler by the presence of four common mechanisms that apply
consistently throughout the language. They are:
1. Specifications
2. Adornments
3. Common divisions
4. Extensibility mechanisms
1.Specifications
The UML is more than just a graphical language. Rather, behind every part of its
graphical notation there is a specification that provides a textual statement of the syntax and
semantics of that building block. For example, behind a class icon is a specification that
provides the full set of attributes, operations (including their full signatures), and behaviors that
the class embodies;
2.Adornments
Most elements in the UML have a unique and direct graphical notation that provides a
visual representation of the most important aspects of the element. A class's specification may
include other details, such as whether it is abstract or the visibility of its attributes and
operations. Many of these details can be rendered as graphical or textual adornments to the
class's basic rectangular notation.
For example, Figure shows a class, adorned to indicate that it is an abstract class with
two public, one protected, and one private operation.Every element in the UML's notation
starts with a basic symbol, to which can be added a variety of adornments specific to that
symbol.
3.Common Divisions
In modeling object-oriented systems, the world often gets divided in at least a couple of
ways.
52
In this figure, there is one class, named Customer, together with three objects: Jan
(which ismarked explicitly as being a Customer object), :Customer (an anonymous Customer
object),and Elyse (which in its specification is marked as being a kind of Customer object,
although it‘snot shown explicitly here).Graphically, the UML distinguishes an object by using the
same symbol as its class and then simply underlying the object's name.
2. interface and implementation.:
An interface declares a contract, and an implementation represents one concrete
realization of that contract, responsible for faithfully carrying out the interface's complete
semantics. In the UML, you can model both interfaces and their implementations, as shown in
Figure
In this figure, there is one component named spellingwizard.dll that implements two
interfaces, IUnknown and Ispelling.
4.Extensibility Mechanisms
The UML provides a standard language for writing software blueprints, but it is not
possible for one closed language to ever be sufficient to express all possible nuances of all
models across all domains across all time. The UML's extensibility mechanisms include
1. Stereotypes
2. Tagged values
3. Constraints
1. Stereotypes
A stereotype extends the vocabulary of the UML, allowing you to create new kinds of
building blocks that are derived from existing ones but that are specific to your problem.For
example, if you are working in a programming language, such as Java or C++, you will often
want to model exceptions.In these languages, exceptions are just classes, You can make
exceptions first class citizens in your models, meaning that they are treated like basic building
blocks, by marking them with an appropriate stereotype, as for the class Overflow in Figure.
53
2. Tagged values
A tagged value extends the properties of a UML building block, allowing you to create
new information in that element's specification. For example, if you want to specify the version
and author of certain critical abstractions. Version and author are not primitive UML concepts.
o For example, the class EventQueue is extended by marking its version and author
explicitly.
3. Constraints
A constraint extends the semantics of a UML building block, allowing you to add new
rules or modify existing ones. For example, you might want to constrain the EventQueue class
so that all additions are done in order. As Figure shows, you can add a constraint that explicitly
marks these for the operation add.
54
If your comment is lengthy or involves something richer than plain text, consider putting your
comment in an external document and linking or embedding that document in a note attached
to your model.
As your model evolves, keep those comments that record significant decisions that cannot be
inferred from the model itself, and unless they are of historic interest discard the others.
55
For example, suppose you are using activity diagrams to model a business process involving the
flow of coaches and teams through a sporting event. In this context, it would make sense to visually
distinguish coaches and teams from one another and from the other things in this domain, such as
events and divisions.
For example, suppose you want to tie the models you create to your project's configuration
management system. Among other things, this means keeping track of the version number, current
check in/check out status, and perhaps even the creation and modification dates of each subsystem.
Because this is process-specific information, it is not a basic part of the UML, although you can add this
information as tagged values. Furthermore, this information is not just a class attribute either. A
subsystem's version number is part of its metadata, not part of the model.
Figure shows four subsystems, each of which has been extended to include its version number and
status. In the case of the Billing subsystem, one other tagged value is shown the person who has
currently checked out the subsystem.
For example, Figure models a small part of a corporate human resources system This diagram
shows that each Person may be a member of zero or more Departments and that each Department
must have at least one Person as a member. This diagram goes on to indicate that each Department
must have exactly one Person as a manager and every Person may be the manager of zero or more
Departments. All of these semantics can be expressed using simple UML. However, to assert that a
manager must also be a member of the department is something that cuts across multiple associations
and cannot be expressed using simple UML. To state this invariant, you have to write a constraint that
shows the manager as a subset of the members of the Department, connecting the two associations and
the constraint by a dependency from the subset to the superset.
Class Diagrams :
Class diagrams are the most common diagram found in modeling object- oriented
systems. A class diagram shows a set of classes, interfaces, and collaborations and their
relationships. You use class diagrams to model the static design view of a system.
Common Properties
57
A class diagram is just a special kind of diagram and shares the same common properties
as do all other diagrams, a name and graphical content that are a projection into a model. What
distinguishes a class diagram from all other kinds of diagrams is its particular content.
Contents
• Classes
• Interfaces
• Collaborations
• Dependency, generalization, and association relationships .
Like all other diagrams, class diagrams may contain notes and constraints. Class
diagrams may also contain packages or subsystems.
Note
Component diagrams and deployment diagrams are similar to class diagrams, except
that instead of containing classes, they contain components and nodes, respectively.
Common Uses
You use class diagrams to model the static design view of a system. This view primarily
supports the functional requirements of a system• the services the system should provide to its
end users. When you model the static design view of a system, you'll typically use class
diagrams in one of three ways.
A collaboration is a society of classes, interfaces, and other elements that work together
to provide some cooperative behavior that's bigger than the sum of all the elements. For
example, when you're modeling the semantics of a transaction in a distributed system, you
can't just stare at a single class to understand what's going on. Rather, these semantics are
carried out by a set of classes that work together. You use class diagrams to visualize and
specify this set of classes and their relationships.
Think of a schema as the blueprint for the conceptual design of a database. In many
domains, you'll want to store persistent information in a relational database or in an object-
oriented database. You can model schemas for these databases using class diagrams.
58
Common Modeling Techniques of class diagrams:
1.Modeling Simple Collaborations
To model a collaboration,
Identify the mechanism you'd like to model. A mechanism represents some function or behavior
of the part of the system you are modeling that results from the interaction of a society of
classes, interfaces, and other things.
• For each mechanism, identify the classes, interfaces, and other collaborations that
participate in this collaboration. Identify the relationships among these things, as well.
• Use scenarios to walk through these things. Along the way, you'll discover parts of your
model that were missing and parts that were just plain semantically wrong.
• Be sure to populate these elements with their contents. For classes, start with getting a
good balance of responsibilities. Then, over time, turn these into concrete attributes
and operations.
For example, Figure shows a set of classes drawn from the implementation of an
autonomous robot. The figure focuses on the classes involved in the mechanism for moving the
robot along a path. You'll find one abstract class (Motor) with two concrete children,
SteeringMotor and MainMotor. Both of these classes inherit the five operations of their parent,
Motor. The two classes are, in turn, shown as parts of another class, Driver. The class PathAgent
has a one-to-one association to Driver and a one-to-many association to CollisionSensor. No
attributes or operations are shown for PathAgent, although its responsibilities are given.
To model a schema,
59
Identify those classes in your model whose state must transcend the lifetime of their
applications.
Create a class diagram that contains these classes and mark them as persistent (a standard
tagged value). You can define your own set of tagged values to address database-specific
details.
Expand the structural details of these classes. In general, this means specifying the details of
their attributes and focusing on the associations and their cardinalities that structure these
classes.
Watch for common patterns that complicate physical database design, such as cyclic
associations, one-to-one associations, and n-ary associations. Where necessary, create
intermediate abstractions to simplify your logical structure.
Consider also the behavior of these classes by expanding operations that are important for
data access and data integrity. In general, to provide a better separation of concerns,
business rules concerned with the manipulation of sets of these objects should be
encapsulated in a layer above these persistent classes.
Where possible, use tools to help you transform your logical design into a physical design.
Figure shows a set of classes drawn from an information system for a school. This figure
expands upon an earlier class diagram, and you'll see the details of these classes revealed to a
level sufficient to construct a physical database. Starting at the bottom-left of this diagram, you
will find the classes named Student, Course, and Instructor. There's an association between
60
Student and Course, specifying that students attend courses. Furthermore, every student may
attend any number of courses and every course may have any number of students.
All of these classes are marked as persistent, indicating that their instances are intended
to live in a database or some other form of persistent store. This diagram also exposes the
attributes of all six of these classes. Notice that all the attributes are primitive types. When you
are modeling a schema, you'll generally want to model the relationship to any nonprimitive
types using an explicit aggregation rather than an attribute.
Identify the rules for mapping to your implementation language or languages of choice. This
is something you'll want to do for your project or your organization as a whole.
Depending on the semantics of the languages you choose, you may have to constrain your
use of certain UML features. For example, the UML permits you to model multiple
inheritance, but Smalltalk permits only single inheritance. You can either choose to prohibit
developers from modeling with multiple inheritance (which makes your models language-
dependent) or develop idioms that transform these richer features into the implementation
language (which makes the mapping more complex).
Use tagged values to specify your target language. You can do this at the level of individual
classes if you need precise control. You can also do so at a higher level, such as with
collaborations or packages.
Use tools to forward engineer your models.
EventHandler successor;
private Integer currentEventID;
private String source;
EventHandler() {}
public void handleRequest() {}
}
• Identify the rules for mapping from your implementation language or languages of
choice. This is something you'll want to do for your project or your organization as a
whole.
• Using a tool, point to the code you'd like to reverse engineer. Use your tool to generate
a new model or modify an existing one that was previously forward engineered.
• Using your tool, create a class diagram by querying the model. For example, you might
start with one or more classes, then expand the diagram by following specific
relationships or other neighboring classes. Expose or hide details of the contents of this
class diagram as necessary to communicate your intent.
Object Diagrams:
Terms and Concepts
An object diagram is a diagram that shows a set of objects and their relationships at a
point in time. Graphically, an object diagram is a collection of vertices and arcs.
Common Properties
An object diagram is a special kind of diagram and shares the same common properties
as all other diagrams, that is, a name and graphical contents that are a projection into a model.
What distinguishes an object diagram from all other kinds of diagrams is its particular content.
62
Contents
• Objects
• Links
Like all other diagrams, object diagrams may contain notes and constraints.
Object diagrams may also contain packages or subsystems
Common Uses
You use object diagrams to model the static design view or static process view of a
system just as you do with class diagrams, but from the perspective of real or prototypical
instances. This view primarily supports the functional requirements of a system• that is, the
services the system should provide to its end users. Object diagrams let you model static data
structures.
When you model the static design view or static process view of a system, you typically
use object diagrams in one way:
• Identify the mechanism you'd like to model. A mechanism represents some function or
behavior of the part of the system you are modeling that results from the interaction of
a society of classes, interfaces, and other things.
• For each mechanism, identify the classes, interfaces, and other elements that
participate in this collaboration; identify the relationships among these things, as well.
• Consider one scenario that walks through this mechanism. Freeze that scenario at a
moment in time, and render each object that participates in the mechanism.
• Expose the state and attribute values of each such object, as necessary, to understand
the scenario.
• Similarly, expose the links among these objects, representing instances of associations
among them.
63
For example, Figure shows a set of objects drawn from the implementation of an
autonomous robot. This figure focuses on some of the objects involved in the mechanism used
by the robot to calculate a model of the world in which it moves. There are many more objects
involved in a running system, but this diagram focuses on only those abstractions that are
directly involved in creating this world view.
As this figure indicates, one object represents the robot itself (r, an instance of Robot),
and r is currently in the state marked moving. This object has a link to w, an instance of World,
which represents an abstraction of the robot's world model. This object has a link to a
multiobject that consists of instances of Element, which represent entities that the robot has
identified but not yet assigned in its world view. These elements are marked as part of the
robot's global state.
At this moment in time, w is linked to two instances of Area. One of them (a2) is shown
with its own links to three Wall and one Door object. Each of these walls is marked with its
current width, and each is shown linked to its neighboring walls. As this object diagram
suggests, the robot has recognized this enclosed area, which has walls on three sides and a
door on the fourth.
• Chose the target you want to reverse engineer. Typically, you'll set your context inside
an operation or relative to an instance of one particular class.
• Using a tool or simply walking through a scenario, stop execution at a certain moment in
time.
• Identify the set of interesting objects that collaborate in that context and render them in
an object diagram.
• As necessary to understand their semantics, expose these object's states.
• As necessary to understand their semantics, identify the links that exist among these
objects.
If your diagram ends up overly complicated, prune it by eliminating objects that are not
germane to the questions about the scenario you need answered. If your diagram is too
simplistic, expand the neighbors of certain interesting objects and expose each object's state
more deeply.
Short Questions
1. What does Unified mean?
2. List the scope of UML.
3. List the types of relationships.
4. Give graphical representation diagram for dependencies, associations, generalizations and
realizations.
5. Write about Association.
6. Differentiate static models and dynamic models.
7. Write about importance of Public, Private and Protected in class.
8. What is an interface?
9. What is the need for modeling?
10. Compare different class diagrams.
Essay Questions
1. Explain the modeling of system’s architecture with diagram.
(or)
Demonstrate the working of UML architecture with neat diagram.
(or)
65
Describe about five interlocking views involved in the architecture of a software-intensive
system modeling
4. What is the UML approach to software development life cycle? Briefly explain various
building blocks of UML.
5.List out the common properties of object and class diagram and demonstrate the classes and
objects in bank management system with neat sketch.
66
Unit 4 & 5
Package Diagrams
While performing object-oriented analysis and design, we need to organize the artifacts of the
development process to clearly present the analysis of the problem space and the associated design. The
benefits of organizing the OOAD artifacts include the following
Provides clarity and understanding in a complex systems development
Supports concurrent model use by multiple users
Supports version control
Provides abstraction at multiple levels—from systems to classes in a component
Provides encapsulation and containment; supports modularity
Figure again shows the HydroponicsGardeningSystem package, but with two of its contained elements
represented as packages themselves. In the representation on the left, we show the Planning and
Greenhouse packages as physically contained packages inside the HydroponicsGardening-System
package. On the right appears an alternate notation for the containment relationship.
On a visual diagram, this visibility notation is placed in front of the element name, as shown in Figure.
The GardeningPlan class has public visibility to permit other elements to access it, while the PlanAnalyst
class has private visibility.
67
Essentials: The Dependency Relationship
A dependency shows that an element is dependent on another element as it fulfills its responsibilities
within the system. Dependencies between UML elements (including packages), as shown in Figure, are
represented as a dashed arrow with an open arrowhead. The tail of the arrow is located at the element
having the dependency (client), and the arrowhead is located at the element that supports the dependency
(supplier). If multiple contained element dependencies exist between packages, these dependencies are
aggregated at the package level.
68
The package diagram is the UML 2.0 structure diagram that contains packages as the primary represented
UML element and shows dependencies between the packages.
However, the package notation can be used to show the structuring and containment of many different
model elements, such as classes, as shown earlier in Figures. It can also be used on UML diagrams that
are not structure
diagrams. We alluded to this earlier when we mentioned that a package can be used to organize use cases.
An example appears in Figure, where packages are used to group use cases of the
HydroponicsGardeningSystem to
facilitate their specification among two groups with different expertise operations and support.
Advanced Concepts: Import and Access
Import is a public package import, whereas access is a private package import. What this really means is
that in an import, other elements that have visibility into the importing package can see the imported
items. But, when a package performs an access, no other elements can see those elements that have been
added to the importing package’s namespace. These items are private; they are not visible outside the
package that performed the access.
Doing so gives us the ability to refer to the public elements of another namespace by using unqualified
names; the importing package adds the names of the imported elements to its namespace. However, if any
of the imported elements are of the same type and have the same name as an owned element, they are not
added to the importing namespace.
Figure 5–8 also shows the Planning package performing a private import of the Plans package, as
illustrated by the dependency labeled with «access». This is necessary to allow the PlanAnalyst class to
access the GardeningPlan and PlanMetrics classes with unqualified names. But, since an access
dependency is private, the Greenhouse package’s import of the Planning package doesn’t provide the
Greenhouse package elements, such as the Gardener
class, with the ability to reference GardeningPlan and PlanMetrics with unqualified names. In addition,
the elements of the Greenhouse package can’t even see the PlanAnalyst class because it has private
visibility. Looking inside the Greenhouse package, the Gardener class must use the qualified names of the
elements within the StorageTank package because its namespace does not import the package. For
example, it must use the name StorageTank::WaterTank to reference the WaterTank class. Taking this
one more step, we look at the elements within the EnvironmentalController package. They all have
private visibility. This means they are not visible outside their namespace, that is, the
EnvironmentalController package.
To summarize, an unqualified name (often called a simple name) is the name of the element without any
path information telling us how to locate it within our model. This unqualified name can be used to access
the following elements in a package:
■ Owned elements
■ Imported elements
■ Elements within outer packages
69
Component Diagrams
A component represents a reusable piece of software that provides some meaningful aggregate of
functionality. Components are a type of structured classifier whose collaborations and internal structure
can be shown on a component diagram. A component, collaborating with other components through well-
defined interfaces to provide a system’s functionality, may itself be comprised of components that
collaborate to provide its own functionality. Thus, components may be used to hierarchically decompose
a system and represent its logical architecture. This logical perspective of a component is new with UML
2.0.
A one-to-one relationship between ports and interfaces is not required; ports can be used to group
interfaces, as shown in Figure. This may be done, for example, to provide clarity in a very complex
diagram or to represent the intention of having one port through which certain types of interactions will
take place. In Figure, the ambient measurements of light and temperature are received at one port.
Similarly, the gardening plan and temperature ramp information provided by the staff of the Hydroponics
Gardening System are received at a single port.
70
called assembly connectors; they are also known as interface connectors. The interface between
Environmental Controller and CoolingController is shown with a dependency to illustrate another form of
representation.
71
In the above Figure, we show an alternate notation for the interfaces of EnvironmentalController. Here we
see the three provided interfaces listed under the heading «provided interfaces». For the CoolControl
interface specified in Figure, we have provided the associated operations. Likewise, the required
interfaces are shown under the heading «required interfaces», along with three classes listed under the
«realizations» heading.
Essentials: Component Realizations
Figure specifies that the EnvironmentalController component is realized by the classes Plan, Controller,
and SensorInput. These three classes provide all of the functionality advertised by its provided interfaces.
But, in doing so, they require the functionality specified by its required interfaces. This realization
relationship between the EnvironmentalController component and the Plan, Controller, and SensorInput
classes is shown in Figure. Here, we see a realization dependency from each of the classes to
EnvironmentalController. This same information may be represented with a containment relationship, as
shown in Figure; each of the classes is physically contained by the EnvironmentalController component.
The naming convention used for these internal classifiers is tool-specific. Also, note the associations
between the classes and the specification of multiplicity.
72
To be specific, :EnvironmentalController requires GardeningPlan, which specifies the environmental
needs (lighting, heating, and cooling) of the Hydroponics Gardening System. The needs of this required
interface are delegated to an unnamed port, to which is attached the GardeningPlan interface. In this
manner, we know that we must provide the EnvironmentalControlSystem component with a gardening
plan if we intend to use its services. We also recognize that we must provide it with AmbientLight,
AmbientTemp, and TempRamp services. The connectors of EnvironmentalControlSystem provide its
communication links to its environment, as well as the means for its parts to communicate internally.
Deployment Diagrams
During development, we use deployment diagrams to indicate the physical collection of nodes that serve
as the platform for execution of our system.
The notation for an artifact consists of a class rectangle containing the name of the artifact, the keyword
label «artifact», and an optional icon that looks like a sheet of paper with the top right-hand corner folded
over. The name of this artifact includes the extension .exe, indicating that it is an executable (i.e.,
73
software code). The HeatingController.exe artifact has a dependency relationship to the HeatingController
component, labeled with «manifest». This means that it physically implements the component, thereby
connecting the implementation to the design. An artifact may manifest more than one component.
Nodes communicate with one another, via messages and signals, through a communication path indicated
by a solid line. Communication paths are usually considered to be bidirectional, although if a particular
connection is unidirectional, an arrow may be added to show the direction. Each communication path may
include an optional keyword label, such as «http» or «TCP/IP», that provides information about the
connection. We may also specify multiplicity for each of the nodes connected via a communication path.
74
The deployment of the EnvironmentalController.exe, LightingController.exe, HeatingController.exe, and
CoolingController.exe artifacts on the ApplicationServer node is indicated by containment. Another way
to denote deployment is shown by the dependency from the GardeningPlanDeveloper.exe artifact to the
PC node labeled with «deploy». A third way to denote deployment is through textually listing the artifacts
within the node icon; this is especially useful for larger or more complex deployment diagrams. We have
three unnamed dependencies within Figure between artifacts: from the LightingController.exe,
HeatingController.exe, and CoolingController.exe artifacts to the EnvironmentalController .exe artifact.
These denote the dependencies between the components that they implement, rather than deployment
onto a node. We also have another dependency, from the EnvironmentalController.exe artifact to the
GardeningPlanDeveloper.exe artifact. This relates back to the interface on the EnvironmentalController
component, which requires a gardening plan. Here we see that the gardening plan will be developed by
PlanAnalyst using the GardeningPlanDeveloper.exe artifact, which manifests the
GardeningPlanDeveloper component. The two devices, LightMeter and Thermometer, provide the
ambient light and ambient temperature sensor readings required by the Environmental Controller.exe
artifact in support of its provision of functionality to the system. GardeningPlanDeveloper.xml
75
deployment specification, which has a dependency relationship to the GardeningPlanDeveloper.exe
artifact. This deployment specification describes deployment properties of the artifact, such as its
execution and transaction specifics.
Essentials: Actors
Actors are entities that interface with the system. They can be people or other systems. Actors, which are
external to the system they are using, are depicted as stylized stick figures. Figure shows two actors for
the Hydroponics Gardening System we discussed earlier. One way to think of actors is to consider the
roles the actors play. In the real world, people (and systems) may serve in many different roles; for
example, a person can be a salesperson, a manager, a father, an artist, and so forth.
76
An Example Use Case Specification: Let us look at an example for the use case Maintain Storage Tanks.
Use case name: Maintain Storage Tanks
Use case purpose: This use case provides the ability to maintain the fill levels of the contents of the
storage tanks. This use case allows the actor to maintain specific sets of water and nutrient tanks.
Optimistic flow:
A. Actor examines the levels of the storage tanks’ contents.
B. Actor determines that tanks need to be refilled.
C. Normal hydroponics system operation of storage tanks is suspended by the actor.
D. Actor selects tanks and sets fill levels. For each selected tank, steps E through G are performed.
E. If tank is heated, the system disables heaters.
1. Heaters reach safe temperature.
F. The system fills tank.
G. When tank is filled, if tank is heated, the system enables heaters.
1. Tank contents reach operating temperature.
H. Actor resumes normal hydroponics system operation.
Pragmatic flows: Conditions triggering alternate flow
Condition 1: There is insufficient material to fill tanks to the levels specified by the actor.
77
D1. Alert actor regarding insufficient material available to meet tank setting. Show amount of
material
available.
D2. Prompt actor to choose to end maintenance or reset fill levels.
D3. If reset chosen, perform step D.
D4. If end maintenance chosen, perform step H.
D5. Else, perform step D2.
Condition 2: . . .
Other useful information may also be added to the specification, such as preconditions (what must be true
prior to executing the use case), postconditions (what will be true after executing the use case),
limitations, assumptions, and so forth.
Overall, a use case specification should not be very long it should be only a few pages. If your
specifications are very long, you should reconsider whether your use case is doing too much. It may be
that it is actually more than one use case. Also, for practical reasons, you cannot include all possible
things that could trigger an alternate flow. Include the most important or critical alternates. Do not include
every possible error condition, such as when the operator enters data in the wrong format (let the user
interface handle that type of exception).
«include» Relationships:
The Nutritionist actor using the use case will have to see what is in the crop encyclopedia prior to
updating it. This
is why the Nutritionist can invoke the View Reports use case. The same is true for the Gardener actor
whenever invoking Maintain Storage Tanks. Neither actor should be executing the use cases blindly.
78
Therefore, the View Report use case is a common functionality that both other use cases need. This can
be depicted on the use case model via an «include» relationship, as shown in Figure. This diagram states,
for example, that the Update Crop Encyclopedia use case includes the View Reports use case. This means
that View Reports must be executed when Update Crop Encyclopedia is executed. Update Crop
Encyclopedia would not be considered complete without View Reports. Where an included use case is
executed, it is indicated in the use case specification as an inclusion point. The inclusion point specifies
where, in the flow of the including use case, the included use case is to be executed.
«extend» Relationships
While developing your use cases, you may find that certain activities might be performed as part of the
use case but are not mandatory for that use case to run.
The Dangers of «include» and «extend» Relationships
These concepts are commonly misused during use case modeling. The primary cause is that some people
are not clear about the semantic differences between «include» and «extend». Another common error we
see with these relationships is violation of basic use case principles. Included and extending use cases are
still use cases and must conform to the use case principles cited earlier; a use case represents a complete
flow of activity of what the actor wants your system to do from the actor’s point of view that provides
value to the actor. This is the most prevalent
problem we see regarding use case models, in which people break down use cases into smaller and
smaller pieces, using «include» or «extend» to tie them all together.
Activity Diagrams
Activity diagrams provide visual depictions of the flow of activities, whether in a system, business,
workflow, or other process. These diagrams focus on the activities that are performed and who (or what)
is responsible for the performance of those activities. The elements of an activity diagram are action
nodes, control nodes, and object
nodes. There are three types of control nodes: initial and final (final nodes have two varieties, activity
final and flow final), decision and merge, and fork and join.
Essentials: Actions
Actions are the elemental unit of behavior in an activity diagram. Activities can contain many actions
which are what activity diagrams depict. Figure shows an action that can be performed in our hydroponics
example.
79
Note the rake symbol inside the action notation at its bottom right-hand corner. This denotes that this
action is a callBehavior type action. So, as a practical matter, we may want to use the rake symbol only
when we have actually defined that activity to be called.
Figure depicts a simple activity diagram composed of one action, Check Tank Levels. Another type of
final node is the flow final node, which is denoted by a circle with a nested “X” symbol.
Essentials: Partitions
The elements in an activity diagram can be grouped by using partitions. The purpose of a partition is to
indicate where the responsibility lies for performing specific activities. For systems, the partitions may be
other systems or subsystems. In application modeling, the partitions may be objects in the application.
Figure shows how the various activities that comprise the Maintain Storage Tanks use case of our
Hydroponics Gardening System are partitioned to the Gardener, WaterTank, and NutrientTank.
Sequence Diagrams
81
A sequence diagram shows how objects operate with one another and in what order. It is a construct of a
message sequence chart. A sequence diagram shows object interactions arranged in time sequence.
The notation used for messages (i.e., the line type and arrowhead type) indicates the type of message
being used, as shown in Figure. A synchronous message (typically an operation call) is shown as a solid
line with a filled arrowhead. An asynchronous message has a solid line with an open arrowhead. A return
message uses a dashed line with an open arrowhead. A lost message (a message that does not reach its
destination) appears as a synchronous message that terminates at an endpoint (a black dot). A found
message (a message whose sender is not known) appears as a synchronous message that originates at an
endpoint symbol.
82
each with its own condition. When a condition is true, the behavior in that region of the frame is
performed.
83
The interaction overview diagram is typically surrounded by a frame; however, the frame is optional
when the context is clear. In Figure, we see the surrounding frame with the name sd MaintainTemperature
lifelines :EnvironmentalController, :Heater, :Cooler in the compartment in the upper left-hand corner.
sd: a tag that indicates this is an interaction diagram
MaintainTemperature: a name describing the purpose of the diagram
lifelines :EnvironmentalController, :Heater, :Cooler: an optional list of contained lifelines
This interaction overview diagram contains flow of control elements and three frames,
EvaluateTemperature, Heat, and Cool.
Essentials: Flow of Control Elements
The flow of control within an interaction overview diagram is provided by a combination of activity
diagram elements to provide for both alternate and parallel paths.
The alternate path control is provided by combinations of a decision node, where the appropriate path is
chosen, and a corresponding merge node (as appropriate) to bring the alternate paths together. This
combination appears twice in Figure. First, a decision node is used to choose a path based on whether the
temperature of the Hydroponics Gardening System is within bounds (therefore, requiring no action) or out
of bounds, which requires either heating or cooling. The interaction constraint [lower bound < =temp < =
upper bound] is used to choose the appropriate path. The second combination of a decision node and a
merge node controls whether heating or cooling is applied by using the two interaction constraints, [temp
< lowerbound] and [temp > upper bound].
Flow of control within parallel paths is provided by combinations of a fork node, to split into parallel
paths, and a corresponding join node to bring the parallel paths together. One important concern with
parallel paths is that tokens from all paths must arrive at the join node before the flow is allowed to
continue. This requires us to ensure that, wherever an interaction constraint may block flow along a path,
there is an alternate path for the token to proceed. .
84
Essentials: Interaction Diagram Elements
The interaction overview diagram contains two types of elements to provide the interaction diagram
information, either an interaction or an interaction use. The interaction is any type of interaction diagram
that provides the nested details of the interaction; these are typically sequence diagrams. They can be
anonymous or named, as in Figure, which shows the Heat and Cool interactions.
The interaction use references an interaction diagram rather than providing its details. Figure contains an
example, the EvaluateTemperature interaction use. The details of EvaluateTemperature would show how
concerns, such as the following, would be managed:
Periodicity of temperature readings
Protection of compressors by not restarting the :Cooler sooner than five minutes since shutdown
Temperature adjustments based on time of day
Temperature ranges for different crops
85
development team. WaterTank contains the Heater and Tank parts, which collaborate to provide its
functionality, that of providing appropriately heated water for the gardeners to use.
The name of a composite structure part uses the format of role name :Class Name [multiplicity], where
the role name defines the role played by a part within the composite structure. Though showing the
multiplicity is optional, we include it in Figure to make clear that WaterTank consists of one Heater and
one Tank.
86
Since the connector is unnamed, it will be realized by a temporary runtime means such as a property or an
argument. If it were named, it would be realized by an instance of an actual association, that is, a link.
Roles are labeled with a name and type in the format of role name : RoleType [multiplicity]. The role
name describes a particular classifier instance that may fulfill this role, and the role type is a constraint on
this classifier instance. We have shown the role names, role types, and multiplicity for the
TemperatureController and TemperatureRamp roles. A role defines the properties that a structured
classifier must have to participate in the collaboration.
There are various ways to control the firing of a transition. A transition that has no annotation is referred
to as a completion transition. This simply means that when the source state completes, the transition
87
automatically fires, and the target state is entered. You can see this in Figure between the Initializing state
and the Timing state. When the duration timer is initialized, it immediately begins timing.
In other cases, certain events have to occur for the transition to fire. Such events are annotated on the
transition. An event is some occurrence that may cause the state of a system to change. For example, in
the Hydroponics Gardening System, the following events play a role in the system’s behavior.
A new crop is planted.
A crop becomes ready to harvest.
The temperature in a greenhouse drops because of inclement weather.
A cooler fails.
Time passes.
Each of the first four events is likely to trigger some action, such as starting or stopping the execution of a
specific gardening plan, turning on a heater, or sounding an alarm to the gardener. In Figure, we develop
the duration timer state diagram. Here you see that the timer execution can be put into a Paused state and
timing resumed through the occurrence of pause and resume events, respectively.
88
diagram as shown in Figure. In this diagram, you can see that the timeout transition has been replaced
with a condition. This condition specifies that when the duration exceeds the maintenance time, the timer
transitions into the Sounding Alarm state, alerting us to the need for maintenance. The use of an event,
condition, and effect in combination is shown on the transition from Sounding Alarm to Timing. Here,
once the maintenance is complete, we want to clear the alarm condition and resume timing. There is a
clear event, but it is guarded by the condition that the cooler must be back online first (before timing is
resumed), shown in brackets. If the cooler is not online, the transition does not fire. If it is, the effect
occurs (the duration timer is set to zero, as shown after the slash), the transition fires, and timing begins
again. The order of evaluation in conditional state transitions is important. Given state S with transition T
on event E with condition C and effect A, the following order applies.
1. Event E occurs.
2. Condition C is evaluated.
3. If C evaluates true, then transition T is triggered, and effect A is invoked.
For example, suppose that event E occurs, and condition C evaluates true, but then the execution of the
exit action changes the world so that C no longer evaluates true. The state transition will still be triggered.
In Figure, we have nested the states Timing, Sounding Alarm, and Paused. This nesting is depicted with a
surrounding boundary known as a region. The enclosing boundary is called a composite state. Thus we
now have a
composite state named Operating that contains the nested states Timing, Sounding Alarm, and Paused.
89
For our example, when the cooler is overdue for maintenance, the duration timer sounds an alarm. Earlier,
in Figure, we showed this by having the state machine transition into the Sounding Alarm state. Let us
say that, instead of just sounding the alarm, we want the system to also capture how long the cooler
remains overdue for maintenance. We show this in Figure by replacing the Sounding Alarm state with a
composite state, Maintenance Overdue, that contains two concurrent states: Sounding Alarm and Timing
Maintenance Overdue (which captures how long the cooler has been overdue for maintenance). Thus,
when the transition into the Maintenance Overdue composite state occurs, both substates start and run
concurrently, that is, the overdue maintenance timer starts and the alarm sounds.
You must be careful to make sure that how you diagram the flow correctly represents your intent. Let us
examine this with a generic composite state, as shown in Figure. You can transition into a composite state
in various ways. For example, you can have a transition to the composite state, as shown in Figure. In this
case, the concurrent submachines would all activate and begin to operate concurrently. Each individual
sub-region would execute beginning at the default initial state (pseudostate) for that sub-region. While it
is not necessary, we recommend overtly showing the initial states in the sub-region for clarity.
Another way to move into a composite state is to use a fork. A fork vertex is actually another pseudostate
(like initial and final states) and is used to split an incoming transition into two or more outgoing
transitions. Figure shows the use of a fork in this manner. The single incoming transition may have an
event and or a guard condition on it. The multiple outgoing transitions may not. In our case, the fork splits
the flow of control, and concurrent execution within the composite state would begin with substates A, B,
and C, as these are the target substates of the multiple outgoing transitions from the fork. You can also
use a join vertex (another pseudostate) to perform a similar merging of control. Figure shows multiple
transitions from the individual concurrent sub-regions to a vertical bar, where they are merged into one
90
outgoing transition. This single outgoing transition may also have an event and a guard condition on it. In
this case, transition to state S would occur when all the joined substates (A,
D, and C) are active, the event occurs, and the condition is satisfied.
In Figure, there is no merging of control as there is when joins are used. In this case, if any one of the
transitions from substates A, D, or C fire, all the other concurrent substates will terminate. Along those
same lines, if some sub-regions do not explicitly participate in a join (see Figure), when the join transition
fires, the nonparticipating sub-regions will be forced to terminate. Conversely, if some sub-regions do not
explicitly participate in a fork, the nonparticipating sub-regions will execute starting at their initial states.
In order to keep the diagrams simple, we could simply replace the Sounding Alarm substate with a
submachine state named Operating:Recording (see Figure). This submachine state represents an entirely
separate state machine diagram that would depict all the detailed recording requirements just mentioned.
In this manner, submachines enable us to organize complex state machine diagrams into understandable
structures.
91
Timing Diagrams
Timing diagrams are a type of interaction diagram. Their purpose is to show how the states of an element
or elements change over time and how events change those states.
Essentials: Layout
The general layout of a timing diagram is reminiscent of a sequence diagram laid on its side. Timing
diagrams have one or more lifelines (which look like a horizontal partition) for each object in the
diagram. The lifeline name (i.e., the object name) is shown in the lifeline. The possible states of the object
are listed inside the lifeline. Also, a timeline shows how the object changes from one state to another.
Events that drive the state changes are shown along the timeline. The horizontal axis shows time and may
also show tick marks. For example, Figure shows a simple timing diagram for a Valve object that is
controlled to fill the WaterStorageTank object in our Hydroponics Gardening System. Valve has two
simple states: open and closed.
Essentials: Events
Events (or other stimuli such as messages) that cause state changes are shown in the lifeline near the
timeline of the object. In Figure, two events have been added, that is, TankLow and TankFull, which
cause changes in the state of the valve.
Essentials: Constraints
Constraints can be used to specify conditions or limits that restrict the change of state shown on a timing
diagram. In Figure, we show a timing diagram with both the Valve and the Heater objects represented.
This diagram shows the relationship between the state of Heater and the state of Valve. Here we see a
constraint on Heater that restricts how quickly the heater can be turned back on. The constraint indicates
that once the heater is turned off, at least three minutes must pass before the heater is turned back on.
92
Advanced Concepts: Alternate Representations
In cases where timing diagrams have many lifelines, or objects that have many states, instead of using a
timeline, we can use a more compact representation, as shown in Figure. States are shown within the
hexagons, and the state changes occur between them. Instead of the change of state being indicated as a
rise and fall of a timeline, the state changes are merely shown progressing along the horizontal axis.
Communication Diagrams
A communication diagram is a type of interaction diagram that focuses on how objects are linked and
what messages they pass as they participate in a specific interaction.
Essentials: Objects, Links, and Messages
A link may exist between two objects if and only if there is an association between their corresponding
classes. The existence of an association between two classes denotes a path of communication (i.e., a link)
between instances of the classes, whereby one object may send messages to another. Given object A with
a link L to object B, A may invoke any operation that is applicable to B’s class and accessible to A; the
reverse is true for operations invoked by B on A. We will refer to the object that invokes the operation as
the client and whichever object provides the operation as the supplier. Figure shows an example of a
communication diagram for the Hydroponics Gardening System. The intent of this diagram is to illustrate
the interaction for the execution of a common system function, namely, the determination of a predicted
net cost-to-harvest for a specific crop. As shown in Figure, we may adorn a link with one or more
messages. We indicate the direction of a message by adorning it with a directed line, pointing to the
destination object. An operation invocation is the most common kind of message (the other type would be
a signal). An operation invocation may include actual parameters that match the signature of the
operation, such as the timeToHarvest message that appears in Figure.
Essentials: Sequence Expressions
Carrying out the predicted net cost-to-harvest system function requires the collaboration of several
different objects. To show an explicit ordering of events, we prefix a sequence number (starting at 1) to a
message. This sequence expression indicates the relative ordering of messages. Messages with lower
sequence numbers are dispatched before messages with higher sequence numbers. The sequence numbers
in Figure specify the order of messages for that example. Using a nested decimal numbering scheme (e.g.,
4.1.5.2), we can show how some messages are nested within the next higher-level procedure call. Each
integer term indicates the level of nesting within the interaction. Integer terms at the same level indicate
the sequence of the messages at that level. In Figure, message 1.3 follows message 1.2, which follows
message 1.1, and all are nested calls within the timeToHarvest call activation (i.e., message 1). We see
from this diagram that the action of the scenario begins with some PlanAnalyst object invoking the
93
operation timeToHarvest() on PlanMetrics. Note that the object C is passed as an actual argument to this
operation. Subsequently, PlanMetrics calls status() on a certain unnamed GardeningPlan object; our
diagram includes a development note indicating that we must check that the given plan is in fact
executing. The GardeningPlan object in turn invokes the operation maturationTime() on the selected
GrainCrop object, asking for the time the crop is expected to mature. After this selector operation
completes, control then returns to the PlanAnalyst object, which then calls yield(), which in turn
propagates this operation to the C:GrainCrop object. Control again returns to the PlanAnalyst object,
which completes the scenario by invoking the operation netCost() on itself.
94
95