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

a

You might also like…

“We have developed the Connected Citizen Card, which assists public administrators in decision-making and policy creation.”(Assist Soluções em TI)

Check below how Assist Soluções em TI used Scriptcase to modernize and streamline the development...

AI-Driven Software Development: The Role of ChatGPT

In the rapidly evolving world of technology, artificial intelligence (AI) is playing an increasingl...

Low-Code: The Key to Accessible Digital Transformation

Digital transformation is imperative for companies wishing to remain competitive in the current era...

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 sales@scriptcase.net. Learn more about our Privacy Police.