What is the best way to document Java sources in UML? I know class diagrams, package diagrams and object diagram. What else should be documented? And is there any recommendation for a tool to support documentation?
2 Answers
Use an UML modeling tool with some kind of code reverse engineering support so that it can create some basic diagrams automatically from your existing code.
Creation of the rest requires manual work and some imagination and some thinking on your side. There's no magic tool. That would be your task/work/effort.
To find out what might the "UML beside classes..." browse through
12 Comments
uml-diagrams.org online book is probably the easiest UML book one can read and at the same time the most complete and up-to-date. To document your Java application, how does the code look ("structure diagrams") what does the code do ("behavior diagrams") and why ("use case diagram") you can use all of the available UML diagrams. For each diagram type the book contains examples, explaining chapter, drawing reference chapter and sometimes some discussion and historical background. After you know what's possible with pencil & paper, get a good UML modeling tool...Java code is hidden behind this class diagram example and this sequence diagram example. Both were drawn using "Microsoft Visio and UML 2.2 stencils" (not very rigorous/helpful UML tool). Pick an UML tool and read it's tutorials. It's probably the best I can advise you without seeing the real *.java code*.java files, see what the tool draws and do the same (or similar) thing manually. There are about 20 different types of UML diagrams and all of them can describe your real *.java code. Just start drawing and if you hit some concrete drawing obstacle related to some concrete piece of code then open another questionFrom Java code, you can get the class diagram including relationships (relation diagram does not exist). Object diagram is for describing runtime instances.
If you have your Java code in a Git repository, you can get the corresponding UML model online using the GenMyModel reverse engineering feature (get started, documentation).
relation diagramfrom your question since there is no such diagram. Go for @xmojmr's answer. I guess GenMyModel is also worth a try.