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.

association

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.

composition

You might also like…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

Comment this post

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.