开发者

when do we draw association?

Class Engine has "start(c:Component)" method. So do we need to draw an as开发者_如何学JAVAsociation between Engine and Component Class IF there is no "new Component()" inside Engine class.


No, you do not in general need to have an association to a type even if the type is mentioned in a parameter. It entirely depends on if the state of an Engine maintains a relationship with one or more Components.

If the Component you passed around is only use locally in method start, then there is no real association that persists from one state (one method call) to the next.


This is not an association, it´s a dependency relationship between the two. A dependency means that if the dependee (the Component in your case) changes the depender (the Engine) may become affected (maybe Engine::start was using a Component method that it is no longer available or that has changed its parameters)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜