OOAD Unit-3 Notes
OOAD Unit-3 Notes
Unit-3
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.
If the amount is sufficient and the item is available then the machine would dispense the
selected item and deduct the required amount from the inserted amount and would return the
remaining change. The diagram below shows you the state diagram of the vending machine.
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.
In the UML notation, the sub machine is denoted by the state name followed by a colon and
the corresponding submachine name. Conceptually a submachine is just like the subroutines in
the programming language.
The other method to model the complex system is using nested states.
Nested States
Nested states, is a deeper alternative to expanding states. When a state has multiple sub states
then they could be nested and enclosed in a contour and could be labelled as the composite
state name. Consider an example of a nested state for a phone line.
In the figure above, you can observe that the Active state is the composite state. The states
DialTone, Dialing, BusyTone and so on all are the nested state enclosed in a composite Active
state. You are allowed to nest the states to an arbitrary length. Every nested state inside the
composite Active state when receives the event ‘onHook’, the corresponding state transits to
the Idle state.
Let us understand nested states with one more example of ‘car transmission. Observe that there
are three states inside CarTransmission state diagram i.e. reverse, neutral and forward. Among
these three states, the forward state has three nested states i.e. First, Second and Third.
At any nested state of Forward gear composite state, selecting N would transit the
corresponding state to the neutral state. Being in a neutral state, selecting F would transit you
to the Forward state.
But here by default, the First nested state in the Forward contour is the initial state and the
control is in the First state. Here the Forward is just an abstract state. You can notice that the
event Stop is shared by all the three nested state. That means if the car is in any Forward gear
the stopping event would transit the car to the First state.
In the nested state diagram, the entry and exit activities allow the state to indicate entry and
exit without worrying about before the state is active and what happens after the state get active.
Whenever a state is transiting into a nested state or transiting out of the nested state it may be
due to the execution several, entry and exit activities if the transition is occurring across several
levels of the nested state. The entry activity is transiting inside the nested state and the exit
activity is transiting outside the several states just like the subroutine calls in a programming
language.
Generalization:
Generalization is the process of extracting common characteristics from a set of classes and
abstracting them into a more general superclass or interface. It embodies the “is-a” relationship,
where a subclass is said to be a specialized version of its superclass, inheriting its attributes and
behaviors while potentially adding or modifying its own.
Use-Case Model
The Use-case model is defined as a model which is used to show how users interact with the
system in order to solve a problem. As such, the use case model defines the user's objective,
the interactions between the system and the user, and the system's behavior required to meet
these objectives.
Various model elements are contained in use-case model, such as actors, use cases, and the
association between them.
We use a use-case diagram to graphically portray a subset of the model in order to make the
communication simpler. There will regularly be a numerous use-case diagram which is related
to the given model, each demonstrating a subset of the model components related to a specific
purpose. A similar model component might be appearing on a few use-case diagrams; however,
each use-case should be consistent. If, in order to handle the use-case model, tools are used
then this consistency restriction is automated so that any variations to the component of the
model (changing the name, for instance) will be reflected automatically on each use-case
diagram, which shows that component.
Packages may include a use-case model, which is used to organize the model to simplify the
analysis, planning, navigation, communication, development and maintenance.
The use-case model acts as an integrated thread in the development of the entire system. The
use-case model is used like the main specification of the system functional requirements as the
basis for design and analysis, as the basis for user documentation, as the basis of defining test
cases, and as an input to iteration planning.
1. Actor
2. Use Case
3. Associations
Actor
Usually, actors are people involved with the system defined on the basis of their roles. An actor
can be anything such as human or another external system.
Use Case
The use case defines how actors use a system to accomplish a specific objective. The use cases
are generally introduced by the user to meet the objectives of the activities and variants
involved in the achievement of the goal.
Associations
Associations are another component of the basic model. It is used to define the associations
among actors and use cases they contribute in. This association is called communicates-
association.
If we want to draw a use case diagram in UML first, we must study the complete system
appropriately. We need to find out every function which is offered by the system. When we
find out all the system's functionalities then we convert these functionalities into a number of
use cases, and we use these use-cases in the use case diagram.
A use case means essential functionality of any working system. When we organize the use
cases, then next we need to enlist the numerous actors or things that will collaborate with the
system. These actors are used to implement the functionality of a system. Actors can be
someone or something. It can likewise be a private system's entity. The actors should be
pertinent to the functionality or a system in which the actors are interacting.
When we enlist the use cases and actors, then next, we need to find the relationship of a specific
actor with the system or a use case. An actor should find the total number of ways in order to
cooperate with the system. One actor can interact with the numerous use cases simultaneously,
or it may interact with the multiple-use cases concurrently.
We have to follow the following rules while drawing use-case for any framework:
• The use case name and actor name should be meaningful and related to the system.
• The actor's interaction with the use case should be well-described and in a
comprehensible manner.
• Use annotations wherever they are essential.
• If the actor or use case has many relationships, then display only important interactions.
System
With the help of the rectangle, we can draw the boundaries of the system, which includes use-
cases. We need to put the actors outside the system's boundaries.
Use-Case
With the help of the Ovals, we can draw the use-cases. With the verb we have to label the ovals
in order to represent the functions of the system.
Actors
Actors mean the system's users. If one system is the actor of the other system, then with the
actor stereotype, we have to tag the actor system.
Relationships
With the simple line we can represent relationships between an actor and use cases. For
relationships between use-case, we use arrows which are labeled either "extends" or "uses".
The "extends" relationship shows the alternative options under the specific use case. The "uses"
relationship shows that single use-case is required to accomplish a job
The below figure shows the working of the student management system:
The sequence diagram represents the flow of messages in the system and is also termed as an
event diagram. It helps in envisioning several dynamic scenarios. It portrays the
communication between any two lifelines as a time-ordered sequence of events, such that these
lifelines took part at the run time. In UML, the lifeline is represented by a vertical bar, whereas
the message flow is represented by a vertical dotted line that extends across the bottom of the
page. It incorporates the iterations as well as branching.
Lifeline
Actor
A role played by an entity that interacts with the subject is called as an actor. It is out of the
scope of the system. It represents the role, which involves human users and external hardware
or subjects. An actor may or may not represent a physical entity, but it purely depicts the role
of an entity. Several distinct roles can be played by an actor or vice versa.
Activation
It is represented by a thin rectangle on the lifeline. It describes that time period in which an
operation is performed by an element, such that the top and the bottom of the rectangle is
associated with the initiation and the completion time, each respectively.
Messages
The messages depict the interaction between the objects and are represented by arrows. They
are in the sequential order on the lifeline. The core of the sequence diagram is formed by
messages and lifelines.
ADVERTISEMENT
• Recursive Message: A self message sent for recursive purpose is called a recursive
message. In other words, it can be said that the recursive message is a special case of
the self message as it represents the recursive calls.
Diagram
The sequence diagram represents the flow of messages in the system and is also termed as an
event diagram. It helps in envisioning several dynamic scenarios. It portrays the
communication between any two lifelines as a time-ordered sequence of events, such that these
lifelines took part at the run time. In UML, the lifeline is represented by a vertical bar, whereas
the message flow is represented by a vertical dotted line that extends across the bottom of the
page. It incorporates the iterations as well as branching.
Lifeline
Actor
A role played by an entity that interacts with the subject is called as an actor. It is out of the
scope of the system. It represents the role, which involves human users and external hardware
or subjects. An actor may or may not represent a physical entity, but it purely depicts the role
of an entity. Several distinct roles can be played by an actor or vice versa.
Activation
It is represented by a thin rectangle on the lifeline. It describes that time period in which an
operation is performed by an element, such that the top and the bottom of the rectangle is
associated with the initiation and the completion time, each respectively.
Messages
The messages depict the interaction between the objects and are represented by arrows. They
are in the sequential order on the lifeline. The core of the sequence diagram is formed by
messages and lifelines.
ADVERTISEMENT
• Recursive Message: A self message sent for recursive purpose is called a recursive
message. In other words, it can be said that the recursive message is a special case of
the self message as it represents the recursive calls.
• Create Message: It describes a communication, particularly between the lifelines of
an interaction describing that the target (lifeline) has been instantiated.
In UML, the activity diagram is used to demonstrate the flow of control within the system
rather than the implementation. It models the concurrent and sequential activities.
The activity diagram helps in envisioning the workflow from one activity to another. It put
emphasis on the condition of flow and the order in which it occurs. The flow can be sequential,
branched, or concurrent, and to deal with such kinds of flows, the activity diagram has come
up with a fork, join, etc.
Activities
The categorization of behavior into one or more actions is termed as an activity. In other words,
it can be said that an activity is a network of nodes that are connected by edges. The edges
depict the flow of execution. It may contain action nodes, control nodes, or object nodes.
The control flow of activity is represented by control nodes and object nodes that illustrates the
objects used within an activity. The activities are initiated at the initial node and are terminated
at the final node.
Activity partition /swimlane
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. It is not necessary
to incorporate swimlane in the activity diagram. But it is used to add more transparency to the
activity diagram.
Forks
ADVERTISEMENT
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. Whenever a data is received at an inward edge, it gets copied and split crossways
various outward edges. It split a single inward flow into multiple parallel flows.
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. It is an object node that precisely
represents one input to or output from the action.
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.
An example of an activity diagram showing the business flow activity of order processing is
given below.
Here the input parameter is the Requested order, and once the order is accepted, all of the
required information is then filled, payment is also accepted, and then the order is shipped. It
permits order shipment before an invoice is sent or payment is completed.
Use-case Relationships:
In UML, a relationship is a connection between model elements. A UML relationship is a type
of model element that adds semantics to a model by defining the structure and behavior
between the model elements.
UML relationships are grouped into the following categories:
Category Function
Associations Indicate that instances of one model element are connected to instances of
another model element
Dependencies Indicate that a change to one model element can affect another model
element
Generalizations Indicate that one model element is a specialization of another model element
Realizations Indicate that one model element provides a specification that another model
element implements
You can set properties and use keywords to create variations of these relationships.
The following topics describe the relationships that you can use in use-case diagrams:
• Association relationships
In UML models, an association is a relationship between two classifiers, such as
classes or use cases, that describes the reasons for the relationship and the rules that
govern the relationship.
• Generalization relationships
In UML modeling, a generalization relationship is a relationship in which one model
element (the child) is based on another model element (the parent). Generalization
relationships are used in class, component, deployment, and use-case diagrams to
indicate that the child receives all of the attributes, operations, and relationships that
are defined in the parent.
• Include relationships
In UML modeling, an include relationship is a relationship in which one use case (the
base use case) includes the functionality of another use case (the inclusion use case).
The include relationship supports the reuse of functionality in a use-case model.
• Extend relationships
In UML modeling, you can use an extend relationship to specify that one use case
(extension) extends the behavior of another use case (base). This type of relationship
reveals details about a system or application that are typically hidden in a use case.