Author Topic: generate sequence diagrams from source  (Read 10425 times)

JohnDoe

  • EA User
  • **
  • Posts: 191
  • Karma: +0/-0
  • EA rocks !
    • View Profile
generate sequence diagrams from source
« on: December 11, 2006, 04:01:38 am »
Hello sparx-people,

I would like to auto-generate sequence diagrams by reengineering soure code (the same easy way like class diagrams are reverse engineered).
Alternatively: Adding especially formatted comments into the source would be an alternative to the automatic reengineering of sequence diagrams.

The languages I am using are: Actionscript, Python and Java.

Regards
Bernd
« Last Edit: December 11, 2006, 04:04:57 am by BerndWill »

Bruce

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: generate sequence diagrams from source
« Reply #1 on: February 04, 2007, 05:59:10 pm »
oh, I am regarding it...

I don't like the comment automaticly generated by it, that I want to change the format and content.

tomte

  • EA User
  • **
  • Posts: 35
  • Karma: +0/-0
  • Reverse Engineering
    • View Profile
Re: generate sequence diagrams from source
« Reply #2 on: February 06, 2007, 02:17:51 am »
I really appreciate that.

- offer two
  • trees of package.interfaces/classes.operations
    - developer draws edges from a classifier in the left tree
     to a method in the right tree each
    - developer selects the package where to generate the
     sequence diagram to
    - developer presses "Generate Sequence Diagram"

    ... would be very helpfull and not too hard to implement.

    Thanks in advance,
    tomte

tomte

  • EA User
  • **
  • Posts: 35
  • Karma: +0/-0
  • Reverse Engineering
    • View Profile
Re: generate sequence diagrams from source
« Reply #3 on: February 07, 2007, 12:53:55 am »
P.S.: I forgot the preselection aspect.

Auto-generating Sequence diagrams from non-trivial projects would be useless if all messages / method calls of the source code would be modelled into one or more Sequence diagrams, even if one could delete the non-interesting messages afterwards.

For a Sequence diagram we are interested in a typical (or in a special) scenario of a usecase. We usually can identify some few "classes of interest" and / or "methods of interest". These we need to elect / mark. (In contrast to my former posting: We need not draw edges between these candidates. That would be design and is supported by the tool anyway. Thereby we do not need two trees, but just one).

What we can get by electing / marking some "elements of interest" would be a (maybe still huge) Sequence diagram that we can refine by erasing arrows from the diagram (not from the model).

Sorry for the confusion, had been late ...
tomte

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: generate sequence diagrams from source
« Reply #4 on: February 13, 2007, 04:53:47 am »
Perhaps you'd be kind enough to share with us an algorithm for decoding an n-level recursive solution (e.g tower of hanoi) into a sequence diagram.  Or if thats too easy how about the "relaxed traveling salesman with holidays" solution.

In short I believe that what you are asking for is seriously impossible ( at least today  :) )

Sequence diagrams ellucidate the behaviour of a system in a particular state under a specific set of circumstances.  In order for a reverse engineering tool to create/design a complete set of behavioral models from a structural description (i.e code) it would need to understand and anticpate all possible states and environmental conditions that the system may experience.  If and when it could do that successfully neither you nor I would have any ecological use.  For then, not only could it RE it, but it could possibly FE it into sentient lifeforms that mey (probably) have no use for us.

Forgive me for the vitriol, but in three or more years of this forum I have seen the same question over and over again.  

"A" sequence diagram, regardless of the UML 2 enhancements, still cannot represent the behaviour of a system succintly and clearly for ALL possible behaviours.  To repeat myself again (tautologically speaking...) a sequence diagram is best used to investigate, analyse or resolve what the system should do under a given set of circumstances given that said system is in a particular state.  It is a design tool not a system descriptive.  

The structural description of a system i.e. the code, knows nothing of the environment is which it is operating.  I appreciate that this is a sweeping statement.  However, it is, or at least should be, a basic assumption for any developer.  Therefore, can I (the developer) anticipate the entire universe of input information and state conditions that may exist when (my) code is invoked?  From my (the architect's) perspective, not in my lifetime.  Moving on from that, are the expected outcomes of these unanticipatable conditions specifiable and realisable?  Not this side of the Styx.  

Consider this.  A web service class to return the current TOY from the operating system "clock" - no input parameters, output to be an XML document whose form is defined by a schema.  Simple eh?  Try it as an exercise.  In 20 seconds I can envisage 16 possible outcomes/behaviors.  

best wishes
bruce
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

tomte

  • EA User
  • **
  • Posts: 35
  • Karma: +0/-0
  • Reverse Engineering
    • View Profile
Re: generate sequence diagrams from source
« Reply #5 on: February 13, 2007, 06:13:44 am »
Hello Bruce,

it is not intended nor needed "for ALL possible behaviours" but e.g. for detecting how some crazy collouge implemented the non-documented Service Locator etc. That also caused me to add second reply regarding the necessary pre-selection.

As you may know the good old Together 6.x Control Center / Solo has such a feature since many years. This does not mean that it is absolutely necessary in Sparx EA too, but it might be possible.

The rest might be a discussion of priorities of features, not of solvability.
tomte



JohnDoe

  • EA User
  • **
  • Posts: 191
  • Karma: +0/-0
  • EA rocks !
    • View Profile
Re: generate sequence diagrams from source
« Reply #6 on: May 28, 2007, 01:09:58 pm »
Hi Guru,

extracting sequence charts by guessing the semantic is not an option at all. What I would like to do, is to give EA some concrete hints when it reverse engineers my source. I would like to add some sender/caller graph hints and when I draw sequence diagrams, EA should offer those sender/caller options while (re-)drawing.

I think it is a big topic in any project, if EA models and source start moving in two directions. But since EA is no source development tool, you have to switch to another IDE at some time of your project (e.g. when coding begins).

IMHO, after some days of coding, the source is where the logic lies and therefore i would want to update my EA diagrams by reverse enginnering, instead of redrawing those pictures permanently. Pictures and text is nice during design phase, but it is a mess to keep it consistent while coding.

Maybe EA can embed some descriptions about classes and diagrams into the source, that EA generates (e.g. putting ID's of objects into the comment together with additional information about methods, variables etc.). Then I would have the option to change these values and get an update of my sequence and class diagrams inside the sources.

It would be superb, if I could "redraw" my EA models by reverse engineering my sources.

Regards
Bernd

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: generate sequence diagrams from source
« Reply #7 on: May 28, 2007, 06:27:32 pm »
Bernd,

[IMHO...]

Perhaps this is where an add-in, with or without the EA integration tools for Eclipse or Visual Studio, would work. You'd likely be facing a fairly large front-end load to get something like this working, but the payoff could be huge.

To offset the development effort, you would have the opportunity to tune the application to your specific needs.

David
No, you can't have it!

tomte

  • EA User
  • **
  • Posts: 35
  • Karma: +0/-0
  • Reverse Engineering
    • View Profile
Re: generate sequence diagrams from source
« Reply #8 on: May 29, 2007, 08:59:26 am »
Quote
Pictures and text is nice during design phase, but it is a mess to keep it consistent while coding.

Hello Bernd,
this topic seems to be discussed periodically, e.g. in
http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=suggestions;action=display;num=1170758957
http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=suggestions;action=display;num=1162376357

Good luck,
tomte

JohnDoe

  • EA User
  • **
  • Posts: 191
  • Karma: +0/-0
  • EA rocks !
    • View Profile
Re: generate sequence diagrams from source
« Reply #9 on: May 29, 2007, 09:27:18 pm »
My personal opinion is, that EA should be able to extract diagram tips from the source. Today we have one model inside EA access database and another (the real) model inside the source. What happens is, that you have to update both of them and you also have to consider the constraints affecting other parts of the model.

a) if you go the XP way, you will start with test classes instead of UML models. And while you are testing and writing classes, you could embed notations into your sources. EA then would be a wonderful diagram viewer, if it could extract those graphical tips from the source comment. Optimistically, you would only open EA and import the sources and and get a full documentation generated from the comments. This would be an amazing feature for XP coders that no tool offers today !

b) If you start the classical way by drawing UML models, your source will eventually differ from the models and then you have to redraw the UML models all the time. If the UML models were part of the source comment, I would be able to reimport them and get my models updated. This would be a fantastic feature that no tool offers today.

Because of the semantic ambiguity of source (polymorphism etc.), I would suggest to rely on the comments inside the source instead of interpreting sources. These comments were either constructed by an EA source export or by the manual input of a programmer whild coding.

The idea behind this suggestion is, to spread the EA models content over the source comments when generating source.

Since these inline diagram tips are language independet, there is no need to reconcile that syntax with different programming languages.

Regards
Bernd

« Last Edit: May 29, 2007, 09:51:01 pm by BerndWill »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8597
  • Karma: +256/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: generate sequence diagrams from source
« Reply #10 on: May 30, 2007, 04:24:01 am »
At last...  Someone who understands...[size=13]VIT: Model<->Code Commentary & Metadata[/size]

You may want to continue this discussion in the other topic as it is more generic.

Paolo
[size=13][Edit][/size]Link fixed, thanks to Gary Wong
« Last Edit: May 30, 2007, 11:08:53 am by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Gary W.

  • EA User
  • **
  • Posts: 139
  • Karma: +0/-0
    • View Profile
Re: generate sequence diagrams from source
« Reply #11 on: May 30, 2007, 07:45:00 am »
Quote
At last...  Someone who understands...[size=13]VIT: Model<->Code Commentary & Metadata[/size]
Paolo


Actually, the link above returns an error.  Try this one instead:
http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=suggestions;action=display;num=1172058404;start=0#0

gary