0% found this document useful (0 votes)
38 views

Lecture 11-UML Basics Inheritance Association, Aggregation, Composition

Uploaded by

mhasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Lecture 11-UML Basics Inheritance Association, Aggregation, Composition

Uploaded by

mhasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Lecture – 11

UML Basics: Inheritance, Association,


Aggregation and Composition

Mohammad Hasan
Assistant Professor & Adjunct Faculty
Department of CSE, NDUB
Contents
 UML Basics
- Generalization (Inheritance) – IS-A Relationship
- Association
- Aggregation
- Composition – HAS-A Relationship

2
Topic - 1 : Inheritance (Generalization)

 A generalization is a taxonomic relationship between a more general classifier


and a more specific classifier.

 Represents an "is-a" relationship.

3
 SubClass1 and SubClass2 are specializations of SuperClass.
IS-A relationship

Bank Human
Super // Generalization

extends extends

DBBL Boy
Sub // Specialization

4
Topic - 2 : Association

 Relationship between two separate classes which establishes through their


Objects. .
 Also known as “has-a" relationship.
 Each class is independent. They can exist without each other.

Course has Teacher

Customer buys Product

5
Two types of Association
 Unary Association: Class A has Class B; But Class B does not have Class A

A has B Customer Product


buys

 Binary Association: Both Classes know about each other.

A has B Student has Teacher


6
Unary Association
Two types and Binary Association
of Association
1. Unary Association

Customer buys
Product
>

Customer Class will have the object of Product

7
Unary Association
Two types and Binary Association
of Association
2. Binary Association

Student Teacher

8
Unary Association
Two types and Binary Association
of Association
2. Binary Association (Solved by Association Class)

Student Teacher

AssociationClass

9
Topic - 3 : Aggregation and Composition
[Whole/Part Relationship]

10
3.1: Aggregation
 Specified form of Association
 Whole/Part Relationship

A B

Whole Part

 Class B is a part of Class A.


 Both Classes are independent. Part class can exist without Whole Class.

Car Engine

11

Whole Part
3.2: Composition
 Specified (Stronger) form of Association
 Whole/Part Relationship

A B

Whole Part

 Class B is a part of Class A.


 The existence of Part class depends on Whole Class.

Car Windo House Kitche


w n
12

Whole Part
The figure below shows the three types of association connectors:
association, aggregation and composition

We see the following relationships:

• owners feed pets, pets please owners


(Association)

• a tail is a part of both dogs


(Aggregation / Composition)

• a dog is a kind of pet


(Inheritance / Generalization)

13
UML Notation

Inheritance

14
Example - 1

15
Example – 2: Description to UML

 Volvo is a Car.
 Every car has model and company of type string.
 Volvo has price of type double, productionYear and registrationNumber of type string.
 Volvo also has Engine and DashBoard.
 Engine has capacity of type double.
 DashBoard has size of type double.
 Car provides drive and stop as abstract service or method of type void.
 Volvo also provides changeFuel and checkBattery service or method of type void.

16
Example – 2: Description to UML

 Volvo is a Car.
 Every car has model and company of type string.
 Volvo has price of type double, productionYear and registrationNumber of type
string.
 Volvo also has Engine and DashBoard.
 Engine has capacity of type double.
 DashBoard has size of type double.
 Car provides drive and stop as abstract service or method of type void.
 Volvo also provides changeFuel and checkBattery service or method of type void.
17
Solution of Example – 2: Description to UML
• Volvo is a Car.
Car
• Every car has model and company of
#model : String
type string.
#company: String
• Volvo has price of type double,
productionYear and + drive () : void
registrationNumber of type string. + stop () : void

• Volvo also has Engine and


DashBoard. Engine
• Engine has capacity of type double. -capacity : double
• DashBoard has size of type double. Volvo
• Car provides drive and stop as - price: double
abstract service or method of type - productionYear: String
DashBoard
void. - registrationNumber: String
-size : double
• Volvo also provides changeFuel and
+ changeFuel() : void
checkBattery service or method of +checkBattery () : void 18
type void.
Solution of Example – 2: Description to UML
• Volvo is a Car.
Car
• Every car has model and company of
#model : String
type string.
#company: String
• Volvo has price of type double,
productionYear and + drive () : void
registrationNumber of type string. + stop () : void

• Volvo also has Engine and


DashBoard. Engine
• Engine has capacity of type double. -capacity : double
• DashBoard has size of type double. Volvo
• Car provides drive and stop as - price: double
abstract service or method of type - productionYear: String
DashBoard
void. - registrationNumber: String
-size : double
• Volvo also provides changeFuel and
+ changeFuel() : void
checkBattery service or method of +checkBattery () : void 19
type void.
Example – 3: Try Yourself
• Apple is a fruit
• Apple has color and origin
• Apple has Sticker
• Sticker has logo

20
Thank you!

21

You might also like