Unit-2 Notes Oosd
Unit-2 Notes Oosd
All the elements, relationships are used to make a complete UML diagram and the
diagram represents a system.
The visual effect of the UML diagram is the most important part of the entire
process. All the other elements are used to make it complete.
Class diagram
Object diagram
Use case diagram
Sequence diagram
Collaboration diagram
Activity diagram
Statechart diagram
Deployment diagram
Component diagram
Structural Modeling
Structural modeling captures the static features of a system. They consist of the
following −
Classes diagrams
Objects diagrams
Deployment diagrams
Package diagrams
Composite structure diagram
Component diagram
Structural model represents the framework for the system and this framework is
the place where all other components exist.
Behavioural Modelling
Behavioral model describes the interaction in the system. It represents the
interaction among the structural diagrams. Behavioral modeling shows the
dynamic nature of the system. They consist of the following −
Activity diagrams
Interaction diagrams
Use case diagrams
Architectural Modeling
Class diagram
Class diagram is a static diagram. It represents the static view of an application.
Class diagram is not only used for visualizing, describing, and documenting
different aspects of a system but also for constructing executable code of the
software application
Class diagrams are the only diagrams which can be directly mapped with object-
oriented languages and thus widely used at the time of construction.
1. Identify the function or behavior of the part of a system you would like to
model.
2. For each function or mechanism identify the classes, interfaces,
collaborations and relationships between them.
3. Use scenarios (sequence of activities) to walk through these things.
To model a schema,
1. Identify the classes whose state must be saved over the lifetime of the
application.
2. Create a class diagram and mark these classes as persistent by using tagged
values.
3. Provide the structural details for these classes like the attributes,
associations with other classes and the multiplicity.
4. Provide the behavior for these classes by listing out the operations that are
important for data access and integrity.
5. Wherever possible, use tools to convert the logical design to physical
design.
Forward and Reverse Engineering
1. Identify the rules for mapping the models to the implementation language
of your choice.
2. Depending on the semantics of the language, you may want to restrict the
information in your UML models. For example, UML supports multiple
inheritance. But some programming languages might not allow this.
3. Use tagged values to specify the target language.
4. Use tools to convert your models to code.
Object diagrams
Object diagrams allow us to model the static design view or static process view. It
involves modeling a snapshot of the system which contains objects (instances),
their state and links between objects.
An object diagram represents the static part of an interaction containing the objects
that communicate and the links between them without any messages.
Common Properties
An object diagram shares the same common properties like the rest of the
diagrams, a name which identifies the diagram and graphical content. What
distinguish an object diagram from the rest of the diagrams are its contents.
Contents
Objects
Links
Like all other diagrams, object diagrams may contain notes and constraints.
Object diagrams may also contain packages and subsystems which are used to
group the related elements in the model together. Sometimes we can also include
classes in the object diagrams. Generally, object diagrams are used to model the
object structures.
First, identify the function or behavior or part of a system you want to model as
collection of classes, interfaces and other things.
For each function or mechanism identify the classes and interfaces that collaborate and
also identify the relationships between them.
Consider a scenario (context) that walks through this mechanism and freeze at a moment
in time and identify the participating objects.
Represent the state of objects by listing out the attributes and their values.
Represent the links between objects which are instances of associations.
Forward engineering a object diagram is theoretically possible but practically of limited value as
the objects are created and destroyed dynamically at runtime, we cannot represent them
statically.
Collaboration Diagram
The collaboration diagram is used to show the relationship between the objects in a
system. Both the sequence and the collaboration diagrams represent the same
information but differently.
The collaboration diagram, which is also known as a communication diagram, is
used to portray the object's architecture in the system.
Following are the components of a component diagram that are enlisted below:
2. Actors: In the collaboration diagram, the actor plays the main role as it
invokes the interaction. Each actor has its respective role and name.
3. Links: It portrays a relationship between the objects through which the
messages are sent. It is represented by a solid line.
4. Messages: It is a communication between objects which carries information
and includes a sequence number, so that the activity may take place. It is
represented by a labeled arrow, which is placed near a link. The messages
are sent from the sender to the receiver.
Messages
Messages in collaboration diagrams are shown as arrows pointing from the Client
object to the Supplier object. Typically, messages represent a client invoking an
operation on a supplier object.
Message icons have one or more messages associated with them. Messages are
composed of message text prefixed by a sequence number. This sequence number
indicates the time-ordering of the message.
1. Enter Borrower ID
1.1 CalcAmtCanBorrow
1.1.1 <<create>>
1.1.2 CalcBorrowerFines
1.1.3 GetBorrowersCheckedOutMedia
Advertisement
1.1.4 IsMediaOverdue
You can indicate that a message is nested under a parent message by adding a
decimal point and incremental digits to the parent's sequence number.
For example, the "CalcAmtCanBorrow" message is the first nested message under
"Enter Borrower ID" and is given the sequence number 1.1. The second nested
message under "Enter Borrower ID" is "Display Invalid User Msg," so it's given a
sequence number of 1.2. As you can see, there are several messages nested under
"CalcAmtCanBorrow" and these are numbered 1.1.1 through 1.1.5.
To indicate that a message is run conditionally, you can prefix the message
sequence number with a conditional clause such as [ x = true ]. This indicates that
the message is sent only if the condition is met.
Sequence Diagram
What is a Sequence Diagram?
Sequence diagrams describe interactions among classes in terms of an exchange of
messages over time. They're also called event diagrams.
These can help to predict how a system will behave and to discover responsibilities a
class may need to have in the process of modeling a new system.
Messages
Messages are arrows that represent communication between objects. Use half-arrowed
lines to represent asynchronous messages.
Asynchronous messages are sent from an object that will not wait for a response from
the receiver before continuing its tasks.
Lifelines
Lifelines are vertical dashed lines that indicate the object's presence over time.
.
Loops
A repetition or loop within a sequence diagram is depicted as a rectangle. Place the
condition for exiting the loop at the bottom left corner in square brackets [ ].
Types of Messages in Sequence Diagrams
Synchronous Message
A synchronous message requires a response before the interaction can continue. It's
usually drawn using a line with a solid arrowhead pointing from one object to another.
Asynchronous Message
Asynchronous messages don't need a reply for interaction to continue. Like synchronous
messages, they are drawn with an arrow connecting two lifelines; however, the
arrowhead is usually open and there's no return message depicted.
Self Message
A message an object sends to itself, usually shown as a U shaped arrow pointing back to
itself.
Create Message
This is a message that creates a new object. Similar to a return message, it's depicted
with a dashed line and an open arrowhead that points to the rectangle representing the
object created.
Delete Message
This is a message that destroys an object. It can be shown by an arrow with an x at the
end.
Found Message
A message sent from an unknown recipient, shown by an arrow from an endpoint to a
lifeline.
Lost Message
A message sent to an unknown recipient. It's shown by an arrow going from a lifeline to
an endpoint, a filled circle or an x.
Broadcast messages are messages that are sent by a single object but
received by more than one. Broadcast messages imply concurrency
(otherwise multiple messages would have to be sent).
A->B: Hello
A->C:Hello
The problem is that the line is in two lines. I would like to have one line with many arrows
on each or some participants.
and
Flow of Control
In a sequential system, there is a single flow of control. i.e, one thing, and one
thing only, can take place at a time.
In a concurrent system, there is multiple simultaneous flow of control i.e, more
than one thing can take place at a time.
Package Diagram
Package diagram, a kind of structural diagram, shows the arrangement and
organization of model elements in middle to large scale project. Package diagram
can show both structure and dependencies between sub-systems or modules,
showing different views of a system, for example, as multi-layered (aka multi-
tiered) application - multi-layered application model.
Package diagrams are used to structure high level system elements. Packages are
used for organizing large system which contains diagrams, documents and other
key deliverables.
Package Diagram can be used to simplify complex class diagrams, it can
group classes into packages.
A package is a collection of logically related UML elements.
Packages are depicted as file folders and can be used on any of the UML
diagrams.
Basic Concepts of Package Diagram
Package diagram follows hierarchal structure of nested packages. Atomic module
for nested package are usually class diagrams.
There are few constraints while using package diagrams, they are as follows.
Package name should not be the same for a system, however classes inside
different packages could have the same name.
Packages can include whole diagrams, name of components alone or no
components at all.
Fully qualified name of a package has the following syntax.
Packages can be represented by the notations with some examples shown below:
It depicts the high-level functionality of a system and also tells how the user handles a
system.
It represents how an entity from the external environment can interact with a part of
the system.
Following are the purposes of a use case diagram given below:
The activity diagram helps in envisioning the workflow from one activity to
another.
Activities
it can be said that an activity is a network of nodes that are connected by edges.
The edges depict the flow of execution
The swimlane is used to cluster all the related activities in one column or one row.
It can be either vertical or horizontal. It used to add modularity to the activity
diagram.
Forks
Forks and join nodes generate the concurrent flow inside the activity. A fork node
consists of one inward edge and several outward edges. It is the same as that of
various decision parameters.
Join Nodes
Join nodes are the opposite of fork nodes. A Logical AND operation is performed
on all of the inward edges as it synchronizes the flow of input across one single
output (outward) edge.
Pins
It is a small rectangle, which is attached to the action rectangle. It clears out all the
messy and complicated thing to manage the execution flow of activities
Initial State: It depicts the initial stage or beginning of the set of actions.
Final State: It is the stage where all the control flows and object flows end.
Decision Box: It makes sure that the control flow or object flow will follow only
one path.
It is the same as that of a flowchart but not exactly a flowchart itself. It is used to
depict the flow between several activities.
Following are the types of a state machine diagram that are given below:
1. Behavioral state machine
The behavioral state machine diagram records the behavior of an object
within the system.
2. Protocol state machine
It captures the behavior of the protocol. The protocol state machine depicts
the change in the state of the protocol and parallel changes within the system.
Types of State
The UML consist of three states:
4.
Types of Events
Events may be external or internal. Events passed between the system and its
actors are external events. For example, in an ATM system, pushing a button or
inserting a card are external events.
Internal events are those that are passed among objects living inside the system.
For example, a overflow exception generated by an object is an internal event.
Signals
A signal is a named object that is sent asynchronously by one object and then
received by another. Exceptions are the famous examples for signals.
A signal may be sent as the action of a state in a state machine or as a message in
an interaction. The execution of an operation can also send signals.
The timing diagram describes how an object underwent a change from one form to
another. A waveform portrays the flow among the software programs at several
instances of time.
1. It emphasizes at that particular time when the message has been sent among
objects.
2. It explains the time processing of an object in detail.
3. It is employed with distributed and embedded systems.
4. It depicts a graphical representation of states of a lifeline per unit time.
Lifeline
As the name suggests, the lifeline portrays an individual element in the interaction.
It represents a single entity, which is a part of the interaction.
Interaction Diagram
From the term Interaction, it is clear that the diagram is used to describe some type
of interactions among the different elements in the model. This interaction is a part
of dynamic behavior of the system.
Architectural Modeling
Architectural model represents the overall framework of the system. It contains both
structural and behavioral elements of the system. Architectural model can be defined
as the blueprint of the entire system. Package diagram comes under architectural
modeling.
A single component diagram cannot represent the entire system but a collection of
diagrams is used to represent the whole.
The purpose of the component diagram can be summarized as −
Visualize the components of a system.
Construct executables by using forward and reverse engineering.
Describe the organization and relationships of the components.
Before drawing a component diagram, the following artifacts are to be identified clearl y
−
Files used in the system.
Libraries and other artifacts relevant to the application.
Relationships among the artifacts.
Following is a component diagram for order management system. Here, the artifacts
are files. The diagram shows the files in the application and their relationships. In
actual, the component diagram also contains dlls, libraries, folders, etc.
Deployment Diagrams
Deployment diagrams are used to visualize the topology of the physical components of
a system, where the software components are deployed.
_if a caller sends a synchronous message, it must wait until the message is done, such as invoking a
subroutine. If a caller sends an asynchronous message, it can continue processing and doesn’t have to wait
for a response. You see asynchronous calls in multithreaded applications and in message-oriented
middleware. Asynchrony gives better responsiveness and reduces the temporal coupling but is harder to
debug.