Bagaimana Menggambar Diagram UML di NetBeans?

Bagaimana Menggambar Diagram UML di NetBeans?
Bosan beralih antara IDE favorit Anda ke lingkungan pemodelan untuk menyelesaikan pekerjaan? Juga merasa kesulitan untuk menyinkronkan antara kode dan model visual dalam dua lingkungan pengembangan yang terpisah? Paradigma Visual terintegrasi dengan mulus dengan NetBeans, memberikan dukungan penuh kode bolak-balik dan rekayasa basis data. Pengembang sekarang dapat melakukan aktivitas pengembangan siklus hidup penuh dengan NetBeans, seperti analisis, pemodelan desain, rekayasa kode, pengembangan kerja tim yang gesit, dan banyak lagi!

Edisi yang kompatibel: Perusahaan, Profesional, Standar
15 Maret 2016
Dilihat: 324.565
PDF
Paradigma Visual adalah platform pengembangan tangkas pemenang penghargaan yang mencakup perangkat tangkas yang banyak digunakan seperti cerita pengguna, kasus penggunaan, model visual UML, teknik pengkodean, kerja tim, dan kemampuan manajemen proyek. Solusi one-stop-shop ini memungkinkan pengembang untuk melakukan seluruh proses pengembangan tangkas di satu tempat.

Persiapan
Untuk mengikuti dan menyelesaikan tutorial ini, Anda harus menginstal Visual Paradigm. Mereka dapat diunduh dari halaman unduhan Paradigma Visual. Tentu saja, Anda memerlukan NetBeans IDE juga. Kami kira Anda sudah menginstalnya tetapi jika belum, silakan unduh dari situs resmi NetBeans untuk menginstalnya.

Catatan: Kami hanya mendukung NetBeans 6.7 atau versi yang lebih tinggi. Jika Anda menggunakan versi sebelumnya, harap pertimbangkan untuk memutakhirkan NetBeans Anda.

Paradigma Visual menargetkan tim perangkat lunak yang ingin mengembangkan perangkat lunak dengan desain profesional, pelaporan, kode, dan dukungan rekayasa basis data. Ini mendukung semua jenis fitur pemodelan UML, Pemodelan Proses Bisnis dengan Notasi Pemodelan Proses Bisnis (BPMN) OMG, ERD (untuk desain basis data), pembuatan kode, rekayasa balik, pembuatan/pembalikan basis data, Hibernasi, pembuat laporan, dan pembuatan laporan.

Integrasikan Paradigma Visual dengan NetBeans
Ini dia. Kita perlu menginstal integrasi dari Visual Paradigm. Jadi, matikan NetBeans Anda dan mulai Visual Paradigm. Lakukan langkah-langkah di bawah ini.
  1. In Visual Paradigm, select Window > Integration > IDE Integration… from the application toolbar. Download https://www.nesabamedia.com/download-visual-paradigm-community-edition/
  2. https://www.nesabamedia.com/download-visual-paradigm-community-edition/1 launch integration
  3. In the Visual Paradigm IDE Integration window, check NetBeans Integration. Click Next.
    2 select netbeans integration
  4. Specify the path of your NetBeans installation and click Next.
    3 specify netbeans location
    This begins files copying. If you see the error messages “java.io.IOException: Cannot make dirs for file…”, please restart Visual Paradigm with the Run as Administrator option. When finished files copying, close Visual Paradigm and move on to the next section to see how to create a Java application in NetBeans along with UML model.

Creating a UML Model for your Java project

In this section, we are going to create a UML model from a Java project in NetBeans. In order not to mess up with your production work, we will create a new Java project for this tutorial.

  1. Start the NetBeans IDE.
  2. Click the New Project button at the toolbar to open the New Project window.
    1 new netbeans project
  3. In the New Project window, select Java category and choose Java Class Library as the project type. Click Next.
    2 new java project
  4. Enter Online Shop in the Project Name field. Leave other settings as default and click Finish to create the project.
    3 name the project
  5. Now, you have an empty Java project. Let’s create a UML model from it. To create a UML model, right-click on the project root node in the Projects pane and select Open Visual Paradigm from the popup menu.
    4 open vp
  6. When you are prompted to enter the path of project file, keep Create in default path selected and click OK. This will create the .vpp project file in the Java project folder.
    5 default path

UML modeling in NetBeans

Let’s draw a simple class diagram. We will generate Java code from it in the next section.

  1. Open the Diagram Navigator of Visual Paradigm.
    10 finished class
  2. Right-click on the Class Diagram node and select New Class Diagram from the popup menu. This creates an empty class diagram.
    2 expand uml tree
  3. The diagram will automatically grab focus on its package header (top left of diagram). This allows you to specify the parent package for your diagram. If the package you specified does not exist in your project, it will be created for you automatically. Once you have specified the package, the class diagram along with the classes to be created in the diagram will automatically be put in the package. Enter onlineshop as package name and press Enter.
    3 new class diagram
  4. Now, the focus will be shift to the diagram name field. Enter Online Shop as the name of the diagram and then press Enter.
    4 name package
  5. Next, we are going to create a class. Select Class from the diagram toolbar and it onto the diagram to create a class.
    5 name diagram
  6. Enter Product as name and press Enter to confirm.
    6 create class
  7. A product has three attributes: name, partNo and price. Let’s add them. Right-click on the Product class and select Add > Attribute with Getter and Setter from the popup menu.
    7 class created
  8. Enter name : String to create the name attribute in String type. Then, press Enter to confirm. Right after your confirmation, the getter and setter operations for the name attribute will automatically be inserted to the class. Similarly, create two more attributes partNo : String and price : float.
    8 create attributes
  9. Press Esc to cancel the next attribute.

Generate Java code from class diagram

Let’s generate Java source code from the UML class. There are several ways to achieve this. Here, let’s try the one that generate code for the entire UML model. Click on the Update Code button at the top of Diagram Navigator.

1 generate code

In the Projects pane, expand the project node and check Source Packages. The package onlineshop and Product class are there. Open Product.java, you can see the Product class filled with attributes and its getter and setter.

2 code generated

Generate and update UML classes from Java code

You’ve learned how to create UML diagrams in NetBeans. If you want to know how to produce UML class model from your Java source code which is essential to keep the design conformed to your source code, you need to perform the steps below.

  1. Let’s create a class in NetBeans. Right-click on the package onlineshop and select New > Java Class… from the popup menu.
    1 new source
  2. In the New Java Class window, enter Vendor as class name and click Finish.
    2 new source file
  3. Add two attributes to the Vendor class, a name in String type and a collection of Product.
    3 implement new source
  4. Next, we try to update the Product class which is just generated in the previous step. Let’s try to add a constructor to it. Right-click on the source file of Product class and select Insert Code.
    4 insert code
  5. Select Constructor… from the popup pane.
    4 insert code
  6. Select all three attributes and click Generate to generate the constructor.
    5 select attributes
  7. Now, go to the Diagram Navigator. Click on the Update UML Model Element button to have your changes reflected in the UML model.
    6 update model
  8. Open the class diagram. The constructor method is presented in the Product class.
    7 generated constructor
  9. Switch to Model Explorer pane, you can find the Vendor class inside the onlineshop package. Drag out the Vendor class and drop it to class diagram, the Vendor class will be visualized with association with Product class.
    9 show new class

Something more – Generate UML Sequence Diagram from Java code

The class diagram helps you to understand the static data structure of your system. However, what about its dynamic behavior? Sequence diagram is one of the popular diagrams in UML used to model the dynamic behavior of a system. You can reverse engineer Java source code into sequence diagram inside the NetBeans integration environment. Let’s walk through the steps below to create a sequence diagram from source code. Before you start, please note that the classes drawn in the previous sections will be overwritten by the steps to be performed.

  1. Select Modeling > Instant Reverse Java to Sequence Diagram… from the menu.
    1 reverse sequence diagram
  2. Click the Add Source Folder button in the Instant Reverse Java to Sequence Diagram window.
    2 add src folder
  3. Specify the source folder of the Java project in the Select Directories window. Click OK and then click Next.
    3 select src folder
  4. Now, expand the tree in the Select Operation step and choose the operation you would like to reverse to sequence diagram. Click Next to proceed.
    4 select operation
  5. Select Create New Sequence Diagram in the Choose Diagram step and leave the diagram name as default. Click Finish.
    5 choose diagram
    Now the sequence diagram of your selected operation is being generated.
    6 sd generated

Tinggalkan Komentar

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

Scroll to Top