Question about implementation relationships between classes. In PHP. It's known that every aggregation is association. But not every association is a aggregation. But what is the difference between them? In terms of implementation.
Of course, there a lot of similar questions and answers.
Here're some answers. But they are almost without some code.
Here're some answers also, with code.
For example, association:
public class Foo {
void Baz(Bar bar) {
}
}
Aggregation:
public class Foo {
private Bar bar;
Foo(Bar bar) {
this.bar = bar;
}
}
However, "If that's the case, both Association and Aggregation code are same. In both cases, 'bar' is just referenced and Bar object may live on". Seems a little bit confusing.
Another example. "Aggregation [...] is the typical whole/part relationship. This is exactly the same as an association with the exception that instances cannot have cyclic aggregation relationships (i.e. a part cannot contain its whole)". Is this the only one difference?
Can you give some example in PHP, showing the difference?
Thanks!