• 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

Variable assignment or Calculation in Sequence Diagram

 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Except for creating notes, is there a way to show the assignment of a variable in a sequence diagram? There are no method calls just

int a = 0;

Thanks

Mark
 
Bartender
Posts: 1205
22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mark Spritzler:
Except for creating notes, is there a way to show the assignment of a variable in a sequence diagram? There are no method calls just

int a = 0;

Thanks

Mark



Normally I don't use a Sequence Diagram at this level of detail. But if that's what suits your needs, who am I to stop you?

Anyhow, I would treat a variable assignement just like a an object sending a message to/calling a void method on itself. In both cases, the side effect is what's important and the return value is ignored.

Look at this image from the IBM page on UML 2.0 Sequence Diagrams:



I would just put "a = 0" where they have system:ReportingSystem calling determineAvailableReports() on itself.

If anyone complains about this bastardization of the spec, just explain that putting "a=0" code inline is better than declaring a setA() method and using it just so that you have a real method name to put in the Sequence Diagram.

Does this sound reasonable?

Ryan
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd go with the note, if I really had to show it.

Are you sure that a sequence diagram is the right way to go in your case? Sometimes a little bit of pseudo code simply makes more sense...
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ilja Preuss:
I'd go with the note, if I really had to show it.

Are you sure that a sequence diagram is the right way to go in your case? Sometimes a little bit of pseudo code simply makes more sense...



Actually, I ended up only having it in one place, and I used the note.

I wanted this because I will use the variable in other calls and I don't want the reviewers coming back and asked where did this variable come from.

I would just put "a = 0" where they have system:ReportingSystem calling determineAvailableReports() on itself.



Yes, but that is still a method call. The note will work for my purposed for now.

I am creating the sequence diagram from psuedocode.

As far as going into this detail. I really prefer doing my coding while in design via sequence diagrams rather than in the coding phase. Then the coding phase is simply typing, and some minor refactoring.

Mark
 
Ryan McGuire
Bartender
Posts: 1205
22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ilja Preuss:
I'd go with the note, if I really had to show it.



Why? Isn't a simple variable assignment more conceptually similar to a method call than to the type of stuff that normally goes in a note? For example, on the Sequence Diagram page at agilemodelling.com there's this pic:



The Build SQL Select action that Persistence Framwork performs on itself is far from formalized method calls that one often sees on a Seq Diag. It seems to me that in terms of formality a simple variable assignment would fit in between what's on the IBM picture I included above and what's on the Agile Modelling picture here. What is it about a variable assgnment that would make you put it in a note? i.e. Isn't a variable assignment an action that an object performs, which is what the arrows in a Seq Diag are explictly for?

Granted, a Sequence Diagram can be used for different purposes and at different points in the development process. But it seems to me that the same type of action (var assignment) would be shown with the same type of graphical element (arrow or note) regardless of the context in which the diagram is used.

(To be honest, this 15% "I think I'm right and I want you to agree with me," and 85% "I don't understand and want to learn from someone who may be considering things I missed.")

Thanks,
Ryan
[ March 23, 2005: Message edited by: Ryan McGuire ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I'd think that there should be a construct for assignment, but there isn't in UML 1.4 Sequence diagrams. Those arrows are all method calls. If I put an arrow using Together and type in "a=0" It would either give me an error or try to create a new meethod called "a=0()".

Mark
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ryan McGuire:
Isn't a simple variable assignment more conceptually similar to a method call than to the type of stuff that normally goes in a note?



I see notes quite often used for pseudo code, for example in the patterns literature.

Anyway, to me it would be more important what communicates better, and I guess most of my coworkers would understand the note more intuitively than the pseudo method call.

Isn't a variable assignment an action that an object performs, which is what the arrows in a Seq Diag are explictly for?



I'm not sure about the official definition, but to me an arrow implies some form of transfer of control.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mark Spritzler:
Well, I'd think that there should be a construct for assignment, but there isn't in UML 1.4 Sequence diagrams.



Mhh, I on the other hand don't miss it. Probably a case of http://www.martinfowler.com/bliki/UmlMode.html

Those arrows are all method calls. If I put an arrow using Together and type in "a=0" It would either give me an error or try to create a new meethod called "a=0()".



I was close to writing that I think optimizing diagrams for both communication to humans and code generation is unlikely to work. Then it occured to me that I actually think it *can* be made work for code - so why not for diagrams? Now I'm confused...
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mhh, I on the other hand don't miss it. Probably a case of http://www.martinfowler.com/bliki/UmlMode.html



Great link. That explains it all. I am on the UMLasBlueprint page.

Mark
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
UmlAsSketch here...
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ilja Preuss:
UmlAsSketch here...



You say Tomato, and I say Toemaatoe.

Mark
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic