Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
35 views

Unit 3 Model Development Using Unified Modelling Language (UML)

The document provides an overview of object-oriented concepts and the Unified Modeling Language (UML). It discusses the four main aspects of object-oriented approach - identity, classification, inheritance, and polymorphism. It then describes UML and its main diagram types for static and dynamic modeling - class diagrams, object diagrams, component diagrams, use case diagrams, sequence diagrams, activity diagrams, and state chart diagrams. The last part of the document focuses on static modeling using class diagrams and provides examples of class diagram notations.

Uploaded by

Ravi Raval
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Unit 3 Model Development Using Unified Modelling Language (UML)

The document provides an overview of object-oriented concepts and the Unified Modeling Language (UML). It discusses the four main aspects of object-oriented approach - identity, classification, inheritance, and polymorphism. It then describes UML and its main diagram types for static and dynamic modeling - class diagrams, object diagrams, component diagrams, use case diagrams, sequence diagrams, activity diagrams, and state chart diagrams. The last part of the document focuses on static modeling using class diagrams and provides examples of class diagram notations.

Uploaded by

Ravi Raval
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 53

GANPAT UNIVERSITY

U. V. PATEL COLLEGE OF ENGINEERING

2CEIT406
SOFTWARE ENGINEERING &
PROJECT MANAGEMENT
UNIT 3
MODEL DEVELOPMENT USING UNIFIED MODELING
LANGUAGE (UML)

Prepared by: Prof. Ravi Raval (Asst. Prof in C.E Dept. , UVPCE)
Unit 3: Model Development using UML
Component diagrams
Contents: 
 Dynamic Modelling
 Overview of object oriented  Use Case Diagram
concepts
 Sequence
 Advantage of OOD
 Activity Diagram
 Unified modelling language(UML)  State chart Diagram
 Static Modelling:
 Exercises and case studies
 Class
 Object
 Package
Overview of object oriented concepts
 What is Object-Orientation? 1) Identity
 It means that we organize software as a collection  It means that data is quantized into
of discrete objects that incorporate both data discrete, distinguishable entities called
structure and behavior objects
Object = Data structure + Behavior
 Ex. White queen in chess
 Object can be concrete, such as a file in
(attributes)
a file system, or conceptual, such as a
(operations)
scheduling policy in a
 Four aspects of OO approach (characteristics) : multiprogramming operating system
1) Identity  Each object has its own inherent identity
2) Classification  Two objects are different even if the
3) Inheritance attribute values are same
4) polymorphism
Overview of object oriented
concepts
2) Classification 3) Inheritance
 Objects with same data structure and  It is the sharing of attributes and
behavior are grouped together into a operations among classes based on a
class hierarchical relationship
 A class is an abstraction that describes  A super class has general information
a properties important to an that subclass refine and elaborate
application and ignores the rest  Each subclass inherits all features of its
 Any choice of classes is arbitrary and super class and adds its own unique
depends on the application features
 Subclasses need not to repeat the
 Each class describes infinite set of
features of the super class
individual objects
 Ex. Scrolling window and Fixed window
 Object is said to be instance of its
are subclasses of Window class
class
Overview of object oriented
concepts
4) Polymorphism
 The same operation behave
differently for different classes
 Ex. Move operation for a pawn
and the queen in a chess game
 An operation is a procedure or
transformation that an object
performs
 An implementation of the
operation by a specific class is
called a method
Advantage of OOD
 Faster Development
 Reuse of Previous work
 Increased Quality
 Modular Architecture
 Client/Server Applications
 Better Mapping to the Problem Domain
Unified modelling language(UML)
 Why to use UML for modeling?
What is UML?  Use graphical notation to
 UML stands for “Unified Modeling
communicate more clearly than natural
Language” language (imprecise) and code(too
 It is a industry-standard graphical detailed).
language for specifying, visualizing,  Help acquire an overall view of a
constructing, and documenting the system.
artifacts of software systems  UML is not dependent on any one
 The UML uses mostly graphical notations language or technology.
to express the OO analysis and design of
software projects.
 Simplifies the complex process of
software design
UML diagrams
UML diagrams
 Structure diagrams show the static structure of the  Behavior diagrams show the dynamic
system and its parts on different abstraction and behavior of the objects in a system, which
implementation levels and how they are related to can be described as a series of changes to
each other. The elements in a structure diagram the system over time, there are seven types
represent the meaningful concepts of a system, and of behavior diagrams as follows:
may include abstract, real world and  Use Case Diagram
implementation concepts, there are seven types of  Activity Diagram
structure diagram as follows:  State Machine Diagram
 Class Diagram  Sequence Diagram
 Component Diagram  Communication Diagram
 Deployment Diagram  Interaction Overview Diagram
 Object Diagram  Timing Diagram
 Package Diagram
 Composite Structure Diagram
 Profile Diagram
Static modelling: Class Diagram
 The UML Class diagram is a graphical  Class diagram is a static diagram. It
notation used to construct and visualize represents the static view of an
object oriented systems. A class application.
diagram in the Unified Modeling
Language (UML) is a type of static Purpose of Class Diagrams
structure diagram that describes the  Analysis and design of the static
structure of a system by showing the view of an application.
system's:  Describe responsibilities of a system.
 classes,
 their attributes,
 Base for component and deployment
diagrams.
 operations (or methods),
 and the relationships among objects.
 Forward and reverse engineering.
Class Diagram
 UML Representation of Class

Class Name

Attributes of Class

Operations/methods of
Class
Class Diagram
Visibility of Attributes and Operations  Class Visibility Example
In object-oriented design, there is a notation
of visibility for attributes and operations.
UML identifies four types of
visibility: public, protected, private,
and package.
protected
 The +, -, # and ~ symbols before an attribute Access Right public (+) private (-)
(#)
Package (~)

and operation name in a class denote the Members of


visibility of the attribute and operation. the same yes yes yes yes
class
 + denotes public attributes or operations Members of
derived yes no yes yes
 - denotes private attributes or operations classes
 # denotes protected attributes or operations Members of
in same
any other yes no no
package
 ~ denotes package attributes or operations class
Class Diagram
Relationships among Classes
 Represents a connection between
multiple classes or a class and itself
 basic categories:
 association relationships
 generalization relationships
 aggregation relationships
 Composition relationships
Class Diagram
Multiplicity
How many objects of each class take part in
the relationships and multiplicity can be
expressed as:
 Exactly one - 1
 Zero or one - 0..1
 Many - 0..* or *
 One or more - 1..*
 Exact Number - e.g. 3..4 or 6
 Or a complex relationship - e.g. 0..1, 3..4,
6.* would mean any number of objects
other than 2 or 5
Example
Static Modelling – Object Diagram
 “instance” and “object” are largely synonymous; used interchangeably.
 difference:
 instances of a class are called objects or instances; but
 instances of other abstractions (components, nodes, use cases, and associations) are not
called objects but only instances.
What is an instance of an association called?
 Object Diagrams
 very useful in debugging process.
– walk through a scenario (e.g., according to use case flows).
– Identify the set of objects that collaborate in that scenario (e.g., from use case flows).
– Expose these object’s states, attribute values and links among these objects.
Instances & Objects - Visual Representation
anonymous instance
named instance
myCustomer

: Multimedia :: AudioStream
t : Transaction

: :keyCode
keyCode
c : Phone
agent : [WaitingForAnswer]
instance with current
multiobject orphan instance
state
(type unknown)

active object myCustomer


r : FrameRenderThread id : SSN = “432-89-1738” instance with
(with a thicker border; owns a attribute values
thread or process and can initiate active = True
control activity)
Instances & Objects - Visual Representation
Instances & Objects - Modeling Concrete Instances
 Expose the stereotypes, tagged values, and attributes.
 Show these instances and their relationships in an object diagram.
current: Transaction
<<instanceOf>>
primaryAgent
LoanOfficer
[searching]

: :Transaction
Transaction current := retrieve()
Instances & Objects - Modeling Prototypical Instances
• Show these instances and their relationships in an interaction diagram or an activity diagram.
1 : create

a: CallingAgent c: Connection
2.1 : startBilling
2: enableConnection
Instances & Objects – some more examples
list() 1: sort() c : Company
d: Directory contents:File
contents: File

s : Department rd : Department
addFile(f:File) 1: addElement(f)
d: Directory contents:File
contents: File name = “Sales” name = “R&D”

secureAll() 1*: changeMode(readOnly)


d: Directory uss : Department
f: File * name = “US Sales”
client :Server
servers :Server
manager
1: aServer := find(criteria)
erin : Person : ContactInfomation
aServer:Server name = “Erin”
2: process(request) employeeID = 4362 address = “1472 Miller St.”
call ::= label [guard] [“*”] [return-val-list “:=“] msg-name “(“ arg-list “)” title = “VP of Sales”
Package Diagrams
 Package: is a piece of a Model. Every part of the
package must be a workable, following some Ticket-ordering subsystem
rational principle, such as common functionality,
tightly coupled implementation and common
viewpoint. Packages and their
 Package — general-purpose mechanism for relationships
organizing elements into groups.
 Nested Elements: Composite relationship (When
the whole dies, its parts die as well, but not
necessarily vice versa)
 (C++ namespace; specialization means “derived”)
 Packages that are friends to another may see all the
elements of that package, no matter what their
visibility.
 If an element is visible within a package, it is Package import
visible within all packages nested inside the
Component Diagrams
 Shows a set of components and their relationships. Component Diagram – another example
(www.cs.tut.fi/tapahtumat/olio2004/richardson.pdf)

 Represents the static implementation view of a system.


 Components map to one or more classes, interfaces, or
collaborations.

Mapping of Components Components and their


into Classes Relationships
loanO component
fficer. Registrar.exe
dll
LoanOfficer CreditSearch
Student.dll Course.dll
LoanPolicy
classes
Sequence Diagrams
 A sequence diagram simply depicts  Sequence diagrams are used to capture
interaction between objects in a the order of messages flowing from one
sequential order i.e. the order in which object to another.
these interactions take place.
The purpose of interaction diagram is −
 We can also use the terms event
diagrams or event scenarios to refer to  To capture the dynamic behaviour of a
a sequence diagram. Sequence system.
diagrams describe how and in what  To describe the message flow in the
order the objects in a system function. system.
 These diagrams are widely used by
businessmen and software developers
 To describe the structural organization of
to document and understand the objects.
requirements for new and existing  To describe the interaction among
systems. objects.
Sequence Diagram Notations
 Lifelines – A lifeline is a named
element which depicts an
individual participant in a
sequence diagram. So basically
each instance in a sequence
diagram is represented by a
lifeline. Lifeline elements are
located at the top in a sequence
diagram.
Sequence Diagram Notations
 Messages– Communication
between objects is depicted
using messages. The messages
appear in a sequential order on
the lifeline. We represent
messages using arrows.
Lifelines and messages form
the core of a sequence
diagram.
Sequence Diagram Notations
 Activations
 A thin rectangle on a lifeline)
represents the period during
which an element is
performing an operation.
 The top and the bottom of the
of the rectangle are aligned
with the initiation and the
completion time respectively
Sequence Diagram Notations
 Guards – To model conditions
we use guards in UML. They are
used when we need to restrict
the flow of messages on the
pretext of a condition being met.
Guards play an important role in
letting software developers
know the constraints attached to
a system or a particular process.
Sequence Diagram Notations
Combined Fragment 2) Options
1) Alternatives The interaction operator opt means that
the combined fragment represents
The interaction operator alt means that a choice of behavior where either the
the combined fragment represents (sole) operand happens or nothing
a choice or alternatives of behavior. happens.
Sequence Diagram Notations
3) Loop
The interaction operator loop means that
the combined fragment represents a loop.
The loop operand will be repeated a
number of times.
Example :Sequence Diagram for Patient Admit / Registration
Activity Diagram
 Activity diagrams and use  A diagram that emphasizes the
cases are logical model which flow of control from activity to
describe the business domain’s activity in an object.
activities without suggesting  Similar to the traditional program
how they are conduct. flowchart.
 Shows the sequence of steps  Used to provide detail for complex
that make up a complex algorithms.
process.  Primary activities and the
relationships among the activities
 Shows flow of control,
in a process.
similarly sequence diagram but
focus on operations.
Activity Diagram
Purpose  Activity Diagram Notations
 To model a task (for example in business
modelling) Initial Node
 To describe a function of a system
represented by a use case
 To describe the logic of an operation  This represents the start of the flow of an
 To model the activities that make up the life activity diagram.
cycle in the Unified Process
 An activity diagram contains a single
 Draw the activity flow of a system.
 Describe the sequence from one activity to start node.
another.  The name of the initial node is entered on
 Describe the parallel, branched and the node. It takes the form of an
concurrent flow of the system. adjective.
Activity Diagram Notations
Control Flow • A control flow has direction, which is
indicated by the arrow head – you
• A control flow connects any may only traverse the control flow in
combination of: the direction of the arrow.
– activities • A control flow may not enter an initial
state.
– branches
• A control flow may not exit a final
– merges node.
– forks
• A control flow is the representation of
an occurrence of an event.
– joins
Activity Diagram Notations
Activity or Action Decision node and Branching
An activity represents execution of When we need to make a decision
an action on objects or by objects. before deciding the flow of control,
We represent an activity using a we use the decision node.
rectangle with rounded corners.
Basically any action or event that
takes place is represented using an
activity.
Activity Diagram Notations
Guards Fork
A Guard refers to a statement written next • The fork may be represented by
to a decision node on an arrow sometimes vertical or horizontal bars.
within square brackets • The fork represents that the flow
through the diagram has split into 2
The statement must be true for the control paths that are running in parallel
to shift along a particular direction. (multitasking).
Guards help us know the constraints and • The fork has a single control flow
conditions which determine the flow of a on entry and several control flows
process. exiting.
Activity Diagram Notations
Join Final State
 For every fork there should be a join (if not The state which the system reaches
your activity diagram is broken).
when a particular process or activity
 The join may be represented by vertical or
ends is known as a Final State or
horizontal bars.
End State. We use a filled circle
 A join simply shows that when the parallel
activities have finished that they then come within a circle notation to represent
back to join a single flow again. the final state in a state machine
 The join has several control flows entering diagram
and a single control flow on exit.
 The exiting control flow cannot be executed
until every incoming control flow has
completed.
 There is no need to label the fork or join.
Activity Diagram Notations
START DECISION
POINT POINT

[Condition] GUAR
END POINT
D

STEP PARALLEL
STEPS

TRANSITIO FORK AND JOIN


N
Example of Activity Diagram
State Diagram/State Machine/State chart
 State model describes the sequences of operations that occur in response to external stimuli.
 The state model consists of multiple state diagrams, one for each class with temporal behavior that is
important to an application.
 The state diagram is a standard computer science concept that relates events and states.
 Events represent external stimuli and states represent values objects.
 The basic elements of state diagrams are:
 Initial state – We use a black filled circle represent the initial state of a System or a class.
 Events – An event is an occurrence at a point in time
 states – the state in which the object finds itself at any moment
 transitions – take the object from one state to another
 actions – take place as a result of a transition
 Final state – We use a filled circle within a circle notation to represent the final state in a state
machine diagram.
State chart Diagram
Events Types of Events
 An event is an occurrence at a point in  Signal event
time such as –
 Time event
User presses left button
Indigo flight departs from Mumbai
 Change event
 An event happens instantaneously with
regard to time scale of an application.
State chart Diagram
Signal Event Time Event Change Event
 A signal is an explicit one-  Time event is an event A change event occurs
way transmission of caused by the occurrence of whenever a specified condition
is met
information from one object an absolute time or the
elapse of a time interval.  Event name is specified as
to another.
keyword when
 An object sending a signal  UML notation for an  Parameter list is a Boolean
to another object may absolute time is the expression
expect a reply, but the reply keyword when followed by  when (battery power < lower limit )
is a separate signal under a parenthesized expression  when (tire pressure < minimum
the control of the second involving time. pressure )
object, which may or may  when (date = Aug 1 ,
not choose to send it. 2015 )
State chart Diagram
States  A state is when a system is:
 State is a condition or situation during the Doing something – e.g., heating oven, mixing
life of an object within which it performs ingredients, accelerating engine,
some activity, or waits for some events Waiting for something to happen – Waiting for
 The objects in a class have a finite number user to enter password, waiting for sensor
of possible states. reading
 Each object can be in one state at a time. Event vs. state
 A state specifies the response of an object to
input events.
 At any given point in time, the system is in
one state.
 It will remain in this state until an event Events represent points in time; states
Name
occurs that causes it to change
sometimes
state.left out when represent intervals of time.
state variables
empty
actions
State chart Diagram
Various
characterizations
of a state. A state
specifies the
response of an
object to input
events.
State chart Diagram
Transitions  A directed relationship between two states .
 A transition is a relationship between two  Source state - current state before
states indicating that an object in the first transition fires.
state will enter the second state.  Event trigger - external stimulus that has
 A transition is an instantaneous change the potential to cause a transition to fire.
from one state to another.  Guard condition - a condition that must
 The transition is said to fire upon the be satisfied before a transition can fire.
change from the source state to target state.  Target state - new state after transition
 A guard condition must be true in order fires.
for a transition to occur.
 A guard condition is checked only once, at
the time the event occurs, and the
transition fires if the condition is true.
State chart Diagram
 A transition is drawn with
event action
an arrow, possibly labeled
off hook / play dial tone with
Idle [ valid subscriber ] Active  event causing the transaction
 guard condition
on hook  Action to perform
guard condition

AnEvent [guard] / SomeAction


State chart Diagram
 Actions
Initial State  is an executable
Transition atomic computation

Idle Running  includes operation


calls, the creation or
destruction of
another object, or
State the sending of a
Unpaid
signal to an object
Invoice paying
Paid
Invoice
created destroying
State Diagrams notation

Initial state event final state


name

Invoice Invoice
created paying destroyed
Unpaid Paid

transition
state
Example: Here’s a simple example SD for a washing machine

State

Transition

Condition

Action
Seminar Registration
event action, taken during
transition

Setup
AddParticipant / Set count = 0 Available
do/initialize seminar
do/initialize seminar

cancel
[ count = 20 ]
seminar
cancel seminar

guard
Canceled Full
cancel seminar
do/finalize seminar
do/refund payments

aktivity, carried out


while in that state
multiple
exits
State diagram for a telephone line
State diagram for chess game
State diagram for phone line with activities
Nested State Diagrams
 You can structure states more
deeply than just replacing a state
with a submachine.

You might also like