开发者

Difference between has-a and composed-of?

开发者 https://www.devze.com 2022-12-28 02:59 出处:网络
In OOP modeling, is there any distinction between a \"has-a\" relations开发者_Python百科hip and a \"composed-of\" relationship?Both statements usually mean composition.

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

精彩评论

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