Unified Modeling Language

Rajeev Kumar CSE, IIT-Kgp

PART I

Rajeev Kumar, CSE, IIT - Kgp

2

Systems, Models, and Views
A model is an abstraction describing a system or a subset of a system A view depicts selected aspects of a model A notation is a set of graphical or textual rules for representing views

Rajeev Kumar, CSE, IIT - Kgp

3

Systems, Models and Views ( UML )
System * Model * depicted by View

described by

airplane:System

scaleModel:Model

flightSimulator:Model

blueprints:View fuelSystem:View electricalWiring:Vie
Rajeev Kumar, CSE, IIT - Kgp 4

What is UML?
UML is a Language for...

• Visualizing • Specifying • Constructing • Documenting

Rajeev Kumar, CSE, IIT - Kgp

5

System Architecture
Class

Design View
Object

Use Case View Process View

Use Case

Sequential Collaboration State Activity

Implementation View Deployment View

Component Deployment
6

Rajeev Kumar, CSE, IIT - Kgp

Class
Name A Class represents a Concept Attributes Represents a set of objects that Surface have the same Texture Attributes, Operations, increaseTex() Relationships descreaseTex() and Semantics. returnTex() Can be mapped directly to many programming Operations languages
Rajeev Kumar, CSE, IIT - Kgp

7

Class
Singleton 2 or more instances

Surface [2..*]
+ Tex : Texture + Col : Colour 1 # Dim : Dimension
Instance scope ( auto )

Public

Private

+ changeCol() + increaseTex() + decreaseTex() - queryTex() # findSibling()

Class scope ( static )

Protected
Rajeev Kumar, CSE, IIT - Kgp 8

Class - Templates
Template class

Polygon

Name Name

+ rotateLeft() Template + rotateRight() parameters + enlarge()

Implicit Binding

<<bind>> ( Square )

Polygon< Square > MySquare
Rajeev Kumar, CSE, IIT - Kgp 9

Relations
A Relation is a Connection between things (e.g.: Classes). The three types or relations are:

• Dependency • Generalization • Association

Rajeev Kumar, CSE, IIT - Kgp

10

Relations - Dependency
A dependency states that changing the thing A may effect the thing B.

Dependency

FindRecord

ReadBlock

B B depends on A
Rajeev Kumar, CSE, IIT - Kgp

A

11

Relations Generalization
generalized

Button
specialized

specialized

Ok Button

Cancel Button

Generalization relationships denote inheritance between classes. The children classes inherit the attributes and operations of the parent class.
Rajeev Kumar, CSE, IIT - Kgp 12

Relations - Association
Multiplicity

1 Is made of 1..*

House

Bricks

Association

•An association denotes the relationship between classes. •the multiplicity of an association end denotes how many objects the source object can reference.
Rajeev Kumar, CSE, IIT - Kgp 13

Relations - Association
parent / aggregate

House

aggregation 12 1..* children

Windows

Bricks

•An aggregation is a special case of association denoting a “consists of” hierarchy. •The aggregate is the parent class, the components are the children class.
Rajeev Kumar, CSE, IIT - Kgp 14

Relations - Association

parent / aggregate

Clock

aggregation 1 1 children

Small hand

Big hand

A solid diamond denote composition, a strong form of aggregation where components cannot exist without the aggregate.
Rajeev Kumar, CSE, IIT - Kgp 15

Relations - Realization

A Realization is: • A contract • Used to model an Interface

Rajeev Kumar, CSE, IIT - Kgp

16

Relations - Realization

processRec record getNewData() updateRec()
realization

seekRecord

A Realization relation...
Rajeev Kumar, CSE, IIT - Kgp 17

Class Diagrams
A Class Diagram consists of the following things:

• Classes • Interfaces • Collaborations • Dependency / generalization / association

Rajeev Kumar, CSE, IIT - Kgp

18

Class Diagrams
Class Cardinality
WristWatch
1 1 1 1 1

Association

2

1

2

1

LCDDisplay Blink getBlink() setBlink()

Battery charge

Buttons state

Strap color fix() release()

getChrge() push() setWarn() release()

Operations
Rajeev Kumar, CSE, IIT - Kgp

Attributes
19

Objects
An Object is a physical instantiation of a class.

blueprint

gives us

house

class

gives us

object

abstract
Rajeev Kumar, CSE, IIT - Kgp

concrete
20

Objects

Named Instance op : Operations

anonymous instance

: Operations

op :

orphan instance

underlined

op : Operations

object with state

res : Result = True

Rajeev Kumar, CSE, IIT - Kgp

21

Object Diagrams

An Object Diagram: • is a snapshot of a dynamic process • is an instance of a class diagram • shows set objects and their relation at a point in time An Object Diagram consists of: • objects • links • attribute value

Rajeev Kumar, CSE, IIT - Kgp

22

Object Diagrams
c : Company Object

d1 : Department

d2 : Department

e1 : Employee

links

e1 : Employee e2 : Employee

e2 : Employee Attribute value

e3 : Employee

c Kgp name = “Satish” Rajeev Kumar, CSE, IIT:- Contact

23