Professional Documents
Culture Documents
UML 1 Ikt437 2015
UML 1 Ikt437 2015
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 1
Object-oriented modelling
involves classes which function as
types that describes their
instances which are called
objects.
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 2
Object-oriented modelling
includes description of:
- object properties
- links between objects
- object behaviour
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 3
Objects
Icons representing
“real world objects”
of different types.
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 4
Classify Objects
Some objects share the same type of qualities so we
may formulate a general concept = define a class.
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 5
Class and Objects
UML Notation
class
objects
Person class name
SSN
person1:Person person2:Person
name attributes
address (fields)
SSN = 123... SSN = 122...
drive() operations name= Jane name = James
Run() address=Norway address = USA
(methods)
...
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 6
Making a Model
• You are to solves some problem in a domain.
chair: Seated in
Tom:
car: owner
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 7
Subclass and Superclass
The class of human beings
Person
The classes represented in
the UML notation.
Female Male
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 8
Class Hierarchy ~
Reuse by Inheritance
An employee is a special type of person, so if you already have a
Person class and needs an Employee class, then inheritance allows
you to reuse class Person.
superclass Person
Jane:Employee
SSN
name SSN = 123...
address name = Jane
inheritance Employee is a
address = Norway
or specialization specialisation
title = accountant
of Person
department = accounting
subclass Employee
An object of type Employee
title
department
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 9
Multiple Person
name
Inheritance Employee
title
Owner
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 10
One Common
Ancestor for All
Classes
Object
hashCode
Employee
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 11
Linking Objects
Objects are typically connected in some way or another. For
example: Jane is married to James, Jane owns a car.
ownership
Person Car
Jane:Person
:ownership
someWreck:Car
Object Model
(model instance of the
class model)
:married
links
James:Person
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 12
Part-of Relation
Some objects can be seen as compost of other objects.
Head
1
1
2 1
Arm Person
1
Leg
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 13
There Are Typically Many
Ways to Classify Objects
Jim may be classified as a person, a male person, an
employee, a student and so on - the context decides.
xxx:
xxx:
xxx:
xxx:
xxx:
xxx: xxx:
xxx: xxx:
xxx:
xxx: xxx:
xxx: xxx:
xxx:
xxx:
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 14
How to model
gender?
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 15
Different Models May be
Possible!
Person Gender Person
gender : String Gender Person
Female Male
Female Male
Gender Person
Androgyni
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 16
Object Behaviour
CoffeeMachine
Person
pourCoffe()
operations ~ behaviour
addMilk()
addOneLumpOfSugger()
addOneLumpOfSugger( )
time
addMilk( )
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 17
An Object-Oriented Program
------
given
System
E.g. physics :
- the system under study is nature (which is given)
- the mission is to come up with a description (model) that
is so good that it can be used to predict and explain
natural phenomenon.
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 19
Specification (Prescriptive)
& Descriptive Model
Model The “specifiedBy role” is a Model
describedBy specialization of the specifiedBy
“describedBy role.”
given describedBy specifiedBy specifies
System System
In physics the system under study is nature (which The specification of a software system;
is given); the mission is to come up with a description the implementation (system) must conform
(model) that is so good that it can be used to predict to the model.
and explain natural phenomenon.
UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 20