Uml
-
Upload
api-3704955 -
Category
Documents
-
view
21 -
download
5
description
Transcript of Uml
UML Unified Modeling Language
Presented By-
Shah Imran Alam
CDAC- Mumbai
Why We Model ?
What is UML ?
The UML language is for
Visualizing
Specifying
Constructing
Documenting
Three major elements of UML
Building Blocks Rules Common Mechanism
Building Blocks Of UML
Things
Relationship
Diagrams
Four Kinds Of Things In UML
Structural Things Behavioral Things Grouping Things Annotational Things
Structural Things (Nouns of UML)
Class Interface Collaboration Use Cases Active Classes Components Nodes
Structural Things (Cont…)
The nouns of UML models are usually the static
parts of the system in question.
Class - an abstraction of a set of things in the problem-domain that have similar properties and/or functionality.
Notation:
Windoworiginsize
open()close()move()display()
Structural Things (Cont…)
Notation:
Interface - A collection of operations that specify the services rendered by a class or component.
CheckSpelling
Structural Things (Cont…)
Notation:
Collaboration - a collection of UML building blocks (classes, interfaces, relationships) that work together to provide some functionality within the system.
Chain Of Responsibility
Structural Things (Cont…)
Notation:
Use Case - an abstraction of a set of functions that the system performs; a use case is “realized” by a collaboration.
Process
Order
Structural Things (Cont…)
Notation:
Active Class - a class whose instance is an active object; an active object is an object that owns a process or thread (units of execution)
eventManager
Structural Things (Cont…)
Notation:
Component - a physical part (typically manifests itself as a piece of software) of the system.
DML_Parser.C
Structural Things (Cont…)
Notation:
Node - a physical element that exists at run-time and represents a computational resource (typically, hardware resources).
PrintServer
Behavioral Things (Verbs of UML)
Interaction Static machine
Behavioral Things (contd)
Interaction
The verbs of UML models; usually the dynamicparts of the system in question.
some behaviour constituted by messages exchanged among objects; the exchange of messages is with a view to achieving some purpose.
ParseNotation:
Behavioral Things (contd)
State machine
A behavior that specifies the sequence of “states” an object goes through, during its lifetime. A “state” is a condition or situation during the lifetime of an object during which it exhibits certain characteristics and/or performs some function.
Notation:EngineIdling
Grouping Things (Packages)
The organizational part of the UML model, provides a higher level of abstraction (granularity).
A general-purpose element that comprises UML elements - structural, behavioral or even grouping things. Packages are conceptual groupings of the system and need not necessarily be implemented as cohesive software modules.
.
AccountsDepartment
Notation:
Annotational Things (Note)
The explanatory part of the UML model; addsinformation/meaning to the model elements. A graphical notation for attaching constraints and/or
comments to elements of the model.
Notation:Parses user-query and builds expression stack ( invokes ErrorHandler)
A Few Other Example
Relationships In UML
Dependency Association Generalization Realization
Relationships (contd)
Dependency
Articulates the meaning of the links between things.
A semantic relationship where a change in one thing (the independent thing) causes a change in the semantics of the other thing (the dependent thing).
(arrow-head points to the independent thing)Notation:
Relationships (contd)
Association
A structural relationship that describes the connection between two things.
Notation:
Associational (usage) relationships1. multiplicity (how many are used)
* 0, 1, or more
1 1 exactly
2..4 between 2 and 4, inclusive
5..* 5 or more
2. name (what relationship the objects have)
3. navigability (direction)
An Example
Student Courseenroll
advisee
advisorFaculty
6..* 0..*
1
0..*Course
0..*
1
teach
1..*
1
Association Class
Adds attributes and operations to an association– Allows exactly one instance of the association class
between any two objects– Can use an actual class instead, if you need more
PersonCompany0..* 1..*
Job
descriptiondateHiredsalary
employeeemployer
Special cases of Association
Aggregation : "is part of" symbolized by a clear white diamond.
Composition : "is entirely made of“ symbolized by a black diamond.
Aggregation
Special form of association representing has-a or part-whole relationship.
Distinguishes the whole (aggregate class) from its parts (component class).
No relationship in the lifetime of the aggregate and the components (can exist separately).
Aggregate Component
Aggregation Example
room
wall
Composition
Stronger form of aggregation
Implies exclusive ownership of the component class by the aggregate class
The lifetime of the components is entirely included in the lifetime of the aggregate (a component can not exist without its aggregate).
Composition Component
A Composition Example
Document
Paragraph
Sentence
Word
0..*
1..*
1..*
An Example
Department
member-of
Faculty
College
chair-of
Student
1
1 1
1
1 1
1..*
0..*1..*
1..*
University
Relationships (contd)
Generalisation
A relationship between a general thing (called “parent” or “superclass”) and a more specific kind of that thing (called the “child” or “subclass”), such that the latter can substitute the former.
Notation:(arrow-head points to the superclass)
Generalization (inheritance) relationshipshierarchies drawn top-down with arrows pointing upward to parent
line/arrow styles differ, based on whether parent is a(n):
class:solid line, black arrow
abstract class:solid line, white arrow
An Example
Relationships (contd)
Realization
A semantic relationship between two things wherein one specifies the behavior to be carried out, and the other carries out the behavior.
Notation:
(arrow-head points to the thing being realized)
Realization (representations)
Another example
Diagrams with UML
UML includes nine diagrams - each capturing a different dimension of a software-system architecture.
Class DiagramObject DiagramUse Case DiagramSequence Diagram Collaboration Diagram
Statechart DiagramActivity DiagramComponent DiagramDeployment Diagram
Common Mechanism
Mechanisms/elements that apply consistently throughout the language:
Specifications
Adornments
Common Divisions
Extensibility Mechanisms
Adornments
visibility: + public
# protected- private/ derived
underline static methods/attributes
parameter types listed as (name: type)
Italics Abstract Class
Common Division
There is a division of class and objects
Customer Joe : Customer
: Customernameaddressphone
Joe
Common Division
There is a separation of Interface and Implementation
Spellingwizard.dll
IUnknown
ISpelling
Extensibility Mechanism
Stereotype : Extends the vocabulary of the UML
Tagged value : Extends the properties of the UML
Constraints : Extends the semantics of the UML
EventQueue {version=3.4 author =sia}
add()removeflush()
<<exception>>Overflow {ordered}
Another Example (Stereotype)
Another Example (Tagged value)
Another Example (Constraints)
Revisiting Classes (Modeling advanced features)
Abstract, root and leaf elements
Multiplicity
Attributes
The Syntax of an attribute in the UML is
[visibility] name [multiplicity] [:type] [=initial-value] [{property-string}]
Example-
+ name [0..1] :String
origin : Point = (0,0)
id : integer {frozen}
Can be one ofchangeable, addOnly, frozen
Operations
visibility name ( parameter-list ) : return-type { property-string }
can be: isQuery (does not change state of the object) sequential (should not be called concurrently) guarded (like synchronized)concurrent (canbe executed concurrently)
Parameters can be marked as in, out, inout
Modeling static types (role-change)
Revisiting Association (Modeling advanced features)
Navigation
Unless otherwise specified, navigation across an association is bidirectional.
Navigation could be limited to one direction. By specifying the direction of traversal.
Visibility
Qualification
Interface Specifier
Class Diagrams
DVD Movie VHS Movie Video Game
Rental Item
Rental Invoice
1..*1
Customer
Checkout Screen
0..1
1
Simple
Association
Class
Abstract
Class
Simple
Aggregation
GeneralizationComposition
Multiplicity
Modeling a schema
Object Diagram
Interaction Diagram
Model the dynamic behaviour of the system; the flow of control within an operation.
Describe the interaction between objects; objects interact through messages to fulfill tasks.
Interaction provides behaviour and typically implements a Use Case.
Two types of interaction diagrams in UML– Sequence Diagrams (temporal dimension)– Collaboration Diagrams (structural dimension)
Sequence Diagram
Sequence diagram is an interaction diagram that emphasizes the time-ordering of messages in an interaction.
Models interaction as a two-dimensional chart.
Objects participating in the interaction are plotted along the X-axis, time on the Y-axis.
Y-axis models the objects lifeline.
Messages passed between objects manifest the interaction.
An Example
Collaboration diagram
Collaboration diagram is an interaction diagram that emphasizes the structural organization of objects participating in an interaction.
It showsobjects / classes
links between them
message flow along links
Messages are numbered to show sequence
An Example
Use Case Diagram
Use Case Diagrams is the UML mechanism for requirements capture.
Use Case Diagrams are a graphical presentation of the “actors” in the domain and the “use cases” initiated by them.
“Use cases” are abstractions of discrete behavior exhibited by the system; perform a specific goal for an “actor”.
An “actor” is an abstraction of a role played by anyone or anything interacting with the system.
Common Uses
To Model the context of the system To Model the requirements of the system.
Modeling the context of the system
Modeling the requirements of the system
Another Example (A complete picture)
Use Cases and Scenarios
A Use Case actually describes a set of sequences [of actions].
Each sequence represents one possible flow of actions in using the system.
Each sequence is called a Scenario.
A Scenario is basically one instance of a use case.– a Scenario is to a Use Case, what an Object is to a Class.
Use Case Realization
The use case diagram is an external view of the system
A use case is realized in a collaboration
A collaboration shows an internal implementation- dependent solution of a use case in terms of:
– classes/objects– their relationships– their interaction
Realization (A Higher level of Abstraction)
Realization
Use Case A:ClassA :ClassB
:ClassC :ClassD
1: msg1
2: msg2
3: msg3
A Collaboration
Class A
Oper1()...
Class B
Oper2()...
Class C
Oper3()...
<<implements>> <<implements>> <<implements>>Use Case A description1. Step 12. Step 23. ...