0% found this document useful (0 votes)
8 views

Notes - 1057 - Unit II

Relationships in UML can include links, associations, generalizations, realizations, and dependencies. Associations describe relationships between classes and can be bidirectional, unary, binary, ternary, or m-ary. Generalization describes "is-a" relationships and inheritance. State modeling uses state diagrams to describe how objects change over time in response to events. A state diagram shows states and transitions between states caused by events. Nested state diagrams allow expanding states to show substates and submachines.

Uploaded by

Naveen Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Notes - 1057 - Unit II

Relationships in UML can include links, associations, generalizations, realizations, and dependencies. Associations describe relationships between classes and can be bidirectional, unary, binary, ternary, or m-ary. Generalization describes "is-a" relationships and inheritance. State modeling uses state diagrams to describe how objects change over time in response to events. A state diagram shows states and transitions between states caused by events. Nested state diagrams allow expanding states to show substates and submachines.

Uploaded by

Naveen Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 61

Relationships in UML

Relationships in UML
• Link
• Association
• Aggregation
• Composition
• Generalization
• Realization
• Dependencies
Link
• Link is a physical or conceptual connection between objects
• E.g. Ram sits on Chair. “Sits on” is a link between object Ram and
object chair.
• It is denoted by solid line
Association
• Association is a group of links which are similar in structure and
semantics. Association is between classes
• Properties of association
• Bidirectional in nature
• Unary: if association of a class is with itself
• Binary: b/w two classes
• Ternary: among three classes
• M-ary: among m classes
End names of an association
• Multiplicity
• Role names
• Link attribute/ association attribute
• Link class/ association class
• Navigation
• Ordering
• Aggregation
• Composition
Multiplicity

• When two classes are associated by an association then one instance


of a class how many instances of another class are associated with it.
•1
• 0..* means 0 or 1 or more
• 0..1 mean 0 or 1
• 2..* means at least two
Generalization Relationship
• It is a “is-a” relationship
• Generalization to specialization relationship
• inheritance
Generalization Relationship
• Types of generalization/inheritance
• Single inheritance
• Multiple inheritance
• Hierarchical inheritance
• Multilevel inheritance
• Multipath inheritance
• Hybrid inheritance
Class Diagram
What is 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 diagram describes the attributes and operations of a class and
also the constraints imposed on the system.
• Class diagram shows a collection of classes, interfaces, associations,
collaborations, and constraints. It is also known as a structural
diagram.
Essential elements of class diagram
• Class, interface, collaborations
• Relationships
• Association
• Aggregation
• Composition
• Generalization/specialization
• Dependency
• Realization
• Constraints
State Modeling
Introduction

• A state model describes the sequences of operations that occur in response to external stimuli.
• As opposed to what the operations do, what they operate on, or how they are implemented.
• Changes to objects and their relationships over time should be examined.
• A state model consists of multiple state diagrams, one for each class with temporal behavior that
is important to an application.
• A state diagram relates events and states.
• Events represent external stimuli
• States represent values of (attributes) object.
What is Event ?

• An event is an occurrence of something at a point of time. It has no duration.

• Examples:
• User depresses left button
• Flight 123 departs from Amman
• Power turned on
• Alarm set
• Paper tray becomes empty

• Events corresponds to verb in the past/present tense or the onset of some condition.
• By definition an event happens instantaneously. The time at which an event occurs is an implicit
attribute of the event.
Events…

• One event may logically precede or follow another, or the two events are unrelated. Events that
are causally unrelated are said to be concurrent.
• Examples of error events:
• Motor jammed
• Transaction aborted
• Timeout

• Three types of events.


• Signal event
• Change event
• Time event
Signal Events

• A signal is a one-way transmission of information from one object to another object.


• It is different from a function call that returns a value
• An object sending a signal to another object may expect a reply, but the reply is a separate signal
under the control to the second object, which may or may not chose to send it.
• A signal event is the event of sending or receiving a signal.
• In general we are more concerned about the receipt of a signal because it causes effects in the
receiving object.
• Difference between signal and signal event: the first one is a message between object, the second
one is an occurrence in time.
Signal Class
Signal classes and Attributes

Event can have attributes


Change Event

• A change event is an event that is caused by the satisfaction of a Boolean expression.


• The intent of a change event is that the expression is continually tested and whenever the
expression changes from false to true the event happens. (an implementation would not
continuously check a change event)
• Examples:
Time event

• A time event is an event caused by the occurrence of an absolute time or the


elapse of a time interval.
• Examples:
States

• A state is an abstraction of the values of attributes and the links of an object.


• State will have duration
• State is a position of an object between two consecutive events.
• Sets of values and links are grouped together into a state according to the gross behavior of
objects.

• Example: The state of a bank is either solvent or insolvent, depending on whether its assets
exceed its liabilities.

• States often correspond to:


• verbs with a suffix ‘ing’: waiting, dialing..
• Or the duration of some condition: powered, below freezing.
States

• Notation:

• The objects in a class have a finite number of possible states. One or possibly larger number.
• Each object can only be in one state at time. Objects may parade through one to more states in
their lifetime
• A state specifies the response of an object to input events.
• The response may include the invocation of a behavior or a change of state.
States

• Event versus State:

• Both events and states depend on the level of abstraction


Transitions and Conditions

• A transition is an instantaneous change from one state to another.


• The transition is said to fire upon the change from the source state to the target state. Usually
the origin and target states are different but may be the same.
• A transition occurs when its event fires, unless an optional guard condition causes the event to be
ignored.
• A guard condition is a Boolean expression that must be true in order for a transition to occur.
• The choice of next state depends on both the source state and the event received.
State Diagram

• A state diagram is a graph whose nodes are states and whose directed arcs are transitions
between states.

• A state diagram specifies or describes the state sequence caused by event sequences.

• State names must be unique within the scope of the state diagram.

• All objects in a class execute the state diagram for that class.

• The class state diagram models the common behavior of the class objects.
State diagram example
Activity

• An activity is behavior than can be executed in response to an event.

• An activity can be performed upon a transition, upon the entry to or exit from a
state or upon some event within a state.
Examples
Examples
Nested State Diagram

• A nested state diagram is used to model the complex system as the


regular state diagram is inadequate in describing the large and
complex problem. The nested state diagram is the concept of
advanced state modelling.
• Conventionally a complex system has much redundancy. This
redundancy can be resolved by restructuring the complex
system. One method to restructure complex system is to
expand the state that has certain sub states.
Expanding States
The complex system can be restructured by implementing
sub diagrams to a high-level diagram and this can be done
by expanding the states that have multiple sub states. This
is just like we use macros in the programming language .
Observe the state dispense may have multiple substates so it is
expanded in the lower level state diagram, which is also termed
as submachine. The term submachine is defined as a state
diagram which is triggered by another high-level state diagram.
References
1. Grady Booch, James Rumbaugh, Ivar Jacobson, The Unified Modeling
Language User Guide, Pearson Education
2. Michael Blaha, James Rumbaugh: Object-Oriented Modeling and
Design with UML, 2nd Edition, Pearson Education, 2005.
3. J. Rambaugh, M. Blaha, W. Premerlani, F. Eddy, W. Lorensen, Object-
Oriented Modeling and Design, Prentice Hall of India

4. Satzinger, Jackson, Burd, Object-Oriented Analysis & Design with the


Unified Process, Thomson.

5. Grady Booch, Object Oriented Analysis & Design, Pearson Education

You might also like