What is simple association in object orientation?

5

1 answer

6

In fact, all relationships are associations , what will differentiate one from the other is the participation of objects in the context of the application.

For example:

The fact that the object rotates, is available in a store, features a simple association, a store could have N wheels, sell these wheels, and the store continues to exist, waiting to receive more wheels in stock.

If this wheel is in the car, it is an aggregation, the car has wheels to run, and there is no car that runs without wheels, for now.

If the wheel is in a shopping cart with other products, it is a composition, the cart exists because of these products, which can be from 1 to N objects, cart depends on the objects to exist, this is the purpose of it, load objects.

Explanation:

If an object can be a thing in a particular context, then the context is a simple Association.

If an object has a thing, whether it is an object or not, then the context is an Aggregation.

If an object is a thing or part of a thing , then the context is a Composition.

Object orientation is a programming paradigm where N objects collaborate with their functionalities so that we have an application, objects make up the orientation to objects, so that if you have only 1 object, you do not have an application oriented objects. Objects need to relate to each other. This relationship of objects is called association. Some associations are stronger, others are weaker. To know what kind of relationship each is, or should be, we need to identify the functionality of each object in each relationship.

    
31.07.2014 / 13:07