I've always had a problem understanding the difference between an association and an aggregation.
Curiously, the difference between composition and aggregation never caused me any problem. You just have to think that when the "whole" gets deleted; if the "parts" still exist then it is a aggregation, if they also get deleted then it is a composition.
Back to the problem: in theory I knew that an aggregation represented an "has a" relationship, but as most of my classes had many other classes as attributes I thought it was strange that all of them were represented by a aggregation relationship.
After some research these are my conclusions:
- If you have another class as an attribute then you do have an aggregation (or composition) relationship.
- An association means that a class "uses" the other class (like in a parameter of an operation).
Here is an example I've done to demonstrate it better:
As it is possible to see, the motor doesn't have any "has a" relationship with the fuel class. It only uses it in a operation to accelerate the motor, therefore it is a association relationship. The same happens to the association between the Fuel class ant the FuelPump class. In this case the Fuel class is present in the return type for the accelerate operation.
Just a practical rule to never forget (a little of topic): If in the code you change a class, the only classes affected by this modification are the ones that have any relationship with the modified class.