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.
views:
138answers:
1
+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
.
Bert F
2010-04-22 23:42:54
Thanks so much, that helps a lot.
Martin Doms
2010-04-22 23:46:08
@Doms - Glad to help
Bert F
2010-04-23 00:23:41
hehe, what a beatiful diamond:)
Gabriel Ščerbák
2010-04-23 10:50:26
@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
2010-04-23 13:11:45
@Bert F I was trying to hint at the diamond inheritance problem:)
Gabriel Ščerbák
2010-04-23 13:15:28
@Gabriel - lol - I'm dense. Doesn't apply to Java interfaces though, right?
Bert F
2010-04-23 13:34:52
@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
2010-04-23 13:40:18
@Gabriel - very interesting! I wasn't aware of that issue. Thanks for the pointer.
Bert F
2010-04-23 15:56:36