Tải bản đầy đủ (.pdf) (18 trang)

Software design: Lecture 19 - Sheraz Pervaiz

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (398.18 KB, 18 trang )

1

Software Design

Lecture : 19


2

Relationships between Classes
Ø

Association –Discussed in Previous  Lecture

Ø

Aggregation Discussed in previous Lecture.

Ø

Composition – Started discussion.

Ø

Inheritance


3

Composition – Container and Contained classes


Ø

It’s a strong association. 

Ø

It contain Objects that live and die together.

Ø

The  composition  aggregation  relationship  is  just 
another form of the aggregation relationship, but 


4

Composition Continues....
Ø

Another  important  feature  of  composition 
aggregation  is  that  the  part  class  can  only  be 
related to one instance of the parent class

Ø

It is represented by a filled diamond shape from 
child to parent class with association


5


Example of Composition


6

Example of Composition


7

Example


8


9

Windows Operating Systems 


10

Aggregation Vs Composition


11

Generalization or “IS­A” 

relationship
Ø

It shows a relationship between super / sub class.

Ø

Sub class inherit public and protected elements 
of super class.

Ø

Sub class may override the behaviour of super 


12

Generalization / Specialization

Ø

Common data elements and methods are put 
together in super class (Generalization) and 
specific data elements are put together in sub 
classes (Specialization)


13

Conceptual Generalization



14

Generalization Example

Role
attributes
operations

Staff

Faculty

Student

Visitor

attributes

attributes

attributes

attributes

operations

operations


operations

operations


15

Example


16


17

Poor Generalization Example

(violates the “is a” or “is a kind of” heuristic)

Person
attributes
operations

Leg

Head

attributes

attributes


attributes

operations

operations

operations

Arm


18



×