Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to show multiple stereotypes?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

As you know, we could use stereotype to show the stuffs like "Entity", "Stateless Session Bean", "Session Facade" and etc... My question is that how shall we show multiple stereotypes in Class Diagram, like a class is both a "Stateless Session Bean" and a Session Facade.

Thanks!
 
Yi Chen
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, how do you show an EJB or JPA Entity in Class Diagram? I'd like to use stereotype. What about you guys?

Thanks!
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used @Entity as stereotype to show a JPA entity and use of annotation.

P
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Yi,

Stereotypes are an extension to the UML language and are terms coined and used by Designers and architectst to express the design in a clear and concise manner .(we will get back to the reason for this definition in just a bit)

In my experience i have never seen a UML element annotated with two sterotypes, so i am not sure if its valid UML - as far as i remember each UML element can have only one stereotype (do confirm this though). If we look at your problem where you want to use two stereotypes on the same class to make your intent more explicit, i see it the following way (going back to the original intent of stereotypes) -

  • The stereotype <<StatelessSessionBean>> adds to the definition of the bean( it helps characterize the bean further).Hence use this stereotype in the class diagram.


  • The stereotype <<SessionFacade>> helps define the role of the bean( it helps define the role the bean plays in the scheme of your sequence).Hence show it in the sequence diagram.


  • I would love to hear opinions on this suggestion.

    Cheers
     
    Yi Chen
    Greenhorn
    Posts: 27
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you all.

    Rahul, you suggestion give me a fresh angle to see this question.
     
    Ranch Hand
    Posts: 1936
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    What is the tool you're using? Didn't it display comma when you applied multiple stereotypes to a class?
     
    Ranch Hand
    Posts: 33
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hello Yi,

    I do not remember the specs, but I do not think that there is a restriction of a number of stereotypes you can use on a single class or component of your diagram.


    As you know, we could use stereotype to show the stuffs like "Entity", "Stateless Session Bean", "Session Facade" and etc... My question is that how shall we show multiple stereotypes in Class Diagram, like a class is both a "Stateless Session Bean" and a Session Facade.



    Just show both stereotypes.


    Also, how do you show an EJB or JPA Entity in Class Diagram?



    As it was already proposed by others - define your own stereotype and use it on your diagram.

    Janis
     
    Rahul Mishra
    Ranch Hand
    Posts: 211
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Then i stand corrected..

    thanks janis
     
    Yi Chen
    Greenhorn
    Posts: 27
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Janis Kazakovs wrote:

    I do not remember the specs, but I do not think that there is a restriction of a number of stereotypes you can use on a single class or component of your diagram.

    Just show both stereotypes.



    Thanks, Janis. One question - How to show multiple stereotypes? separate them by comma? or anything else? My UML tool doesn't support multiple stereotypes. But I think stereotype is very flexible. Separating them by something like comma could be fine. But I won't do this unless I don't have other choices....

     
    Janis Kazakovs
    Ranch Hand
    Posts: 33
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ok, I looked in specs (after such a long time). There what it says:


    If multiple stereotypes are applied to an element, it is possible to show this by enclosing each stereotype name within a pair of guillemets and listing them after each other.



    This means that you should specify multiple stereotypes on one class as follows:
    <<StatelessSessionBean>>
    << SessionFacade>>

    However, specs also say that

    A tool can choose whether it will display stereotypes or not.



    So, it is normal that your tool does not display multiple stereotypes.

    I found another example in specs that presents multiple stereotypes separated by comma, so your assumption was correct. As I understand, in your case you can use the following notation:
    <<StatelessSessionBean, SessionFacade >>
    which should be also correct.

    Janis
     
    Yi Chen
    Greenhorn
    Posts: 27
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Janis,

    Thank you very much for your investigation! Really appreciated!
     
    Ranch Hand
    Posts: 123
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I tend to subscribe to the view that multiple stereotypes can be included in the same guillimets, separated by comma(s), since I have noticed this quite often.

    Is there any differing opinion?
     
    knowledge is the difference between drudgery and strategic action -- tiny ad
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
      Bookmark Topic Watch Topic
    • New Topic