Book a Demo

Author Topic: Automatic Generation of Sequence Diagrams  (Read 4153 times)

Darrell Thurmond

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Automatic Generation of Sequence Diagrams
« on: June 21, 2004, 10:44:01 am »
How difficult would it be to generate Sequence diagrams from source code.
Darrell R. Thurmond

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Automatic Generation of Sequence Diagrams
« Reply #1 on: June 24, 2004, 06:16:44 pm »
If you mean automatically by reverse engineering - phenomenally!  If you mean by writing an add-in suitable for analysing a specific persons code against specific input data in specific scenarios, then almost as phenomenal.

Sequences denote the operation of the system in specific circumstances, from these sequences we can generalise the behaviour of a system into codable methods.  Thus in a sense, the code is a "pattern" for the operational behaviour of the system given a specific set of stimuli.  The pattern has been built by a person with a limited (albeit a learned) exposure to the total set of stimuli scenarios. This specific code reflects the coder's gestalt of the system in its environment and thus each coder will produce a different set of code.  Undoing the result of the coding process then would require knowledge of the coder's specific techniques, knowledge of what they know about the system and knowledge of the total scenario pool that the system could operate in.

How could such a generator know which specific stimulation scenario to construct a diagram for?  How would it know which scenario is of interest to the problem being studied?

Lets take something simple - say an MS Access form with 6 textboxes, a listbox, a menu of 10 items and say 3 command buttons.  Each of these elements having some level of "code behind" in a VBA class model that responds to, say, on average 3 events per control.  Thats, say 60 event handler methods.  How many usage scenarios does that represent? How many are trivial?  How many are of any interest?

B
"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.

angel-o-sphere

  • EA User
  • **
  • Posts: 112
  • Karma: +0/-0
    • View Profile
Re: Automatic Generation of Sequence Diagrams
« Reply #2 on: June 25, 2004, 07:44:24 am »
The question is wether a Sequence Diagram is a scenario or not. (E.G. I never use branches in sequence diagrams).

*I* only make sequence diagrams for scenarios ... so for me a "Sequence Diagram" is-a "Scenario". Others transform activity diagrams into sequence diagrams and use branches etc. Thats trivial restructured from code.

The best way for transforming code into a sequence diagram is having a test case. E.g in case you use Java you could use AspectJ to instrument method calls. The instrumentation should write out a class and method name, if needed with an object id or parameters. Running the test case triggers the intrumentations. That yields an TAB formated CSV file which can be imported into EA.

Now you are close to convert that into a sequence diagram .... which fits a scenario.

BTW: Together/J  *CAN* generate sequence diagrams from source code (since over 5 years).

Its not that impossible as you believe :D

A much better way is to automatically construct an activity diagram where every method is an activity and every method call is an edge from activity to activity. The edges are guarded with the while/if etc. conditions from the source code. By selecting a set of branches this could be automatically converted into a sequence diagram just for that set.

angel'o'sphere