Generate Class Diagram from Existing Classes
When creating a class diagram, sometimes we would draw it using the diagram toolbar and there are times we would reuse elements by drag & drop. However, when you start from scratch, sometimes it can be difficult to know which class goes with which because we may not necessarily know all relationships among them.
Luckily, there is a function called Form Diagram which automatically generates a class diagram from existing classes for you. You just need to specify one or more classes that you want to explore with.
This article will show you how.
Note: Visual Paradigm for UML (VP-UML) is used in the example below.
Before We Start
We have already reversed Java code for java.io & java.lang and you can see them in the Class Repository.
Steps To Take
Let’s say we want to take a closer look at the File class.
1. In the Class Repository, under base > java > io, right click on File.
2. While right clicking on File, select Form Diagram.
Under it there are 3 choices to select for your class diagram as follows:
– Customize… allows you to customize your own class diagram.
– Hierarchical diagram shows you the vertical structure of classes (e.g. a superclass over another).
– Navigation diagram shows you the horizontal structure of classes (e.g. which has associations with which).
3. Let’s say we’ve selected Customize…
In the Form Diagram dialog box, under the Form Diagram tab, the preview changes based on the current mouse location (e.g. Generalization, Association).
4. In the Form Diagram dialog box, under the Presentation Options tab, the preview changes on the current mouse position (e.g. Attribute Options).
Select the checkbox next to Show operation signatures. Click OK.
5. Click Yes to set the first view as the master view.
6. Your customized class diagram will then appear.
Related Articles
- Grouping Generalizations by Creating a Generalization Set
- Progressively Develop Conceptual, Logical and Physical ERDs
- When reversing Java code to sequence diagram, why can’t I select an operation?
Is there any way to generate class diagram from existing Salesforce Apex classes.
The Salesforce Apex classes are based on Java and therefore you can make use of the Java round-trip engineering feature (supported in Standard Edition or above) to reverse it into UML Class Model. Details about reverse engineering of Java source can be found at https://www.visual-paradigm.com/support/documents/vpuserguide/276/381/7530_generateorup.html
After reverse the Java source to class model you can then generate Class Diagram from it. Details can be found at https://knowhow.visual-paradigm.com/uml/gen-class-diagram-from-class/