In the realm of OOP, inheritance, abstraction and polymorphism are basic concepts of the paradigm.
On top of that, there also have the concept called "associations" which I understand is that one object associates (uses) another object. There are also specialized forms of "associations" - aggregation and composition.
What I'm really confused about is that some sites on the Internet (even some university slides) mixing all these terms and sometimes refer "Inheritance", "Polymorphism", "Abstraction" as the associations.
So the relationships between objects forming because of "Inheritance", "Abstraction" and "Polymorphism" are included in the concept of "association" (or at least in terms) ?
-
1Association isn’t an OOP concept. It’s a UML concept.candied_orange– candied_orange07/06/2020 14:46:45Commented Jul 6, 2020 at 14:46
-
3I don't think the typical programmer sees inheritance, abstraction and polymorphism as forms of "association;" they see them as forms of abstraction.Robert Harvey– Robert Harvey07/06/2020 14:59:44Commented Jul 6, 2020 at 14:59
-
Aggregation and composition are definitely more proper examples of "association."Robert Harvey– Robert Harvey07/06/2020 15:05:10Commented Jul 6, 2020 at 15:05
1 Answer 1
What’s missing in your basic OOP features are not associations, but composition:
- object composition is a way to make more complex object structures
- object composition can often be a better alternative for inheritance (i.e. prefer composition over inheritance)
- object composition can be used to implement associations
Every OOP languages provides composition. None provides association. Associations are an abstraction of the way composition is used to connect objects.
Remark: the fact of using an object is not sufficient to make an association (see discussion here). It just creates a dependency.
Explore related questions
See similar questions with these tags.