Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

UML diagram of a Java Servlet API

 
Ranch Hand
Posts: 89
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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()).
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sergei Zhylinski
Ranch Hand
Posts: 89
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correct!
 
Sergei Zhylinski
Ranch Hand
Posts: 89
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roberto Perillo wrote:Correct!



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

Servlet_API_class_diagram.png
[Thumbnail for Servlet_API_class_diagram.png]
 
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic