In OOP modeling, is there any distinction between a "has-a" relations开发者_Python百科hip and a "composed-of" relationship?
Both statements usually mean composition.
But it seems to me that composed-of always means composition while has-a sometimes can mean aggregation (but not in the picture below). In UML it looks like:
(source: atomicobject.com)
Not really, since both indicate that a parent object contains an instance of a child class. It's mostly a semantic difference where "has-a" represents an association between two different objects, where "composed-of" indicates that the child is an integral part of the parent.
精彩评论