File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes UML diagram of a Java Servlet API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "UML diagram of a Java Servlet API" Watch "UML diagram of a Java Servlet API" New topic
Author

UML diagram of a Java Servlet API

Sergei Zhylinski
Ranch Hand

Joined: Nov 15, 2013
Posts: 67
    
    1
Hello,

I've found a brief UML class diagram for a Java Servlet API. And I wonder wether this diagram is correct. Specifically I would like to clarify association relationships.

Firstly, the know and unknown classes in an association. For instance, look at the association between classes "ServletOutputStream" and interface "ServletResponse". It is uni-directional association. According to this article, a "uni-directional association is drawn as a solid line with an open arrowhead (not the closed arrowhead, or triangle, used to indicate inheritance) pointing to the known class". Therefore, the known type in our case is "ServletOutputStream". Lots of books (particularly, UML Distilled by Martin Fauler) say that association relationships are realized as fields in source code. And thats why, following the logic, class "ServletOutputStream" should contain the reference to a "ServletResponse" instance. But, on the contrary, "ServletResponse" has a getter for a "ServletOutputStream" (getOutputStream()).
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

Howdy, Sergey!

Indeed, I too think this diagram is wrong. In the case of the ServletOutputStream -> ServletResponse relationship, I think I'd go with the dashed arrow from ServletResponse to ServletOutputStream, so it would be ServletResponse ------> ServletOutputStream. Although an interface cannot hold state, it would mean that the concrete classes that implement ServletResponse would depend on ServletOutputStream (well, in this case, the interface itself also depends on ServletOutputStream, because a method in it returns ServletOutputStream). And the relationship would be represented by the dashed arrow because this means dependency, which is used in cases where a class depends on another, for instance, when a method on class A returns class B, or class A receives class B as parameter on a method, etc.

There are other mistakes, like the relationships between ServletConfig, ServletContext and RequestDispatcher. It's the other way around, and I think I'd go with dashed arrows too.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Sergei Zhylinski
Ranch Hand

Joined: Nov 15, 2013
Posts: 67
    
    1
And I would choose aggregation from interface "Servlet" to interface "ServletConfig". I've opened the source code of the servlet api:



Am I right?
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

Correct!
Sergei Zhylinski
Ranch Hand

Joined: Nov 15, 2013
Posts: 67
    
    1
Roberto Perillo wrote:Correct!


I've recently accomplished my own UML class diagram. Could please look at it?



[Thumbnail for Servlet_API_class_diagram.png]

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: UML diagram of a Java Servlet API