Association, Aggregation, Composition, Abstraction, Generalization, Realization, Dependency

These terms signify the relationships between classes. These are the building blocks of object oriented programming and very basic stuff. But still for some, these terms look like Latin and Greek. Just wanted to refresh these terms and explain in simpler terms.


Association 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.

Example: A Student and a Faculty are having an association.


Aggregation 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. Aggregation is also called a “Has-a” relationship.


Composition 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: 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. For easy understanding I am picking this example. Don’t go deeper into example and justify relationships!

Ads by Google


Abstraction is specifying the framework and hiding the implementation level information. Concreteness will be built on top of the abstraction. It gives you a blueprint to follow to while implementing the details. Abstraction reduces the complexity by hiding low level details.

Example: A wire frame model of a car.


Generalization uses a “is-a” relationship from a specialization to the generalization class. Common structure and behaviour are used from the specializtion to the generalized class. At a very broader level you can understand this as inheritance. Why I take the term inheritance is, you can relate this term very well. Generalization is also called a “Is-a” relationship.

Example: Consider there exists a class named Person. A student is a person. A faculty is a person. Therefore here the relationship between student and person, similarly faculty and person is generalization.


Realization is a relationship between the blueprint class and the object containing its respective implementation level details. This object is said to realize the blueprint class. In other words, you can understand this as the relationship between the interface and the implementing class.

Example: A particular model of a car ‘GTB Fiorano’ that implements the blueprint of a car realizes the abstraction.


Change in structure or behaviour of a class affects the other related class, then there is a dependency between those two classes. It need not be the same vice-versa. When one class contains the other class it this happens.

Example: Relationship between shape and circle is dependency.

This oops tutorial was added on 26/06/2010.



Comments on "Association, Aggregation, Composition, Abstraction, Generalization, Realization, Dependency"

  1. Ali says:


    What is Difference between Association and Dependency ?

  2. Swapnil says:

    U Say ‘ if the contained object cannot exist without the existence of container object, then it is called composition.’–>with example Library–>Books
    With your definition ‘Books can not exists without Library’..How’s this ? ..or is it the other way round ‘Library can not exists without Books’??
    I am damn confused?
    Please please help.Thanks

  3. Amitabha Roy says:

    Association: uses a
    Aggregation: has a : strong association
    Composition: owns a : weak association
    Inheritance: is a

  4. thakkar komal says:

    in ooad(Object Oriented Analysis Design and UML)

    1)Is association class same as ordinary classs? Explain with example.

    plz send ans

  5. furry says:

    “Suppose we have implemented a scenario and we used aggregation in it, after some time we realize that use of aggregation is not a correct choice, now we want to use composition instead of aggregation. Can we replace composition with aggregation? At which phase(s) these changes are required? Justify your answer with solid reasons. ”

    sir this question is related by C++

  6. Prakash says:

    Can u please explain about abstraction and encapsulation oops concepts

  7. Nagarjuna says:

    Really good article , thanks a lot.

    If you can provide the UML examples using symbols(aggregation,composition and generalization) will be more useful.

  8. Venkat says:

    Hi Joe, very nice explanation.
    I just got doubt about the sentence in “Generalisation” , you wrote as – Common structure and behaviour are used from the specializtion to the generalized class.

    or it should be as below.

    Common structure and behaviour are used from the generalized to the specializtion class.

    Correct me on this please.

  9. sarang says:

    cool.. :)

  10. pradeep says:

    Really helpful to brush up the concepts.Thanks for posting such a nice article.

  11. Girish says:

    Thanks.:) Clearcut definitions. :)

    For association, aggregation and composition could you please put real time exmaples with come classes?

    Nice work ..

  12. Jatinder says:

    Indeed this is a very good post.
    If i have understood correctly,then will it be ok to say that a child in a mother’s womb is an example of composition and after birth,a mother-child relation can be called aggregation.
    Request all learned to please correct me if i have understood incorrectly.

  13. Anonymous says:

    Very helpful and easy t understand

  14. archana says:


  15. Hamed Mirzaei says:

    Thank you

    it was very useful for me

  16. vandu says:

    such a nice information .it will help everyone..

  17. js says:

    Very information. thanks

  18. Priya says:

    Its really very easy to understand.. Thanks a lot

  19. Anonymous says:

    simple to understand…with real life egg

  20. Anonymous says:

    Nice explaination

  21. Gaurav says:

    superbly explained.. :)

  22. Abhijeet says:

    Very Nice and easy explanation.

    Thanks Joe.

  23. Anonymous says:

    good article for basics

  24. Anonymous says:

    nice explanation for UML easy understanding…Please continue this short of topics

  25. shashikant pandit says:

    earlier i confused to understand about these topic .but by the God i found your site, and understood these all topics with in few moments.

    nice site

  26. dheeraj says:

    very good explanation thanks…………..

  27. Yuri says:

    Hi, Joe!
    Thank you for your explanations!
    But… you write: “A book cannot exist without a library and therefore its a composition.”
    I think more correctly would be as follows:
    “A library cannot exist without book and therefore it’s a composition.”

  28. jyoti says:


  29. durga says:

    Thank you…..
    could you please explain these association,aggregation,composition and dependancies with a sample scenario with java classes implementation…..

  30. Ajay Shah says:

    This post is very helpfull to understand the basic concept of association and understands the association type aggregation and composition type ….

  31. Ganesh says:

    Dependency explanation is need to be amended as follows.

    Dependency is a weaker form of relationship which indicates that one class depends on another because it uses it at some point of time. One class depends on another if the latter is a parameter variable or local variable of a method of the former. This is different from an association, where an attribute of the former is an instance of the latter.

  32. Anonymous says:

    unclear definitions

  33. Anonymous says:

    Had confusion with all these terms..your way of explanation is very simple and straight forward..thanks

  34. Kausik says:

    It will be great if you have some real life example on this..

    Thanks Kausik

  35. Anonymous says:

    bhiya tussi to cha gaye…

  36. manikesh says:

    I was screwed in a interview for all these.. thanks for sharing…really good one..

  37. Anonymous says:

    thank u …………

  38. jpnaidu says:

    very helpful and easy understanding

  39. Hakkim says:

    Content is very good and the site is also looking so good keep it up sir,…

  40. Vijay says:

    Really a useful stuff to understand object relation ship.

  41. Minesh says:

    Clear explanation with simplicity!

  42. Jigar says:

    Thanks!!:) It was really worthy.. Short & to the point.. Clarifying examples played vital role in understanding.. ‘Thanks’ once again..

  43. Vijay Arige says:

    Sir…it clearly differentiated the terms for a novice programmer.

  44. Parshant says:

    sir…you should use email validation in comment box…..
    and your site content is awesome….i loved it….

  45. manojbharal says:

    Could you please share with java code examples.

    A implements B is realization
    A extends B is generalization

    AM I right?

  46. Pratik Jain says:

    Nice article.
    Adding some example, hope till will support the article.
    There are four kinds of Class relationships

    Association: uses a
    Ex:a Class Man uses a Class Pen
    Aggregation: has a
    Ex:a Class Man has a Class Car ( Car is still there when Man die )
    Composition: owns a
    Ex:a Class Man owns a Class Heart ( When Man die, Heart die )
    Inheritance: is a
    Ex:a Class Man is a Class Human ( Man is a Human )
    A relationship between classes of objects


  47. Priyabrat says:

    I Think U are right Hikmat.

  48. Hikmat Jaber says:

    In defining the Composition in top of page, I think the sentence should be
    “…, if the container object cannot exist without the existence of contained object, then it is called composition”
    instead of “…, if the contained object cannot exist without the existence of container object, then it is called composition”

  49. nitish says:

    very lucid and helpful. thank you.

  50. Ganesh says:

    ijust hv a doubt about composition ,as a example “A circle is composed of points”.
    then i think points are exist without circle ,,but according to u points r not exist without circle ..plz explain.?

  51. Abdul Hadi Ibrahimi says:

    I love your blog and find helpful…thanks for your great passion! You people make the world really great!

  52. Pavan says:

    Nice Article Joe

  53. Anonymous says:

    nice explanation..

  54. Ganesh says:

    Thanks a lot Joe, Very Useful information with simple language and good examples.

  55. SanjayK says:

    Thanks a lot for such an easy explanation. Examples are also easy to understand and correlate.

  56. Ravi says:

    give me answer plz..
    Justifying the statement ,”inheritance is a special case of Generalization”.

  57. zeeshan says:

    Very nice content. I like it. The best site and very comprehensiveness information I ever found.

  58. Gajendra says:

    Nice explanation yaar

  59. VVV says:

    Good explanations….

  60. Mohammad Arif says:

    Thanks very much nice information about Generalization, Aggregation, Association, Composition, Dependency,, only one time i have refereed to it but absolutely i got******

  61. sourabh singhai says:

    good site thanks

  62. sabarish says:

    Thanks for your inputs

  63. SAGAR_D says:

    GOOD and NICE and SIMPLE Explanation……..

  64. Rupesh says:

    Great and a very simple way to explain a confusing subject. Thanks a lot for this Post.

  65. priya says:

    nice explanation. very useful. thanks

  66. YoFo says:

    Good Summary. Thanks a lot!
    A simple class diagram to explain the direction of the relationship would be great, if can be added

  67. himanshu says:

    please explain more sir,with example..

  68. samy says:


  69. venky says:

    really helping me a lot….
    u r dng a great work.Thank You

  70. Nikhil says:

    Really good man easy to understand

  71. Pradip Lavania says:


    Superb Explanation sir .

  72. Rohit Ojha says:

    Nice way of information.

  73. Anonymous says:

    really clears the confusion.

  74. TSKarthic says:

    Wonderful Job Joe. Keep it up.

  75. Chandra says:

    Good article. One of the questions mentioned above, was related to manager,supervisor and staff. Certainly there is a generalization relationship with Staff as superclass and manager and supervisor classes are subclasses inheriting from Staff. Though attributes could be same in manager and supervisor when it comes behaviour(methods) manager and supervisor classes are specialized with inheriting the generic class i.e., Staff.

  76. Joe says:


    I feel very happy when I get to know that my blog helps a student.

    More than anything, I maintain this to help students succeed in their exams / interviews.

  77. Sanchit says:

    Thanks..!! M sure your examples gonna help in tomorrows exam.

  78. bluepicaso says:

    Nice one
    thank you

  79. jay says:

    identify in detail association and aggregation

  80. siva says:

    Very good explanation

  81. Subir says:

    Really simple and excellent explanation. Easy to understand for beginners…!!!

  82. Imrana Aminu Muhd says:

    1. Identify and briefly explain the objectives, classes, method and attributes for a hotel reservation system.
    2. Draw a use cases diagram to represent a hotel reservation system.
    3. Draw a class diagram that models hotel reservation system data structure, clearly representing the objects, classes, associations, generalization and aggregations.


  83. Imrana Aminu Muhd says:

    1. Identify and briefly explain the objectives, classes, method and attributes for a hotel reservation system.
    2. Draw a use case diagram to represent a hotel reservation system.
    3. Draw a class diagram that models hotel reservation system data structure, clearly representing the objects, classes, associations, generalization and aggregations.


  84. Arvind kumar says:

    Very nice explanation about class diagram terms…

  85. mayur bhalekar says:

    very nice artical!!

  86. Anonymous says:

    A very good explanation..I never seen before like this type explanation about this concept

  87. cheng kuyleang says:

    Thanks you very much for share good knowledge for me .

  88. CT says:

    Hi, may I seek a clarification about generalization concept. Let’s say I have a two kinds of staff, Manager and Supervisor and both have the same attributes (name,contact number). So, is it possible to say that this has a generalization relationship – Staff as the superclass, Manager and Supervisor as its subclasses althought there’s no difference in terms of the attributes between Manager and Supervisor?

  89. abi says:

    Very nice post.. i have never experienced such
    simple examples for explaining such complex terms like aggregation and composition
    i thought so far.. Keep posting…

  90. Arun K Deo says:

    You mentioned in this article – Abstraction is specifying the framework and hiding the implementation level information. Abstraction never says about hiding anything. Let’s take an Example of Employee with Super class and Manager and Salesman bening subclass of Employee. So if Employee may provide various implentation in common, but can’t have implementation for calculateBonus because this is fully dependet on nature of employee subclass, and hence Employee would have calculateBonus as abstract. So overall, abstraction is isolation of common essentioal behaviour and supress unimportant behaviours. Abstraction never meanse hiding anything. Hiding of implementation from accidental access is Encapsulation.

    Arun Deo

  91. Chandraprakash says:

    Nice explanation on the topics of association, aggregation and composition with quite undrestandable language.

  92. Mani says:

    Dear sir, I need more explanation and example about abstraction… How to apply in c…? i use data structure linked list concept..

  93. Ramyashree says:

    very good explanation on composition and aggregation relationships

  94. NextGeneration says:

    Nice Article, Much useful for a beginner

  95. Prakash says:

    Superb Article !!!!!!!!!

  96. Om Behera says:

    Nice Article Joe..Like very much the way you describe ,Must say Very good Article for the beginners …!!!

  97. shubh says:

    explanation also easy for preparing answerssssssssssss

  98. shubh says:

    it is so easy and interesting

  99. Kintesh says:

    thanks for simple explanation of association, aggregation, composition. Good Work…Thank you..

  100. Anonymous says:

    Very Good article… Thank you..

  101. Thirupathi says:

    nice explanation.. thiru

  102. Zahid Nasim says:

    Thanks dude.. its really so simple to understand these stuffs…….. really gr8 work.

  103. Ramakrishna Chandragiri says:

    Useful information with good explanation well done Joseph..

  104. mowlika says:

    it helped me alot sir………thank u sir

  105. pravinth says:

    Good Artcile. it helps.. Thanks..!

  106. Baravil Barivare says:

    This article is very helpful and well explained. Thanks

  107. niranjan says:

    simply super….very useful Thanks for posting..

  108. Parmod says:

    Very easily explained and easy to understand all the definition. Keep it up

  109. Girish Varma says:

    multiplicity is no given here :) pls add


  110. Varma says:

    could you please provide some code samples for association, aggregation and other all oops concepts.


  111. Rajasekhar says:

    thanks much. very useful information

  112. ankana says:

    thankz sir , very nice content

  113. KARTHIKEYAN A says:

    Wow., Awesome work., Thankz,
    Keep up the Good work.,

  114. ray says:

    thank you for you very clear work joe.

  115. Su says:

    Very nice article. I am facing a unique situation where we have modeled a test case with two compositions between the same two entities. Is this realistic? If so, can you give me a real world example for this?

  116. sadish says:

    Great Work !!!
    Keep going on !!!

    All the best !!

  117. sambha says:

    simple and understanble…
    Thanks a lot

  118. kondalarao says:

    it is simple and very easy to understand
    thank you,

  119. viji says:

    Nice.. Thank You..

  120. Prabhat says:

    Very nice page.
    It contains all required information about association, aggregation, composition.
    thanks a lot.

  121. Kareem Afifiy says:

    Thanks for these information. Great definition for aggregation n composition

  122. Sanjay Upadhyay says:

    I was always get confused for these relationship but as you defined these relationship it became easy to understand. Thanks buddy :)

  123. Vijay Agalcha says:

    thank you very much for sharing your knowledge. very useful content. I learnt the concept very well to be applied in OOAD.

  124. kamatchi sundaram says:


    The definition given in this site is very clean and neat and simple and very understandable instead of blah..blah…

    Cheers !!!

  125. Abhijit Boruah says:

    jst superb…think u r bst faculty for starters..i bliv in it…”with strong foundationz u can aim for the sky.”

  126. RenuNaidu..... says:

    i searched most of the definitions for these association,aggregation and composition…u cleared my doubt …u people are explaining like baby feeding thank you……

  127. Chetan Jadhav says:

    Terse explanation of Association, Aggregation and Composition..!!! :) Thanks a lot… :)

    Looking forward for your next posts…

  128. Narayan says:

    Good explaination mate

  129. Casper says:

    Thank you for addressing all relevant items.. little bit more code would be marvelous. still great. CDW

  130. Salman Khan says:

    Thank You Very Much… It Was Very Helpfull…

  131. Amit Shekhar says:

    Thanks Joe for the wonderful post. It is really quite useful.Most of the times we tend to get confused with these terms as all sound the same. Few more additions would make it better:
    a) Class diagrams
    b) Code for Aggregation and Composition

  132. Mutayyab Shah says:

    Sir. i m n trouble..if u post full code .which contain aggregation and compostion.then it will be very clear to all of us.according to programing point of view.
    and realy good work u have done.we appriciate ur work…
    plz post full code waiting 4 ur reply

  133. swathi says:

    Hi ,

    thnaks for that information.

    but i think i havnet understand that last.(Dependency)
    does it comes with arrow or just —- lines. pls post me

  134. Prashant S Shivashimpi says:

    Really very good and straight forward description about the Association, Aggregation, Composition, Abstraction, Generalization, Realization, Dependency. Thank you so much..

    Its very handy too..


  135. Joe says:

    Thanks Jyotilal for the aggregation example. Actually its otherway around.

    A car has a stereo system. A stereo system can exist without a car. There exists aggregation between car and stereo.

    Don’t go too technical into electronics and say a car stereo needs a car. Just for an example!

  136. Jyotilal says:

    An example for aggregation is missing and it could be like:

    A car has a stereo system.A car can exist without a stereo system. There exists aggregation between car and stereo.

  137. himanshu says:

    very nice content to start


  138. Rajesh says:

    Thank you..
    Looking forward for your next post…

  139. Gift vincy says:

    Now these basic can be easily differentiated, after read this post

Comments are closed.