29

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.

1 Answer 1

41

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.

7
  • 5
    hehe, what a beatiful diamond:) Commented Apr 23, 2010 at 10:50
  • @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
    Commented Apr 23, 2010 at 13:11
  • 4
    @Bert F I was trying to hint at the diamond inheritance problem:) Commented Apr 23, 2010 at 13:15
  • @Gabriel - lol - I'm dense. Doesn't apply to Java interfaces though, right?
    – Bert F
    Commented Apr 23, 2010 at 13:34
  • @Bert F I was not sure myself, according to this: <a href="java.sun.com/docs/books/jls/second_edition/html/… 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. Commented Apr 23, 2010 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.