Generating Class Diagram - java

HI All I am at the end of the release of my project.So in order to keep working our manager asked us to generate Class Diagrams for the code we had written.Its medium project with 3500 java files .So I think we need to generate class diagrams.First I need to know how reverse engineering works here. Also I looked for some tools in Google(Green, Violet) but not sure
whether they are of any help.Please suggest me how to proceed.Also a good beginning tutorial is appreciated.

I strongly recommend BOUML. Its Java reverse support is absolutely ROCK SOLID.
BOUML has many other advanteges:
it is extremely fast (fastest UML tool ever created, check out benchmarks),
has rock solid C++, Java, PHP and others import support,
it is multiplatform (Linux, Windows, other OSes),
has a great SVG export support, which is important, because viewing large graphs in vector format, which scales fast in e.g. Firefox, is very convenient (you can quickly switch between "birds eye" view and class detail view),
it is full featured, impressively intensively developed (look at development history, it's hard to believe that such fast progress is possible).
supports plugins, has modular architecture (this allows user contributions, looks like BOUML community is forming up)

The tool you want to use is Doxygen. It's similar to Javadoc, but works across multiple languages. If figures out the dependencies, and can call graphviz to render the class diagrams. Here's an example of a few Java classes run through Doxygen.

This is more a toolchain than a tool and I haven't tried it out myself. But it maybe a starting point. Using UMLGraph, ant and GraphViz. Explained step by step: in this article.

I ve used Visual Paradigm for UML for what you want to do and it was quite good.
See here for details.
Just go Tools -> Instant reverse and select your packages.

You may be able to reverse engineer class diagrams with the open source modelleing tool ArgoUML http://argouml.tigris.org/

ObjectAid is pretty nice. You can drag classes into a diagram and arrange them the way you want.

Visual Paradigm for UML Standard Edition (or Better) will reverse engineer Java files in to Class Diagrams.

I guess if your boss just wants to keep you busy until the next project starts then there's no harm in it, but you will find pretty quickly that creating a class diagram with 3500 classes will tell you exactly NOTHING about your system. In fact, you don't really want a diagram with more than about 10 classes on it. So once you have reversed all the code into your modelling tool, you will want to start organizing and arranging to find the meaning. Create a new diagram, drop a single important class onto it and bring in all the classes that are directly related to that class. Repeat for maybe the 300 most significant classes. Don't worry, it isn't as horrible as it sounds, maybe a week's work.
For the record, my modelling tool of choice is Enterprise Architect by Sparx Systems. It will reverse java sources or .jar files. There is a free 30 day trial edition.

There are some tools available that will help you generate these diagrams. These cost money.
Otherwise you could to try to parse your Java files. This could be as simple to create a simple parser that reads the Java files and writes the name of the class and all the import statements to a file and generates a class diagram from there, graphviz can help you there.

I've been using Enterprise Architect for a number of years. A JBoss developer suggested it to me. It works very well for all types of UML modeling including the reverse engineering of class models (Java, C# and others). The basic version is currently $120 per seat, but it has most of the capabilities of much more expensive tools and it is much easier to learn. I particularly like its ability to generate HTML and RTF documentation.
It is very easy to synchronize code between the tool and your source code. Even bi-directional if you want.
Your PM may also like the activity and sequence diagrams that it can create. I also frequently use the deployment diagrams. It's very helpful to have all of this in one tool.

Related

Get the class structure of an android project

I've an android project opensource written in Java (Eclipse). There are about 300 classes..I wanna to be able to understand the code quicker and to have a general representation of all the classes, interfaces and to know how they are connected each other.
Is there a way in Eclips or an external utility that could help retrieve the class structure of the project?
I have not tried it, but this looks good: http://sourceforge.net/projects/jug/
EDIT: Well this one looks even better: http://www.objectaid.com/home
EDIT 2: See this, too: http://www.nwiresoftware.com/
I haven't done that yet with Java, but you can try some of the options discussed here:
How to generate UML diagrams (especially sequence diagrams) from Java code
to get UML diagrams of your code
There are quite a few UML plugins available out there for Eclipse. It's really about how much information you want and which you feel comfortable with. The most popular one I found is Object Aid but a quick Google search for UML plugins for Eclipse returns a number of options.
If you want detailed UML diagrams then I highly recommend taking a look at Enterprise Architect. It provides tight integration with Eclipse. The desktop version is quite affordable.

Eclipse plugin or a Open source tool to reverse engineer java code for sequence diagram

I am looking out for a eclipse plugin or an open source tool to reverse engineer the sequence diagrams. I tried using Alto UML, but it just gives out sequence diagram of the class chose. I would like to have a sequence diagram of the whole call stack with methods, input arguments and output arugments as well.
Could you please let me know some pointers on this? Thanks!
Architexa does have sequence diagrams for the whole call stack with methods. What you will find is that unlike typical UML tools Architexa is much more code-centric and therefore would work much better for reverse engineering.
-Vineet (Architexa founder)
Look at this Wikipedia article comparing reverse engineering tools.
(repeat from How to Create Flowchart from java source code in Eclipse for completeness):
I found this Eclipse plugin Flowchart4j V 2.0.0 et
http://www.codeswat.com/
You can use it for flowchart or sequence diagram and export it to MS Visio.
It has only one disadvantage. You have to pay for it.
Diver: Dynamic Interactive Views For Reverse Engineering can solve part of your problem. It provides both static and dynamic sequence diagrams for Java applications. It does not store the inputs and outputs though.
It is a plugin for Eclipse and lets you:
Easily trace your Java programs
Visualize your program’s runtime functionality
Filter your traces to make them more compact
Filter your IDE based on what occurs at runtime
See what code ran in your source code editors
It's on Github and there is also a project web site
Full Disclosure: I am the current project lead for Diver
Take a look at the MoDisco open source eclipse project MoDisco
(repeat from How to Create Flowchart from java source code in Eclipse for completeness):
I am not sure if there is a plugin for this but there are certainly techniques for doing this. If there is no plugin available, theoretically, one could follow the approach of such techniques to build one. One such technique that comes to mind is contained in the paper Object naming analysis for reverse-engineered sequence diagrams by Atanas Rountev and Beth Harkness Connell.
Here's the abstract:
UML sequence diagrams are commonly used to represent object interactions in software systems. This work considers the problem of extracting UML sequence diagrams from existing code for the purposes of software understanding and testing. A static analysis for such reverse engineering needs to map the interacting objects from the code to sequence diagram objects. We propose an interprocedural dataflow analysis algorithm that determines precisely which objects are the receivers of certain messages, and assigns the appropriate diagram objects to represent them. Our experiments indicate that the majority of message receivers can be determined exactly, resulting in highly-precise object naming for reverse-engineered sequence diagrams.

Visualizing Java project

I have been tasked with porting a large Java codebase to the Android platform. The project makes extensive use of AWT which isn't' supported on Android.
I'm looking for a tool that lets me visualize all of the classes in the project. I'd like to be able to see all of the relationships between classes so that I can get a good idea of where to start the port.
If you have any suggestions that would help in this task I'd like to hear about them.
I use Structure101 almost daily to visualize and understand our code base. A great tool and quite reasonably priced too.
This question has been touched at StackOverflow many times before and here are some links:
Is there some tool to visualize java class hierarchies and relations?
Tool to visualize code flow in Java?
Recommended Eclipse plugins to generate UML from Java code
Good free UML tool for Java/Eclipse?
IntelliJ IDEA also has some tools to help, like Graphical Navigator in IDEA 8 and Code Navigator plugin.
Netbeans has an OK reverse engineering tool which spits out a heaps of UML. I haven't used it in a while, but when I did it was a tad buggy.
There is an Eclipse plugin called Creole which you could also try. http://www.thechiselgroup.com/creole

Does anyone have any experiences with Eclipse GMF?

I've just started to play around with Eclipse GMF.
Has anyone used the framework?
Any good or bad experiences you had using it?
Any alternatives for graphical modeling you could suggest?
EDIT: What good examples are available?
Has anyone used the framework? Yes, I am using it right now. It works, but it is typically quite a bit of coding for the graphical figures. I currently am struggling to leverage the IBM RSA/RSM UML editparts/figures/nodes etc built on top of GMF.
Any good or bad experiences you made using it? Looking back on my initial dives into GMF/EMF/GEF etc I can say for certain, study the examples. There are important patterns that you have to pick-up on from the examples and not the documentation. I would also suggest a new book (Eclipse Modeling Project: A Domain-Specific Language (DSL)) specific for GMF Modeling in Eclipse. I paged through it and it seemed to be the missing manual to some of the more basic concepts. Why the book is good is that is focuses on the key to making UML/Models useful through constraining it to a specific domain and providing a tool that only allows for valid models to be created. There is not a lot of documentation online and the API only tells you so much. WATCH OUT for repaint/paint loops caused by calling setBounds() or other set methods on children, it crashes the eclipse instance, not fun. Oh yes and the APIs are split between eclipse help documentation versions or not included at all.
Any alternatives for graphical modeling you could suggest?
Consider UML profiles with custom images and icons rather than full shape generation. It takes about 2 hours to put together a pretty good Image/Icon editor building on top of UML graphical objects and UML profiles. The IBM RSM tool UML Profile tooling project does this quickly. There is a lot you can do with constrained UML profiles (via Eclipse plug-ins or OCL). Entering GMF land is more than a order of magnitude effort increase, from 1 to 10 hours no problem.
Consider pure DSL (Domain specific language) tools out there. Google will provide a good list. From what I have seen the main reason to use GMF is eclipse integration and leveraging existing ecore/UML models, this is why I use GMF.
Ask yourself do I need model which is easy, or do I need a tool for creating instances of this model. If there are only 1-5 expert users there may not be a need for a sleek tool.
The TOPCASED project makes use of GMF. It provides various graphical editors for UML and other diagrams.
With GMF, most of the editor code is generated for you, but the main complexity arises from having to modify it.
As most recent alternatives, you might try Graphiti and Spray. Here is a comparison and another between GMF and Graphiti.

Sequence Diagram Reverse Engineering

I'm looking for a tool that will reverse engineer Java into a sequence diagram BUT also provides the ability to filter out calls to certain libraries.
For example, the Netbeans IDE does a fantastic job of this but it includes all calls to String or Integer which clutter up the diagram to the point it is unusable.
Any help is greatly appreciated!!!!!!!
I think jtracert is what you are looking for. It generates a sequence diagram from a running Java program. Also, because its output is a text description of the diagram (in the formats of several popular SD tools), you can use grep to filter for only the classes you are interested in.
I believe the perfect tool to solve your problem is Diver: Dynamic Interactive Views For Reverse Engineering. It provides both static and dynamic sequence diagrams and looks to solve all your requirements from your question.
It is a plugin for Eclipse and lets you:
Easily trace your Java programs
Visualize your program’s runtime functionality
Filter your traces to make them more compact
Filter your IDE based on what occurs at runtime
See what code ran in your source code editors
It's on Github and there is also a project web site
Full Disclosure: I am the current project lead for Diver
Try MaintainJ. MaintainJ generates sequence diagrams at runtime for a use case. It provides multiple ways to filter out unwanted calls. Yes, filtering out unwanted calls is the most important feature needed in sequence diagram generating tools. Besides, MaintainJ provides a neat interface to explore the diagram and search for calls in one use case or across use cases.
Check the demo video to get a quick overview.
I am the author of MaintainJ, by the way.
JTracert is now discontinued. In place, they recommend http://www.jsonde.com/
I have a tool that meets your requirements exactly. Check it out
http://sourceforge.net/projects/javacalltracer/
In addition to being a reverse engineering tool for java it is also very lightweight. You can control the what you want to record from your java program.
Enterprise architect from Sparx claims to be able to reverse engineer java code including generating sequence diagrams - see this section of the user guide
It looks like it can record a debugging session and then you generate the sequence diagram from that
I've not tried it (though have used EA as a modelling tool) so ymmv!
There is a free 30day evaluation download available
Take a look at http://www.maintainj.com
It don't know, whether it can filter library calls, but it has a reasonable graphical front end and seems to trace even very large applications.
MaintainJ is really wonderful tool, Recently i was started to use with MaintainJ with my application it is giving more comfort with my entire usage to understand my system based on Maintainj sequence & UML diagrams.
I am sure for the above question MaintainJ is will give better idea.
Thanks,
Krishna MM
I have just started using the sequence diagram recording feature in Sparx Systems Enterprise Architect. It works very well for C#. You can create filters by class and by method. I'm actually trying to find out if it's possible to filter out an entire package. There is a checkbox for automatically excluding external modules (like the .NET Framework) which aids in declutter. YMMV for Java, but I think their support (and documentation) for Java is generally better (more examples) than for .NET.
Heatlamp (http://www.jmolly.com/heatlamp/) was designed for exactly this purpose.
It generates interactive (and printable) diagrams from running Java code. You can specify filters to describe which classes, packages, and methods to trace. You can also search, filter, and collapse invocations after the diagram is rendered to further reduce the sequence diagram.
Disclaimer: I'm the author of Heatlamp.
This looks like a really nice tool:
http://www.architexa.com/learn-more/sequence-diagrams
But it looks like it's only free for a year, then its $250 a year. Bummer.
I found the ModelGoon plugin to be helpful. It's a bit limited because you choose a single method as the starting point for the sequence diagram, and it only shows the calls that method makes (so to go a level deeper you need to generate another diagram.)
http://www.modelgoon.org/?page_id=53
JIVE (www.cse.buffalo.edu/jive) will construct a sequence diagram from the execution of a Java program. It has an Exclusion Filter capability will allow you to exclude objects belonging to designated classes or packages. JIVE can draw sequence diagrams for multi-threaded Java program execution. It also has the ability compact large diagrams in both the horizontal and vertical dimension, under user guidance.
Here's and add-on to Asgeir's answer. Here's the link that I found.
http://www.java2s.com/Code/Jar/s/sequence.htm
Run from the command line ... "java -jar sequence.jar" ... this is a Java application with a GUI.
The help section says:
SEQUENCE is a program for producing UML Sequence Diagrams. In contrast to most similar programs you don't actually draw the diagram. Instead you write a textual description of the method calls you want to diagram and the layout is calculated and drawn automatically.
So this tool doesn't reverse engineer anything, but I can see how it might be helpful if you wanted to quickly diagram things from scratch. Looks like it was built in 2002 and I think there are probably better tools out there now.
Here's another similar tool here:
http://sdedit.sourceforge.net/example/index.html

Categories

Resources