SlideShare a Scribd company logo
9
Most read
10
Most read
14
Most read
Difference between association, aggregation and composition
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
Difference between Association,
Aggregation and Composition
Name
@abhishekmenon121989@gmail
.com
www.facebook.com/
Abhishek H menon
twitter.com/Abhishek H
Menon
in.linkedin.com/in/Abhishek
H menon
Association,Aggregation and Composition
• They are the relationship among classes in
java.
– Association
– Aggregation
– Composition
Derivation diagram
Association
Composition
Aggregation
Association
• It is a relationship between objects.
• Defines the multiplicity between objects.
• We are aware about the relationship such as
one-one, one-many, many-one, many-many,
these terms defines the association between
objects.
• It represents a binary relationship in between
two objects that describes an activity.
Association
• E.g.
• public class Student{
/* data fields*/
private Course;
courseList;
/*Constructors*/
/*Methods*/
}
STUDENT TEACHERCOURSE
takes teach
Association
• public class Course{
/* data fields*/
private Student[];
classList;
Private Faculty faculty;
/*Constructors*/
/*Methods*/
}
• public class Faculty{
/* data fields*/
private Course[];
courseList;
/*Constructors*/
/*Methods*/
}
Difference between association and
aggregation
• Association is a relationship between two classes
where one class use another. But aggregation
describes a special type of an association.
• Aggregation is the relationship between two classes.
When object of one class has object of another, if
second is a part of first then we called that there is
an aggregation between two classes. Unlike
association, aggregation always insists a direction.
Aggregation
• It is special case of association.
• A directional association between objects.
• When an object “has-a” another object, then
you have got an aggregation in between them.
• Direction between them should be specified
which object contains the other object.
• It is also called ‘has-a’ relationship.
Aggregation(e.g.)
Circle
Operation O
double i
area(int radius)
Operation
Square i
Aggregation
• class Operation{
int square(int i){
return n*n;
}}
• class Circle{
double pi=3.14;
double area(int radius){
Operation O=new Operation();
int rsquare=O.square(radius);
return pi*rsquare;
}
Aggregation
• Another example: take an example of our
department and developers. A developer can
be only in one department like java,dotnet
etc.suppose if we delete the department
object, still the developer exists. This is a
‘has-a’ relation.
Composition
• It is a special case of aggregation.
• In more specific manner, a restricted aggregation
is called composition.
• When an object contains another object, if the
contained object cannot exist without the
existence of the container object, then it is called
composition.
• In both aggregation and composition, direction is
must. As the direction specifies, which object
contains the other object.
Composition
• If Object B is contained within Object A, then
Object A is responsible for the creation and
destruction of Object B. Unlike
aggregation, Object B cannot exist without Object
A.
Composition(e.g.)
import java.util.GregorianCalendar;
public class Student {
private String name;
private GregorianCalendar dateOfBirth;
public Student(String name, int day, int month, int year) {
this.name = name;
this.dateOfBirth = new GregorianCalendar(year, month, day);
}
//rest of Student class.. }
Composition
• As the student class is responsible for the creation of
the GregorianCalendar object it will also be
responsible for its destruction (i.e., once the Student
object no longer exists neither will the
GregorianCalendar object). Therefore the
relationship between the two classes is composition
because Student has-a GregorianCalendar and it also
controls its lifetime. The GreogrianCalender object
cannot exist without the Student object.
If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
Contact Us

More Related Content

What's hot (20)

PPTX
Gof design patterns
Srikanth R Vaka
 
PPTX
Object Oriented Analysis (Coad-Yourdon)
Subash Khatiwada
 
PPTX
Java Beans
Ankit Desai
 
PPTX
OOP - Understanding association, aggregation, composition and dependency
Mudasir Qazi
 
PPTX
Use case diagram
City University
 
PPT
Java-java virtual machine
Surbhi Panhalkar
 
PDF
Lecture7 use case modeling
Shahid Riaz
 
PPT
Class diagrams
Nadia_Nazeer
 
PPT
Architecture design in software engineering
Preeti Mishra
 
PPTX
Inner classes in java
PhD Research Scholar
 
PPTX
Event handling
swapnac12
 
PPTX
Design Pattern - Singleton Pattern
Mudasir Qazi
 
PPTX
Transaction Properties in database | ACID Properties
nomanbarki
 
PPT
Design Patterns
Anuja Arosha
 
PPTX
Java virtual machine
Nikhil Sharma
 
PPTX
Presentation on Core java
mahir jain
 
PPT
Java static keyword
Lovely Professional University
 
PPTX
Packages in java
Elizabeth alexander
 
PPTX
Let us understand design pattern
Mindfire Solutions
 
PPT
packages and interfaces
madhavi patil
 
Gof design patterns
Srikanth R Vaka
 
Object Oriented Analysis (Coad-Yourdon)
Subash Khatiwada
 
Java Beans
Ankit Desai
 
OOP - Understanding association, aggregation, composition and dependency
Mudasir Qazi
 
Use case diagram
City University
 
Java-java virtual machine
Surbhi Panhalkar
 
Lecture7 use case modeling
Shahid Riaz
 
Class diagrams
Nadia_Nazeer
 
Architecture design in software engineering
Preeti Mishra
 
Inner classes in java
PhD Research Scholar
 
Event handling
swapnac12
 
Design Pattern - Singleton Pattern
Mudasir Qazi
 
Transaction Properties in database | ACID Properties
nomanbarki
 
Design Patterns
Anuja Arosha
 
Java virtual machine
Nikhil Sharma
 
Presentation on Core java
mahir jain
 
Java static keyword
Lovely Professional University
 
Packages in java
Elizabeth alexander
 
Let us understand design pattern
Mindfire Solutions
 
packages and interfaces
madhavi patil
 

Similar to Difference between association, aggregation and composition (20)

PPTX
Association agggregation and composition
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Association
Kanishq Gupta
 
PPT
Relations Class Diagram
halwal
 
PPT
Slide 5 Class Diagram
Niloy Rocker
 
PPTX
FALLSEM2024-25_SWE2018_ETH_VL2024250103302_2024-10-04_Reference-Material-I.pptx
yadavdkshitij2003
 
PPTX
Inheritance.pptxci-Net.ci-Netci-Net.ci-Net..ci-Net.
kiran kumar
 
PPTX
Inheritance with examples.pptxInheritance with examples.pptxInheritance with ...
kiran kumar
 
PPTX
Aggregation
zindadili
 
PPT
UML-class diagram for beginners to adance.ppt
WorkDrive2
 
PPT
cse 355 UML class diagram software engineering.ppt
Safaet Hossain
 
PPT
UML-class_diagram.ppt
PragnyaNandaSabat
 
PPTX
SoftwareEngineering sSoftwareEngineering
RiteshSharma879249
 
PPT
06 class diagrams
Baskarkncet
 
PPT
UML-class_diagram.ppt diagrams ppt download
divijareddy0502
 
PPT
Software Designing Qualified Association
KhushiAgarwal193641
 
PPT
Chapter3
Dang Tuan
 
PPTX
UML constructs
Dawood Faheem Abbasi
 
PPT
ملخص تحليل الانظمة وتصميمها - الوحدة الخامسة
جامعة القدس المفتوحة
 
PPTX
Chapter 6:Working with Classes and Their Relationships
It Academy
 
DOCX
Association in oop
Zohaib Hussain
 
Association agggregation and composition
baabtra.com - No. 1 supplier of quality freshers
 
Association
Kanishq Gupta
 
Relations Class Diagram
halwal
 
Slide 5 Class Diagram
Niloy Rocker
 
FALLSEM2024-25_SWE2018_ETH_VL2024250103302_2024-10-04_Reference-Material-I.pptx
yadavdkshitij2003
 
Inheritance.pptxci-Net.ci-Netci-Net.ci-Net..ci-Net.
kiran kumar
 
Inheritance with examples.pptxInheritance with examples.pptxInheritance with ...
kiran kumar
 
Aggregation
zindadili
 
UML-class diagram for beginners to adance.ppt
WorkDrive2
 
cse 355 UML class diagram software engineering.ppt
Safaet Hossain
 
UML-class_diagram.ppt
PragnyaNandaSabat
 
SoftwareEngineering sSoftwareEngineering
RiteshSharma879249
 
06 class diagrams
Baskarkncet
 
UML-class_diagram.ppt diagrams ppt download
divijareddy0502
 
Software Designing Qualified Association
KhushiAgarwal193641
 
Chapter3
Dang Tuan
 
UML constructs
Dawood Faheem Abbasi
 
ملخص تحليل الانظمة وتصميمها - الوحدة الخامسة
جامعة القدس المفتوحة
 
Chapter 6:Working with Classes and Their Relationships
It Academy
 
Association in oop
Zohaib Hussain
 
Ad

More from baabtra.com - No. 1 supplier of quality freshers (20)

PPTX
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
PDF
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
PDF
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 3 stored procedures
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Ad

Recently uploaded (20)

PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
community health nursing question paper 2.pdf
Prince kumar
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 

Difference between association, aggregation and composition

  • 2. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 3. Difference between Association, Aggregation and Composition Name @abhishekmenon121989@gmail .com www.facebook.com/ Abhishek H menon twitter.com/Abhishek H Menon in.linkedin.com/in/Abhishek H menon
  • 4. Association,Aggregation and Composition • They are the relationship among classes in java. – Association – Aggregation – Composition
  • 6. Association • It is a relationship between objects. • Defines the multiplicity between objects. • We are aware about the relationship such as one-one, one-many, many-one, many-many, these terms defines the association between objects. • It represents a binary relationship in between two objects that describes an activity.
  • 7. Association • E.g. • public class Student{ /* data fields*/ private Course; courseList; /*Constructors*/ /*Methods*/ } STUDENT TEACHERCOURSE takes teach
  • 8. Association • public class Course{ /* data fields*/ private Student[]; classList; Private Faculty faculty; /*Constructors*/ /*Methods*/ } • public class Faculty{ /* data fields*/ private Course[]; courseList; /*Constructors*/ /*Methods*/ }
  • 9. Difference between association and aggregation • Association is a relationship between two classes where one class use another. But aggregation describes a special type of an association. • Aggregation is the relationship between two classes. When object of one class has object of another, if second is a part of first then we called that there is an aggregation between two classes. Unlike association, aggregation always insists a direction.
  • 10. Aggregation • It is special case of association. • A directional association between objects. • When an object “has-a” another object, then you have got an aggregation in between them. • Direction between them should be specified which object contains the other object. • It is also called ‘has-a’ relationship.
  • 12. Aggregation • class Operation{ int square(int i){ return n*n; }} • class Circle{ double pi=3.14; double area(int radius){ Operation O=new Operation(); int rsquare=O.square(radius); return pi*rsquare; }
  • 13. Aggregation • Another example: take an example of our department and developers. A developer can be only in one department like java,dotnet etc.suppose if we delete the department object, still the developer exists. This is a ‘has-a’ relation.
  • 14. Composition • It is a special case of aggregation. • In more specific manner, a restricted aggregation is called composition. • When an object contains another object, if the contained object cannot exist without the existence of the container object, then it is called composition. • In both aggregation and composition, direction is must. As the direction specifies, which object contains the other object.
  • 15. Composition • If Object B is contained within Object A, then Object A is responsible for the creation and destruction of Object B. Unlike aggregation, Object B cannot exist without Object A.
  • 16. Composition(e.g.) import java.util.GregorianCalendar; public class Student { private String name; private GregorianCalendar dateOfBirth; public Student(String name, int day, int month, int year) { this.name = name; this.dateOfBirth = new GregorianCalendar(year, month, day); } //rest of Student class.. }
  • 17. Composition • As the student class is responsible for the creation of the GregorianCalendar object it will also be responsible for its destruction (i.e., once the Student object no longer exists neither will the GregorianCalendar object). Therefore the relationship between the two classes is composition because Student has-a GregorianCalendar and it also controls its lifetime. The GreogrianCalender object cannot exist without the Student object.
  • 18. If this presentation helped you, please visit our page facebook.com/baabtra and like it. Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com