开发者

java class relations,Generalization Realization Association Aggregation Composition Dependency

开发者 https://www.devze.com 2023-04-11 19:45 出处:网络
here are some question after I have looked at wikipedia: Association: \"Association represents the static relationship shared among the objects of two classes.\", does this mean aggregation and compo

here are some question after I have looked at wikipedia:

Association: "Association represents the static relationship shared among the objects of two classes.", does this mean aggregation and composition can be also describe as association?

Aggregation: "However, an aggregation may not involve more than two classes", what does it mean? say a class "has a" professor, and a class "has a" teach-assistant. a professor also "has a" teach-assisitant, isn't this also aggregation, and it involve more than two?

Dependency: as long as two classes 开发者_开发知识库are related, can be described as dependency? am I right?


Association: "Association represents the static relationship shared among the objects of two classes.", does this mean aggregation and composition can be also describe as association?

-Yes, Aggregation is an Association which denotes an "is part of" relationship and Composition adds a lifetime responsibility to Aggregation.

Aggregation: "However, an aggregation may not involve more than two classes", what does it mean? say a class "has a" professor, and a class "has a" teach-assistant. a professor also "has a" teach-assisitant, isn't this also aggregation, and it involve more than two?

--aggregations are not allowed to be circular.In your case, class and professor have a relation, class and TA have a relation, and TA and prof has a relation.

Dependency: as long as two classes are related, can be described as dependency? am I right?

-yes.

Also,you may like to read this: http://www.martinfowler.com/bliki/AggregationAndComposition.html

0

精彩评论

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

关注公众号