Book a Demo

Author Topic: Reverse engineering UML diagrams from C#  (Read 7682 times)

BrianTollins

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Reverse engineering UML diagrams from C#
« on: February 12, 2009, 02:46:30 am »
I have been evaluating the trail version of Enterprise Architect 7.1 Corporate, and have a couple of technical questions.
 
I am mainly interested in the reverse engineering from C# code capability.
 
I have created a new package of type class diagram and can import my code directory and generate UML class diagrams.
 
And I can generate sequence diagrams from running the imported code.
 
However I cannot seem to generate any of the other diagram types (use case / state / activity etc).
 
Can these diagrams be auto generated from reverse enginnering the code, or am I asking for too much.
 
If so how? If not, will they be supported in future?

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Reverse engineering UML diagrams from C#
« Reply #1 on: February 12, 2009, 04:29:47 am »
Hi Brian,

I think you're expecting too much. At least for use cases it's simply not possible to reverse engineer from code. Use case diagrams describe  how external actors (human or machine) communicate with the software to achieve certain output or behavior. A single use case may be implemented in a single class, or may need a whole bunch of classes, components or even further external systems for its implementation. So, how should a reverse engineering process extract this kind of information from code??

Use case diagrams and activity diagrams are purposed to analyze what is necessary to fulfill requirements that are defined for your software, before implementation IMHO.

State machines are a bit different, because they belong more to the implementation details description. Anyway, as long the reverse engineering process cannot really decide in general, which structural implementation elements (i.e. classes, operations, ...) map to certain state diagram elements, these also cannot be reverse engineered.

BTW, I think that the main purpose of an UML tool is to help in designing object oriented software before implementation, and not vice versa. Reverse engineering is a useful feature in many situations, but just a feature.

WBR
Günther

BrianTollins

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Reverse engineering UML diagrams from C#
« Reply #2 on: February 12, 2009, 09:16:22 pm »
Thanks for your reply Gunther,

I understand and agree with your comments and arguments, and your answer is exactly what I was looking for.

I was interested in finding out in general which UML diagrams I could generate from reverse engineering code, and which ones I couldn't.

Even if I can only generate Class diagrams and Sequence diagrams, then at least it's a start.

Although I do have one question. Using a static code analyis tool, I can generate a diagram showing all the possible code paths and logic flows through my C# code. Can I also do this in EA. I am not sure of the terminology, but maybe something like an activity diagram.

The source code contains more information than just the class definitions, and as such I would hope to be able to extract more diagrams from the code. Again, I may be asking for too much, but you don't get anywhere without asking!!

Cheers,
Brian

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Reverse engineering UML diagrams from C#
« Reply #3 on: February 15, 2009, 08:57:16 am »
Hi Brian,

I didn't mention this explicitely, but I think Activity Diagrams are comparable to what I explained for Use Cases, they're purposed for higher level analysis.
What you could achieve by the kind of code analysis a static code analysis tool can do, is a set of sequence diagrams describing all the possible code paths (message calls). This is possible in EA only by tracking down to debug sessions, that go through particular code paths (may be you could generate all the possible ones, using debug + complete unit test environemnt).

But again, I am wondering what you're trying to get, or what's your goal with reverse enineering. Do you have to provide the missing documentation for an existing Software? Then good luck, with only the code and a reverse engineering tool at hand.
UML is designed to provide analysis support from top to bottom, and not to represent all information that will be manifest in the final implementation. There will always be a natural leak from UML model to implementation. IMHO this is intended, UML provides describing  abstractions for possible implementations.
Reverse engineering will help to keep analysis models consistent with code changed after analysis phases, or to import externally implemented code for use in developing your models using references to it.

WBR
Günther
« Last Edit: February 15, 2009, 09:10:24 am by g.makulik »
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/

BrianTollins

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Reverse engineering UML diagrams from C#
« Reply #4 on: February 16, 2009, 10:50:27 pm »
Thanks again for you reply,

I have an (incomplete) c# model representing a system, and I was hoping to use this implementation code as a basis for starting a more formal UML design. We would then use the master UML design for development before generating implementation code (also in C#).

Just wondering how much of a "legup" I could get along the UML process with just the reverse engineering.

I fully agree with you answer that the code can only give certain information; as such I will manually generate UML use case and activity diagrams which properly reflect our design intentions.

Thanks again for your support.

Regards,
Brian