SlideShare a Scribd company logo
1 of 19
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
Association aggregation and
        composition


           Jithin Mathew
           jitmat@gmail.com
           www.facebook.com/jithinmatthew
They are the relationships among classes in
java
– Association
– Aggregation
– Composition
Association
• It is a relationship between two objects.
• In other words, association defines the multiplicity
  between objects.
• You may be aware of one-to-one, one-to-many,
  many-to-one, many-to-many all these words define
  an association between objects.
• Aggregation is a special form of association.
• Composition is a special form of aggregation.
Association represents a general binary relationship
that describes an activity between two classes
Another example for Association

• Let’s take an example of Teacher and Student.
  Multiple students can associate with single
  teacher and single student can associate with
  multiple teachers but there is no ownership
  between the objects and both have their own
  lifecycle. Both can create and delete
  independently.
Aggregation
• It is a special case of association.
• A directional association between objects.
• When an object ‘has-a’ another object, then
  you have got an aggregation between them.
• Direction between them specified which
  object contains the other object.
• It is also called ‘Has-a’ relationship.
Note:
 If you delete the parent object, even then the
 child object may exist. One object can contain
 the other, but there is no restriction that the
 composed object has to exist in order to
 have existence of child object.
Examples for aggregation
• Take an example of Departments and developers. A developer
  can be only in one department like dotnet, java etc. but if we
  delete the Department object, still the Developer object
  exists. This is a “Has- a” relation.

• Let’s take another example of Department and teacher. A
  single teacher can not belongs to multiple departments, but if
  we delete the department teacher object will not destroy.
Composition
• It is a special case of aggregation.
• In a more specific manner, a restricted
  aggregation is called composition.
• When an object contains the other object, if
  the contained object cannot exist without the
  existence of container object, then it is called
  composition.
Example for composition
• A class contains students. A student cannot
  exist without a class. There exists composition
  between class and students.
Difference between aggregation and
            composition
• Composition is more restrictive.
• When there is a composition between two
  objects, the composed object cannot exist
  without the other object.
• This restriction is not there in aggregation.
  Though one object can contain the other
  object, there is no condition that the
  composed object must exist.
• The existence of the composed object is
  entirely optional.
• In both aggregation and composition,
  direction is must. The direction specifies,
  which object contains the other object.
Example:
  A Library contains students and books.
  Relationship between library and student is
  aggregation.
  Relationship between library and book is
  composition.
  – A student can exist without a library and therefore
    it is aggregation.
  – A book cannot exist without a library and
    therefore its a composition.
Another Example
• The relation between a car and a tyre is an
  aggregation because the tyre is still a tyre if it
  is not attached to a car. The tyre has a life of
  its own. It exists outside of a car and you can
  use it on another car.
• The relation between a car and a carburetor is
  a composition because the carburetor has no
  use if it is out of a car.
Video link:
You can refer more about this topic
  https://www.youtube.com/watch?v=0po_wm
  SEW1Q
Thank
you

More Related Content

What's hot

Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 
WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAsivasundari6
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPTPooja Jaiswal
 
Java package
Java packageJava package
Java packageCS_GDRCST
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship DiagramShakila Mahjabin
 
Dbms 14: Relational Calculus
Dbms 14: Relational CalculusDbms 14: Relational Calculus
Dbms 14: Relational CalculusAmiya9439793168
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentationtigerwarn
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVAVINOTH R
 
Constructor overloading & method overloading
Constructor overloading & method overloadingConstructor overloading & method overloading
Constructor overloading & method overloadinggarishma bhatia
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overridingRajab Ali
 
Operators in java presentation
Operators in java presentationOperators in java presentation
Operators in java presentationkunal kishore
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)Ritika Sharma
 
Principles and advantages of oop ppt
Principles and advantages of oop pptPrinciples and advantages of oop ppt
Principles and advantages of oop pptdaxesh chauhan
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingIqra khalil
 

What's hot (20)

Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVA
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Er diagrams presentation
Er diagrams presentationEr diagrams presentation
Er diagrams presentation
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Java package
Java packageJava package
Java package
 
Entity Relationship Diagram
Entity Relationship DiagramEntity Relationship Diagram
Entity Relationship Diagram
 
Dbms 14: Relational Calculus
Dbms 14: Relational CalculusDbms 14: Relational Calculus
Dbms 14: Relational Calculus
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
java token
java tokenjava token
java token
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Constructor overloading & method overloading
Constructor overloading & method overloadingConstructor overloading & method overloading
Constructor overloading & method overloading
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
 
Operators in java presentation
Operators in java presentationOperators in java presentation
Operators in java presentation
 
Uml class-diagram
Uml class-diagramUml class-diagram
Uml class-diagram
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)
 
Principles and advantages of oop ppt
Principles and advantages of oop pptPrinciples and advantages of oop ppt
Principles and advantages of oop ppt
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 

Similar to Association agggregation and composition

Chapter 6:Working with Classes and Their Relationships
Chapter 6:Working with Classes and Their RelationshipsChapter 6:Working with Classes and Their Relationships
Chapter 6:Working with Classes and Their RelationshipsIt Academy
 
Ict portfolio Michael Jacobs
Ict portfolio Michael JacobsIct portfolio Michael Jacobs
Ict portfolio Michael JacobsMichaeljay15
 
How can blogging improve the quality of sentence structure
How can blogging improve the quality of sentence structureHow can blogging improve the quality of sentence structure
How can blogging improve the quality of sentence structureJessica Miller
 
Object oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyayObject oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyaySaurabh Upadhyay
 
Implementing a Robot-Based Pedagogy in the Classroom: Initial Results from St...
Implementing a Robot-Based Pedagogy in the Classroom: Initial Results from St...Implementing a Robot-Based Pedagogy in the Classroom: Initial Results from St...
Implementing a Robot-Based Pedagogy in the Classroom: Initial Results from St...Karel Van Isacker
 
UML-class diagram for beginners to adance.ppt
UML-class diagram for beginners to adance.pptUML-class diagram for beginners to adance.ppt
UML-class diagram for beginners to adance.pptWorkDrive2
 
Articles Powerpoint
Articles PowerpointArticles Powerpoint
Articles Powerpointguestebac70
 
Articles Powerpoint
Articles PowerpointArticles Powerpoint
Articles Powerpointguestebac70
 
Blended Reading Using Collaborative Online Annotation
Blended Reading Using Collaborative Online AnnotationBlended Reading Using Collaborative Online Annotation
Blended Reading Using Collaborative Online AnnotationDeclara, INC
 
2CPP05 - Modelling an Object Oriented Program
2CPP05 - Modelling an Object Oriented Program2CPP05 - Modelling an Object Oriented Program
2CPP05 - Modelling an Object Oriented ProgramMichael Heron
 

Similar to Association agggregation and composition (20)

Difference between association, aggregation and composition
Difference between association, aggregation and compositionDifference between association, aggregation and composition
Difference between association, aggregation and composition
 
Association
AssociationAssociation
Association
 
Aggregation
AggregationAggregation
Aggregation
 
UML constructs
UML constructs UML constructs
UML constructs
 
Chapter 6:Working with Classes and Their Relationships
Chapter 6:Working with Classes and Their RelationshipsChapter 6:Working with Classes and Their Relationships
Chapter 6:Working with Classes and Their Relationships
 
Unit iv dbms
Unit   iv dbmsUnit   iv dbms
Unit iv dbms
 
Ict portfolio Michael Jacobs
Ict portfolio Michael JacobsIct portfolio Michael Jacobs
Ict portfolio Michael Jacobs
 
How can blogging improve the quality of sentence structure
How can blogging improve the quality of sentence structureHow can blogging improve the quality of sentence structure
How can blogging improve the quality of sentence structure
 
Object oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh UpadhyayObject oriented programming concept- Saurabh Upadhyay
Object oriented programming concept- Saurabh Upadhyay
 
cognitive process
cognitive processcognitive process
cognitive process
 
Implementing a Robot-Based Pedagogy in the Classroom: Initial Results from St...
Implementing a Robot-Based Pedagogy in the Classroom: Initial Results from St...Implementing a Robot-Based Pedagogy in the Classroom: Initial Results from St...
Implementing a Robot-Based Pedagogy in the Classroom: Initial Results from St...
 
Entity Relationship Model
Entity Relationship ModelEntity Relationship Model
Entity Relationship Model
 
UML-class diagram for beginners to adance.ppt
UML-class diagram for beginners to adance.pptUML-class diagram for beginners to adance.ppt
UML-class diagram for beginners to adance.ppt
 
UML-class_diagram.ppt
UML-class_diagram.pptUML-class_diagram.ppt
UML-class_diagram.ppt
 
W200 Powerpoint
W200 PowerpointW200 Powerpoint
W200 Powerpoint
 
Design pattern - part 1
Design pattern - part 1Design pattern - part 1
Design pattern - part 1
 
Articles Powerpoint
Articles PowerpointArticles Powerpoint
Articles Powerpoint
 
Articles Powerpoint
Articles PowerpointArticles Powerpoint
Articles Powerpoint
 
Blended Reading Using Collaborative Online Annotation
Blended Reading Using Collaborative Online AnnotationBlended Reading Using Collaborative Online Annotation
Blended Reading Using Collaborative Online Annotation
 
2CPP05 - Modelling an Object Oriented Program
2CPP05 - Modelling an Object Oriented Program2CPP05 - Modelling an Object Oriented Program
2CPP05 - Modelling an Object Oriented Program
 

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

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

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Association agggregation and composition

  • 1.
  • 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. Association aggregation and composition Jithin Mathew jitmat@gmail.com www.facebook.com/jithinmatthew
  • 4. They are the relationships among classes in java – Association – Aggregation – Composition
  • 5. Association • It is a relationship between two objects. • In other words, association defines the multiplicity between objects. • You may be aware of one-to-one, one-to-many, many-to-one, many-to-many all these words define an association between objects. • Aggregation is a special form of association. • Composition is a special form of aggregation.
  • 6. Association represents a general binary relationship that describes an activity between two classes
  • 7. Another example for Association • Let’s take an example of Teacher and Student. Multiple students can associate with single teacher and single student can associate with multiple teachers but there is no ownership between the objects and both have their own lifecycle. Both can create and delete independently.
  • 8. Aggregation • It is a special case of association. • A directional association between objects. • When an object ‘has-a’ another object, then you have got an aggregation between them. • Direction between them specified which object contains the other object. • It is also called ‘Has-a’ relationship.
  • 9. Note: If you delete the parent object, even then the child object may exist. One object can contain the other, but there is no restriction that the composed object has to exist in order to have existence of child object.
  • 10. Examples for aggregation • Take an example of Departments and developers. A developer can be only in one department like dotnet, java etc. but if we delete the Department object, still the Developer object exists. This is a “Has- a” relation. • Let’s take another example of Department and teacher. A single teacher can not belongs to multiple departments, but if we delete the department teacher object will not destroy.
  • 11. Composition • It is a special case of aggregation. • In a more specific manner, a restricted aggregation is called composition. • When an object contains the other object, if the contained object cannot exist without the existence of container object, then it is called composition.
  • 12. Example for composition • A class contains students. A student cannot exist without a class. There exists composition between class and students.
  • 13. Difference between aggregation and composition • Composition is more restrictive. • When there is a composition between two objects, the composed object cannot exist without the other object. • This restriction is not there in aggregation. Though one object can contain the other object, there is no condition that the composed object must exist.
  • 14. • The existence of the composed object is entirely optional. • In both aggregation and composition, direction is must. The direction specifies, which object contains the other object.
  • 15. Example: A Library contains students and books. Relationship between library and student is aggregation. Relationship between library and book is composition. – A student can exist without a library and therefore it is aggregation. – A book cannot exist without a library and therefore its a composition.
  • 16. Another Example • The relation between a car and a tyre is an aggregation because the tyre is still a tyre if it is not attached to a car. The tyre has a life of its own. It exists outside of a car and you can use it on another car. • The relation between a car and a carburetor is a composition because the carburetor has no use if it is out of a car.
  • 17.
  • 18. Video link: You can refer more about this topic https://www.youtube.com/watch?v=0po_wm SEW1Q