In both association and aggregation, one class maintains a reference to another class.
Then, does constructor injection imply composition? Going by the same logic, is it safe to say that setter injection leads to an association, and not an aggregation?
An aggregation is merely another representation of an association. So setter injection leads to an association and aggregation -- as does constructor injection.
It's debatable as to whether constructor injection implies composition since, according to a strict interpretation of composition, the class itself must be responsible for both the construction and destruction of the composite class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With