I UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, - - PowerPoint PPT Presentation

i
SMART_READER_LITE
LIVE PREVIEW

I UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, - - PowerPoint PPT Presentation

UML Class & Object Diagram I 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


slide-1
SLIDE 1

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 1

UML Class & Object Diagram

I

slide-2
SLIDE 2

Object-oriented modelling involves classes which function as types that describes their instances which are called

  • bjects.

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 2

slide-3
SLIDE 3

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

slide-4
SLIDE 4

Objects

myChair: :Bus :Plane :Truck :Ship

PN62001:Car

Anonymous object, only type is given Object name and no type Object name (id) and type

Represented in the UML notation. Icons representing “real world objects”

  • f different types.

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 4

slide-5
SLIDE 5

Classify Objects

myChair: yourChair: theBrownSofa: Furniture

Some objects share the same type of qualities so we may formulate a general concept = define a class.

This is a form of abstraction - some of the differences between the objects are “abstracted away” (ignored).

A class describes a set of objects that have the same type of attributes, behaviour and relationships.

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 5

slide-6
SLIDE 6

Class and Objects UML Notation

person1:Person SSN = 123... name= Jane address=Norway person2:Person SSN = 122... name = James address = USA

  • bjects

Person SSN name address drive() Run() ...

class attributes (fields)

  • perations

(methods) class name

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 6

slide-7
SLIDE 7

Introduction to Object-oriented Software Development, Jan.Pettersen Nytun page no. 7

How does one show

Classes and Objects

in a

Java Program?

slide-8
SLIDE 8

public class Patient extends Person { private Journal patientsJournal; public Patient(String name, Doctor createdBy) { super(name); patientsJournal = new Journal(); patientsJournal.setCreatedBy(createdBy); patientsJournal.setConcerns(this); } public Journal getPatientsJournal(){ return patientsJournal; } public void setPatientsJournal(Journal patientsJournal) {

  • this. patientsJournal = patientsJournal;

} }

Introduction to Object-oriented Software Development, Jan Pettersen Nytun page no. 8

slide-9
SLIDE 9

Making a Model

  • You are to solves some problem in a domain.
  • Simplify and find what is essential for your problem.
  • OO modelling: ”Objects from reality” are mapped

”directly” onto objects in your model.

reality chair: car: Tom:

Seated in

  • wner

model mapping

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 9

slide-10
SLIDE 10

Subclass and Superclass

The class of human beings

The subclass of ”female objects” People is superclass of Female

Jane:

James:

Person Female Male

The classes represented in the UML notation.

Person Female Male

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 10

slide-11
SLIDE 11

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.

Person SSN name address Employee title department An object of type Employee Jane:Employee SSN = 123... name = Jane address = Norway title = accountant department = accounting inheritance

  • r specialization

Employee is a specialisation

  • f Person

superclass subclass

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 11

slide-12
SLIDE 12

Multiple Inheritance

Person name Employee title Owner WorkingOwner

  • UML and OWL supports

multiple inheritance.

  • Some object-oriented

theoreticians claim that multiple inheritance should not be used! (e.g., Java).

Cassette

volume : Integer

Book

volume : Integer CassetteBook

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 12

slide-13
SLIDE 13

One Common Ancestor for All Classes

In Java all classes have a common ancestor called Object. In OWL it is called Thing. In C++ UML this is not the case.

Object Person Car Employee hashCode

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 13

slide-14
SLIDE 14

Linking Objects

Objects are typically connected in some way or another. For example: Jane is married to James, Jane owns a car.

Jane:Person someWreck:Car James:Person

:married :ownership

links

Person Car

  • wnership

married

association

Class Model Object Model

(model instance of the class model)

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 14

slide-15
SLIDE 15

Part-of Relation

Some objects can be seen as compost of other objects.

Person Leg Head Arm

2 1 2 1 1 1

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 15

slide-16
SLIDE 16

There Are Typically Many Ways to Classify Objects

the classes may overlap (or they may be disjoint)

xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx: xxx:

Jim may be classified as a person, a male person, an employee, a student and so on - the context decides.

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 16

slide-17
SLIDE 17

How to model gender?

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 17

slide-18
SLIDE 18

Different Models May be Possible!

Gender Female Male Person Person gender : String Gender Female Male Person Undecided Gender Female Male Person Androgyni Gender Female Male Person Androgyni

?

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 18

slide-19
SLIDE 19

8/17/2016 Introduction to Object-oriented Software Development, J.Pettersen Nytun page no. 19,

“Not all people feel at home in the categories male or female. Professor of sexology Esben Esther Pirelli Benestad believes there are seven different genders.”

[https://www.nrk.no/norge/visste-du-at-det-finnes-sju-kjonn_-1.13057760]

slide-20
SLIDE 20

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 20

Object Behaviour

Jane : Person

  • ffice : CoffeeMachine

pourCoffe( ) addOneLumpOfSugger( ) addOneLumpOfSugger( ) addMilk( )

time

sending a message lifeline for object

  • ffice:CoffeeMachine

canUse

  • perations / behaviour

canBeUseBy * *

slide-21
SLIDE 21

An Object-Oriented Program

  • Objects Work Together and Solve Problems
  • Objects have identity.
  • Objects have state, the values of the attributes defines

the state. The state change when the values of the attributes change.

  • Some objects are linked together.
  • The objects communicate by sending messages to each
  • ther (messages follows the links).

Sending a message is the same as asking an object to perform one of its operations (methods).

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 21

slide-22
SLIDE 22

Descriptive Models

System Model given describedBy 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. 22

slide-23
SLIDE 23

Specification (Prescriptive) & Descriptive Model

System Model given describedBy System Model specifies specifiedBy Person name Car 1 * :Person name=“Bob” :Car :Car In 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. The specification of a software system; the implementation (system) must conform to the model. Model A Model Instance snapshot The “specifiedBy role” is a specialization of the “describedBy role.” A system is a group of interacting, interrelated, or interdependent elements that form a complex whole.

specifiedBy describedBy

UML Class Diagram & Object Diagram I, Jan Pettersen Nytun, page no. 23

slide-24
SLIDE 24

What is a Domain Model

“A domain model is a model of the domain within which an Enterprise conducts its

  • business. The Domain Model for one

Enterprise should be the same as that for any

  • ther Enterprise conducting business in the

same do main. When we get down to more detailed levels, different people have different ideas about what constitutes a Domain Model.”

[http://www.aptprocess.com/whitepapers/DomainModelling.pdf]

8/17/2016 Introduction to Object-oriented Software Development, J.Pettersen Nytun page no. 24,

Domain Domain Model given describedBy

slide-25
SLIDE 25
  • A UML class diagram can be used to describe a

domain model.

  • Some would say that a domain model is an
  • ntology.
  • The model is a model of software which is the

main purpose of UML.

8/17/2016 Introduction to Object-oriented Software Development, J.Pettersen Nytun page no. 25,

Domain Domain Model given describedBy System Model specifies specifiedBy