[英]UML Class Diagram: Object passed through constructor relationship?
Suppose I have a class like this in Java:假设我在 Java 中有这样的 class:
public class ClassA{
public ClassA(ClassB b){
// do some operations or get some values etc. from ClassB b
ClassB is passed to ClassA through its constructor. ClassB通过其构造函数传递给 ClassA。 (not a method) Is this relationship considered a dependency or some form of association?
(不是方法)这种关系被认为是依赖关系还是某种形式的关联? If we were to assume that there is no ClassB attribute in ClassA.
如果我们假设 ClassA 中没有 ClassB 属性。
This would normally be a dependency or 'uses' relationship.这通常是依赖关系或“使用”关系。 Association implies a 'has-a' relationship.
关联意味着“有”的关系。
If an instance of ClassA keeps the passed instance of ClassB, then model as an association.如果 ClassA 的实例保留传递的 ClassB 实例,则 model 作为关联。 Otherwise, model as a dependency.
否则,将 model 作为依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.