tags:

views:

138

answers:

1

In Java it's perfectly legal for an interface to extend an interface. Does this relationship in UML look like an "extends" relationship (solid line, closed, unfilled arrowhead) or an "implements" relationship (dotted line, close, unfilled arrowhead)? I can't seem to find an example of this relationship either online or in Fowler's book.

+2  A: 

Use "extends" (solid line, closed, unfilled arrowhead), which is consistent with how Java uses the extends and implements keywords.

  • "extends" == UML generalization / specialization relationship
  • "implements" == UML realization relationship

The sub-interface is a specialization of the super-interface, not a realization of it.

See http://www.informit.com/articles/article.aspx?p=29224&seqNum=2

Example of interfaces extending interfaces.

Bert F
Thanks so much, that helps a lot.
Martin Doms
@Doms - Glad to help
Bert F
hehe, what a beatiful diamond:)
Gabriel Ščerbák
@Gabriel - *heh* - it is a nice diagram. I wish I could take credit for it, but its from the referenced article, so credit to Stephen R. Palmer.
Bert F
@Bert F I was trying to hint at the diamond inheritance problem:)
Gabriel Ščerbák
@Gabriel - lol - I'm dense. Doesn't apply to Java interfaces though, right?
Bert F
@Bert F I was not sure myself, according to this:<a href="http://java.sun.com/docs/books/jls/second_edition/html/interfaces.doc.html">9.3.2.1 Ambiguous Inherited Fields</a> it is a problem, which at least gets resolved at compile time. But I have no idea if this holds for methods.
Gabriel Ščerbák
@Gabriel - very interesting! I wasn't aware of that issue. Thanks for the pointer.
Bert F