• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

sequence diagram

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have an interface A with one method M(). I have two classes A1 and A2 which implement interface A.
So the logic is


How do I show this in the sequence diagram?


Thanks
Tanveer
[ July 08, 2008: Message edited by: Tanveer Ahmad ]
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could simply use the interface class. Whatever class contains the logic for creating an instance of A will contain two arrows to the time-line of the interface class. The first line will indicate the instantiation and the second line will indicate the call to method M().

If it is important to detail both sequences of when the condition is true and when it is false, you would create two sequence diagrams (one for each case). In these diagrams you would use the actual concrete class instead of the interface class. You could add a stereotype to the class indicating that it is an instance of A with <<A>> (a nice touch).
Note, you have to determine whether this detail is important enough to include on your diagrams. Personally, I don't think so.

Also, the way you are creating the objects should be looked at again. In your example, you have a significant syntax-level dependency upon the class name. Very Bad! I suggest you read up on the Creational object-oriented design patterns and rethink how you create objects.

Good luck!
[ July 08, 2008: Message edited by: James Clark ]
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can display both case in the same sequence diagram. you can attach a note or with uml2 you can have a frame with the label "alt" that represents a conditional logic.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. This piece of code is too trivial. It does not have to appear in your sequential diagram.
2. The creation part shall be in an AFactory class. And you can just show A and AFactory in your diagram, as no matter what kind of A it is, you use it in the same way anyway.
3. If you really want to show the branch logic, use UML2's "alt" frame.
 
Tanveer Ahmad
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Thanks a lot for your replies. I agree, I should be using a Factory instead of that code. But it again brings to same point. There will be an interface AbstractFactory which will be implemented by ConcreteFactory. Now my client class will have something like


How do I show this in the sequence diagram?

Thanks again for clearing all my doubts.
Tanveer
 
giuseppe fanuzzi
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you've to show only the interface in the sequence diagram. you can have another sequence diagram or class digram in which you show the classes that realize the operation
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Example




[ July 09, 2008: Message edited by: James Clark ]
 
giuseppe fanuzzi
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can do in this way:


---------------------------- ----------------------------
| | | |
| | | |
| y : YClient | | x : Manager |
---------------------------- ----------------------------
| |
| new() |
|----------------------------->|
| |
| XObjectFactory |
|<-----------------------------
 
giuseppe fanuzzi
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry
you can do in this way:

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
mmm... why are you so interested to show the interface classes in your sequence diagram? your seq. diagram should show the interaction between objects of certain classes, it doesn't need to reflect your class diagram on it.

So, you will not add that complexity to your seq. diagram. the developer will not look for inheritance in this diagram, he will look at the class diagram to create the classes, and then use the seq. to develop the methods.
[ July 10, 2008: Message edited by: Juan Pablo Crossley ]
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic