Top Banner
12 September, 2007 Information System Design IT60105, Autumn 2007 Information System Design IT60105 Lecture 11 Class and Object Diagrams
28

Information System Design IT60105

Jan 13, 2016

Download

Documents

lilia Baltouma

Information System Design IT60105. Lecture 11 Class and Object Diagrams. Lecture #11. What is a class diagram? Basic components in any class diagram and their notations Example: Class Diagram in OLP system What is an object diagram - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Information System DesignIT60105

Lecture 11

Class and Object Diagrams

Page 2: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Lecture #11• What is a class diagram?

• Basic components in any class diagram and their notations

• Example: Class Diagram in OLP system

• What is an object diagram

• Basic components in any object diagram and their notations

• Example: Object Diagram in OLP system

Page 3: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Class Diagram

Page 4: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

What is a Class Diagram?• A class is a structural component of any object oriented system. The class

diagram used to model the structural view of the underlying system

• A class diagram is a collection of all possible classes in a system and relationships among them

• The different relations may occur in a class diagram are

– Association/Aggregation

– Generalization/Specialization

• Class diagrams also show the attributes and operations of a class. also it can depicts the navigability (direction of trace ability) and the constraints that apply to the way objects are connected

Page 5: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Basic Class Model Notations

• Class

• Example

C lassN am e

A cco u n t B o o k

C u sto m er P erso n

Page 6: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Detail Class Diagram

• Class diagram also shows the attributes and operations of classes

• Think: For the class Server, what are the attributes? operations?

N am e

A ttribu tes

O pera tions

B o o kb o o k N a m e : S t r in gA u th o rs : S t r in gA c c n N o :S t r in gd a te O fIsu u e : D a teissu e T o :P e rso nd a te O fR e tu rn : D a te

issu e (b o r ro w e r Id : P e rso n ID )re tu rn ( ) :flo a tre se rv e (b o r ro w e rID :P e rso n ,p r io r ity :in t )e d itB o o k ( )re m o v e B o o k ( )

Att

ribut

es

Ope

ratio

ns

Page 7: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Visibility

• The notation that precedes the attribute or operation name indicates the visibility of the element, if the + symbol is used the attribute or operation has a public level of visibility, if a - symbol is used the attribute or operation is private. In addition the # symbol allows an operation or attribute to be defined as protected and the ~ symbol indicates package visibility.

Page 8: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Relation Association

• An association implies two model elements have a relationship - usually implemented as an instance variable in one class. This connector may include named roles at each end, cardinality, direction and constraints. Association is the general relationship type between elements. For more than two elements, a diagonal representation toolbox element can be used as well. When code is generated for class diagrams, associations become instance variables in the target class.

C lass BC lass AAssocia tion name

Role A Role B

Page 9: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Aggregation and Composition

C lass BC lass AAggregation name

C lass BC lass AComposition name

Page 10: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Association Class

C lass BC lass AAssocia tion name

A sso cN am e

C lass BC lass AW orks for

A sso cN am e

Employee Department

W orks

Page 11: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Multiplicity

cc

C lass1

E xac tly on e

C lass*

M an y (zero o r m ore}

C lass0..1

O p tion a l(zero o r on e)

C lass1..*

O n e o r m ore

Page 12: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Multiplicity & Association

Page 13: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Example of a Class Diagram

IIT

FacultyCourse

Departm ent

Student

attends teacheso

ffers

wo

rks

in

en

rolle

d in

has

HO D

cha

irs

1

* * *

1..*

1..*

1..*

1..*

1..*

0..1**

*

1..*

Page 14: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Another Example

Page 15: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Example: Internet

• ? Internet– Network of networks (is a collection of servers)

– A collection of web pages

• This internet can be thought of an object-oriented system– ? Use case diagram

– ? Activity diagrams

– ? State-chart diagrams

etc…..

• Let’s consider the class diagram of the system Internet

Page 16: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Example: Internet

• This class diagram shows a collection of all possible classes in the system namely, the Internet and relationships among them

• This simple class diagram shows the association and aggregation relationship

W e b p a g e S e rv e r

N e tw o rk

* 1

1

*

has

links

Page 17: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Interface: Generalization & Specialization

C lass BC lass A

C lass S

C lass X C lass Y

C lass C

Page 18: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Another view of Internet Class Diagram

W e b p a g e S e rv e r

N e tw o rk

* 1

1

*

has

links

S ta tic D y a n m ic

.a sp .jsp .p h p

IIS A p a c h e

M A N W A NL A N

• This class diagram shows the generalization/specialization relationship

Page 19: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Example: Class Diagram in OLP System

1O rd e r C u s to m e r

C o rp o ra teP e rso n

I te m L is t P ro d u c t E m p lo y e e

*

1

1

0..1

*

*1

Page 20: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Object Diagram

Page 21: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

What is an Object Diagram• An object is an instance of a class

• An object diagram is a collection of object and its relationships among them, just like class diagrams

• More precisely, an object diagram is a snapshot of the objects in a system at a particular point of time

• Since object diagram shows instances rather than classes, an object diagram is often called an instance diagram

• Usually, an object diagram is used to provide an example configuration of objects

Page 22: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Example: Object Diagram• Let us consider a composition of a class in OLP system

• From the application point of views, the customer class signifies that a customer is either a person or an organization or an employee of an organization

1O rd e r C u s to m e r

C o rp o ra teP e rso n

I te m L is t P ro d u c t E m p lo y e e

*

*

1

0..1

*

*1

purchase

Page 23: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Example: Object Diagram• Further consider a particular snapshot at an instance

ram: Person

sita: Person

bhim: Employee

arjun: Employee

oldIndia: Corporate

newIndia: Corporate

Further assume that bhim and arjun are the employees of oldIndia

C u s to m e r

C o rp o ra teP e rso n

E m p lo y e e

[ram , s ita ]

[bh im , a rjun ]

[o ld Ind ia , new Ind ia ]

Page 24: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Example: Object Diagram• The object diagram for the above snapshot will look like this

o ld In d ia : C o rp o ra te n e w In d ia : C o rp o ra te

b h im : E m p lo y e e a r ju n : E m p lo y e e

ra m : P e rso n

s ita : P e rso n

Page 25: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

More Example: Object Diagram• Let’s consider a small modification in the class diagram

• This signifies that a customer being a corporate can purchase for others, say person, organizations

C u s to m e r

C o rp o ra teP e rso n

E m p lo y e e

*

1

purchase for

Page 26: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

More Example: Object Diagram• A snapshot under this modified situation is

ram: Person

sita: Person

bhim: Employee

arjun: Employee

oldIndia: Corporate

newIndia: Corporate

india: Corporate

Here, suppose india purchase for oldIndia and newIndia

C u s to m e r

C o rp o ra teP e rso n

E m p lo y e e

[ram , s ita ]

[bh im , a rjun ]

[ind ia , o ld Ind ia , new Ind ia ]

1

Page 27: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

More Example: Object Diagram

O ld In d ia : C o rp o ra te N e w In d ia : C o rp o ra te

b h im : E m p lo y e e a r ju n : E m p lo y e e

ra m : P e rso n

s ita : P e rso n

in d ia : C o rp o ra te

Page 28: Information System Design IT60105

12 September, 2007 Information System Design IT60105, Autumn 2007

Problems to Ponder

• For all the geometric objects possible like point, straight line, circle, ellipse etc. obtain the following

– Class diagram

– Object diagram for an instance of object with reference to an instance of a graphics that is drawn based on the geometric objects

• Conceptual class diagram?

• Domain class diagram?