Search code examples
javadependenciesumlaggregationcomposition

How to represent the Java "this" keyword in a constructor using UML


Say we have:

class A {
    A(B theB){
    }
}

and

class B {
    B() {
        A theA = new A(this);
    }
}

How should the relationship between A and B be represented using UML?


Solution

  • This is nothing else but a cross-over dependency.

    enter image description here

    If you were to hold a property of one class in the other you would show that as association. But in this case it's just a dependency.