The use of an object by other objects is very common in POO. This behavior is classified as relation, whose behavior will be determined by specific classifications. Association, aggregation and composition are names used to classify the type of relations between objects and each of them will be explained below.

Objects that work by association use one another. This type of relation is the most common. Each one of them works independently, but associate with another one in order to perform a certain task. A driver of a car, for example. The driver and the car exist independently, but combine to make the car function.

In the aggregation, the behavior is slightly different. In this case, an object adds another object, such as a parent object. Thus, the parent object begins to utilize the features of the aggregate object. Still, both objects can exist independently. For example, a lid adds a pan, but the lid and the pan may still exist without depending on the existence of one another.

In the composition, the behavior changes completely. An object becomes dependent on the other to exist. The parent object is responsible for the creation and destruction of child object, which shall be responsible for the instance of its parts. In this example we can mention the wheels of the bike – the bike can only exist if the wheels exist.

These classifications help the interpretation of various diagrams, thereby allowing the reading and understanding to be facilitated.

In the class diagram, for example, those relations are marked in form of UML, thus allowing the reader to understand in few minutes all the logic that was used in the creation and implementation of objects. In the case, representation by lines indicates the type of relationship between objects:

  • Straight line: indicates Association;
  • Line with cutting of empty lozenge: indicates Agregation;
  • Line with cutting of filled lozenge: indicates Composition.

Check out more content on our blog!
Learn all about Scriptcase.

By ,

June 12, 2015


You might also like…

12 IT Trends to Keep an Eye on in 2023

The year 2023 has already started in full swing bringing news and projecting trends for the web dev...

Low-code: it’s the future, not a passing trend

Low-code tools enable professionals to develop fast, efficient, and precise systems. Low-code ha...

What’s new in PHP 8.1

In this article, we will talk a little about the new features, changes, and improvements coming wit...

You might also like…

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at Learn more about our Privacy Police.