开发者

Difference between has-a and composed-of?

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:

Difference between has-a and composed-of?


(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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜