If I have a class "Foo" that contains an instance of "Delegate". Foo delegates method calls to class "Delegate" like so:
public class Foo {
private Delegate delegate = new Delegate();
public void bar() {
delegate.bar();
}
}
When I draw the Foo class in UML, would it have a dependency relationship (dashed line with an arrowhead) between it and the Delegate class, or would it have a line representing a Composition relationship instead?
The nice thing about UML is that you have some leeway, but in your case, IMHO, dependency is better.
You don't have a delegate
as a property of a Foo
(there is no getDelegate
) so no one looking at your system would really care that a Foo
was composed of a delegate (among other things).
Then again, if your UML diagram was given to a tool that would generate code from a diagram, it might. :)
Do what feels right to the people (or agents) to whom you are giving the diagram.