0
Dependency vs Composition
I'm confused between the differences in the two of them, as I see both of them naket an instance of another class inside them... So how are they different?
3 Respuestas
+ 2
The two are often very similar. The main difference you'll usually see is that with Dependency, the instance creation of the other class will take place outside of the encapsulating class and is passed in, usually via the classes constructor. With Composition, the instance of the other class is created within the encapsulating class itself, again usually in the constructor, but may also be done within a method or as a field.
+ 2
Here, maybe this will explain things better than my attempt.
https://www.google.com/amp/s/nirajrules.wordpress.com/2011/07/15/association-vs-dependency-vs-aggregation-vs-composition/amp/
0
ChaoticDawg but then dependency looks like an aggregation since you do the same thing you described for dependency