Chapter Four
Chapter Four
Dependency
4. Port
A port (definition) indicates that the component itself does not
provide the required interfaces (e.g., required or provided).
Instead, the component delegates the interface(s) to an internal
class.
ORDER MANAGEMENT SYSTEM
EXAMPLE
COLLABORATION DIAGRAM
Collaboration diagrams (known as Communication Diagram
in UML 2.x) are used to show how objects interact to perform the
behavior of a particular use case, or a part of a use case.
OR it shows interactions between objects and/or parts (represented
as lifelines) using sequenced messages in a free-form arrangement.
Along with sequence diagrams, collaboration are used by
designers to define and clarify the roles of the objects that perform
a particular flow of events of a use case.
They are the primary source of information used to determining
class responsibilities and interfaces.
COMMUNICATION DIAGRAM VS.
SEQUENCE DIAGRAM
The communication diagram and the sequence diagram are
semantically equivalent, that is, they present the same information,
and you can turn a communication to a sequence diagram and vice
versa.
The main distinction between them is that the communication
diagram arranged elements according to space, the sequence
diagram is according to time.
NOTATIONS
Frame
Communication diagrams could be shown within a
rectangular frame with the name in a compartment in the upper
left corner.
There is no specific long form name for communication diagrams
heading types. The long form name interaction (used
for interaction diagrams in general) could be used.
There is also no specific short form name for communication
diagrams. Short form name sd (which is used for interaction
diagrams in general) could be used.
This sd is bit confusing as it looks like abbreviation of sequence diagram.
LIFELINE
Lifeline is a specialization of named element which represents
an individual participant in the interaction.
While parts and structural features may have multiplicity greater than
1, lifelines represent only one interacting entity.
If the referenced connectable element is multi-valued (i.e, has a
multiplicity > 1), then the lifeline may have an expression (selector) that
specifies which particular part is represented by this lifeline.
If the selector is omitted, this means that an arbitrary
representative of the multi-valued connectable element is chosen.
A Lifeline is shown as a rectangle (corresponding to the "head" in
sequence diagrams).
Lifeline in sequence diagrams does have "tail" representing the line of
life whereas "lifeline" in communication diagram has no line, just
"head".
Information identifying the lifeline is displayed inside the
rectangle in the following format:
MESSAGE
Message in communication diagram is shown as a line
with sequence expression and arrow above the line.
The arrow indicates direction of the communication.
SEQUENCE EXPRESSION
The sequence expression is a dot separated list of sequence
terms followed by a colon (":") and message name after that:
sequence-expression ::= sequence-term '.' . . . ':' message-
name
For example,
3b.2.2:m5
contains sequence expression 3b.2.2 and message name m5.
The integer represents the sequential order of the message
within the next higher level of procedural calling (activation).
Messages that differ in one integer term are sequential at that
level of nesting.
For example,
message with sequence 2 follows message with sequence 1,
2.1 follows 2
5.3 follows 5.2 within activation 5
1.2.4 follows message 1.2.3 within activation 1.2.
The name represents a concurrent thread of control. Messages
that differ in the final name are concurrent at that level of nesting.
For example,
messages 2.3a and 2.3b are concurrent within activation 2.3,
1.1 follows 1a and 1b,
3a.2.1 and 3b.2.1 follow 3.2.
A guard specifies condition for the message to be sent
(executed) at the given nesting depth. UML does not specify guard
syntax, so it could be expressed in pseudocode, some
programming language, or something else.
For example,
2.3b [x>y]: draw() - message draw() will be executed if x is greater than y,
1.1.1 [s1.equals(s2)]: remove() - message remove() will be executed if s1
equals s2.
An iteration specifies a sequence of messages at the given
nesting depth.
UML does not specify iteration-clause syntax, so it could be
expressed in pseudocode, some programming language, or
something else.
Iteration clause may be omitted, in which case the iteration
conditions are unspecified.
The * iteration notation specifies that the messages in the
iteration will be executed sequentially.
The *|| (star followed by a double vertical line) iteration notation
specifies concurrent (parallel) execution of messages.
For example,
4.2c *[i=1..12]: search(t[i]) - search() will be executed 12 times, one after
another
4.2c *||[i=1..12]: search(t[i]) - 12 search() messages will be sent
concurrently,
2.2 *: notify() - message notify() will be repeated some unspecified
number of times.
EXAMPLE – ONLINE BOOKSHOP
EXAMPLE - HOTEL
RESERVATION
ACTIVITY DIAGRAM
Activity Diagrams and advanced flowchart to illustrate the flow
of control in a system and refer to the steps involved in the
execution of a use case.
We model sequential and concurrent activities using activity
diagrams.
So, we basically depict workflows visually using an activity
diagram.
An activity diagram focuses on condition of flow and the
sequence in which it happens.
NOTATIONS
Initial State – The starting state before an activity takes place is
depicted using the initial state.
A process can have only one initial state unless we are depicting
nested activities.
We use a black filled circle to depict the initial state of a system.
Action or Activity State – An activity represents execution of an
action on objects or by objects.
We represent an activity using a rectangle with rounded corners.
Basically any action or event that takes place is represented
using an activity.
Action Flow or Control flows – Action flows or Control flows
are also referred to as paths and edges.
They are used to show the transition from one activity state to
another.
An activity state can have multiple incoming and outgoing action
flows.
We use a line with an arrow head to depict a Control Flow.
If there is a constraint to be adhered to while making the
transition it is mentioned on the arrow
Decision node and Branching – When we need to make a decision
before deciding the flow of control, we use the decision node.
The outgoing arrows from the decision node can be labeled with
conditions or guard expressions.
It always includes two or more output arrows.
Guards – A Guard refers to a statement written next to a
decision node on an arrow sometimes within square brackets.
Packages are depicted as file folders and can be used on any of the UML
diagrams.
Packages appear as rectangles with small tabs at the top.
The package name is on the tab or inside the rectangle.
The dotted arrows are dependencies.
One package depends on another if changes in the other could
possibly force changes in the first.
Package Diagram Example - Import
<<import>> - one package imports the functionality of other
package