UML Modeling on NetBeans, Part III: Generate code from a diagram
Java, NetBeans, Programming February 13th, 2007In this part, I am going to show how to generate code from existing diagram so that it can reduce a lot of work if you have an well-defined diagram. Also, it can make sure that the coding structure of your project will conform as in a diagram.
- Suppose I have an existing class DicomImage in Model1 Project as in figure below.


- Before we start, let choose where to save source code file. Let say, I want to put source code in Source Packages, Dicom project. (“C:\Documents and Settings\Linglom\Dicom\src”)

- Now, let generate code. Right click on Model1 Project, select Generate Code…

- Select destination to put the source code, I use location from 2. Click OK.
If you don’t want to backup file, just uncheck the box.

- If you have just created a diagram, it will ask to save it first. Click OK.

- When code are generating, you will see the progress in the output window.

- When it finished, you will see the new file in destination Project was created. Try open it and you will see some source code that it has generated for you.


This tool is useful if you have a clearly well-defined diagram. But keep in mind that if your diagram contain some errors, your generated code may effected from that, too.
Related post
- UML Modeling on NetBeans, Part IV: Generate a diagram from existing code Now I will show about how to generate a diagram from an existing code. It also can be called reverse...
- UML Modeling on NetBeans, Part II: Create a Use Case Diagram A Use Case diagram is useful when you are describing requirements for a system in the analysis, design, implementation and...
- UML Modeling on NetBeans, Part I: Installation Introduction This article show how to create UML Model on NetBeans and infers that you have already install NetBeans 5.5...
Related posts:




February 16th, 2007 at 10:38 pm
Good post !!! It was really interesting, but I dont know all the buttons from the palette, where can I found more information about the these button?….
Thanks for the time. bye
February 16th, 2007 at 11:28 pm
To Saul,
I guess you mean icons in palette window in part II. I suggest you should find some information about the diagram.
For Use Case diagram, there are some nice tutorials:
http://www.developer.com/design/article.php/2109801
http://www.agilemodeling.com/artifacts/useCaseDiagram.htm
June 23rd, 2007 at 9:08 pm
great site…but i need stuff like pdf format…
September 10th, 2007 at 12:45 pm
[...] Part III: Generate code from a diagram [...]