PowerDesigner (eight)-object-oriented model (use case diagram, Sequence diagram, class diagram, generate Java source code and Java source code generation class diagram)

Source: Internet
Author: User
Tags powerdesigner
Object-oriented model

Object-oriented model is a model that uses UML (Unified Modeling Language) to describe the system structure, which realizes the working state of the system from different angles. These graphics help communicate information between users, managers, system analysts, developers, testers, and others. This article mainly introduces use case diagram, Sequence diagram and class diagram.

1. Object-oriented model Oom

Object-oriented model is a model that uses UML to describe the system structure, which can be created by PowerDesigner object-oriented model. PowerDesigner supports the following graphics for UML. Use case diagram Diagram: A high-level sketch commonly used to define a system, which describes the application's system functions from a user's point of view, and points out the external operators of each function. Sequence diagram (Sequence Diagram): Describes how the system actually completes the functionality defined in the user case diagram. You can draw the timing relationship that occurs when an object (an instance of a class) interacts. Class Diagram Diagram: Describes the static relationship between classes and classes. This includes a series of packages, classes, interfaces, and the relationships between them. Class diagrams are the basis for defining other graphs.

2. Create an object-oriented model

(1) Select the file-new Model command or click the New Model icon in the toolbar to eject the New model window.

(2) on the left is the Model type column, select the Object-oriented model (object-oriented models) option, and on the right type the name, language, as shown in Figure 8-1.

Figure 8-1

(3) Click the "OK" button to enter the Oom design workspace. You can define the properties and operations of Oom in this workspace, or you can design various UML graphics.

(4) Select the Model-model Properties command to display the Model Properties window as shown in Figure 8-2 Oom.

Figure 8-2

(5) When the definition is complete, click the OK button. Then select the File-save as command to save the defined model by pubinfosys.oom this name.

(6) Set the selection of the model. Select the Tools-model Options command to open the Model Options window. As shown in Figure 8-3.

Figure 8-3

(7) Click the Set as Default button, set to the defaults, and then click the OK button.

3. Design use case diagram

3.1 Use case diagrams are used in the system requirements analysis phase to perform system requirements and function design, which contains two elements of executor and use cases. The performer refers to the user's role in the system, and the use case is an interaction between the user and the computer. Use case diagrams are primarily used to describe which actors are involved in each use case.  Define use cases: A use case is an externally visible system functional unit that is provided by the system unit and expressed through a series of units exchanged with one or more participants. Define roles: Roles describe a group of users interacting with the system, the most obvious of which is the person in the system, but it may also be the system itself. Definition Association: A use case can participate in multiple relationships in the system, in addition to associating with its participants, allowing definitions of associations to be associated, extended, and use case generalizations, including.

3.2 Defining use case diagrams

Define the use case diagram as follows:

(1) Click the Use Case icon to define 4 use cases, as shown in Figure 8-4.

Figure 8-4

(2) Select the first case double-click to open the Use Cases Properties window, modify the Name property to find, and modify the Code property to search, as shown in Figure 8-5.

Figure 8-5

(3) Using the same method, modify the other 3 use case properties as shown in Figure 8-6.

Figure 8-6

(4) Click the Performer icon to define 3 performer, as shown in Figure 8-7.

Figure 8-7

(5) Select the first performer and double-click, open the Actor Properties window, modify the Name property to "Customer", and modify the Code property to buyer, as shown in Figure 8-8.

Figure 8-8

(6) Modify the properties of the other two performer using the same method.

(7) Define the relationship between performer and use case. Create a relationship between the performer and the use case by clicking the Relationship icon, clicking the performer's customer, and dragging the mouse to the use case "find" to release the mouse. Double-click the relationship, open the association Properties window, modify the Name property to query merchandise, and modify the Code property to Searchproduct.

(8) Follow the steps (7) to establish a relationship between the other performer and the use case.

(9) The completion of the definition of the use case diagram is shown in Figure 8-9.

Figure 8-9

4 design sequence diagram

The 4.1 sequence diagram (Sequence Diagram) is used to describe how the system accomplishes the functions defined in the use case diagram. You can draw the timing relationships that occur when interacting with objects. On the one hand, it describes an interaction, involving classes in the class diagram, and a refinement of the use case description.

Sequence diagrams have roles (Actor), objects (object), messages (message), and activation periods (activation) Several elements if shown in 8-10.

Figure 8-10

Message types are: Message Slef messages Recursive message call messages with activation period messages self call messages with the activation period of the recursive message returned message returns the messages self return MESSAG E Recursive return message

4.2 Creating a sequence diagram

(1) Select the File-new Model command to open the New model window. Select the object-oriented model option in the mode type bar on the left side of the window, select the Sequence diagram option in the Diagram Drop-down list box on the right, and select the Java option in the Object language Drop-down box. As shown in Figure 8-11.

Figure 8-11


(2) After the selection, click the "OK" button to enter the PowerDesigner design workspace.

(3) Click the object icon on the Palette toolbar and click the mouse on the right blank workspace to see the object symbol as shown in Figure 8-12.

Figure 8-12

(4) Right-click in the design area blank area, the mouse pointer changes to an arrow shape, double-click the object symbol, pop the actor Properties window, enter "Caller" in the Name text box, enter "Caller" in the Code text box, and then click OK.

(5) Repeat Steps (3) (4), add two other objects, name is "switch" and "callee" respectively, and code is exchange and receiver.

(6) Click the message icon in the Palette toolbar, click at the dotted line below the "Caller" object, and drag to release the mouse by dragging the dotted line below the "switch" object to add one.

(7) Right-click in the blank area of the design area, the mouse pointer changes to an arrow shape, double-click the object symbol, pop the message Properties window, enter "Pick up the microphone" in the Name text box, enter "Lift reciever" in the Code text box, and then click OK.

(8) Repeat (6) (7) to add additional messages.

(9) The final sequence diagram is shown in Figure 8-13.

Figure 8-13

(10) Select the File-save command to save the newly created object-oriented model

5 Design class diagram

Class diagrams describe the relationships between objects and objects in an abstract way and do not describe all the details of an object.

5.1 Creating Class (Class)

(1) Select the File-new Model command to open the New model window. Select the object-oriented model option in the mode type bar on the left side of the window, select the class Diagram option in the Diagram Drop-down list box on the right, and select the Java option in the Object language Drop-down box. As shown in Figure 8-14.

Figure 8-14

(2) In the Class Diagram workspace, click the class icon in the Palette toolbar, create a class, double-click the graphical symbol of the class diagram to open the Class Properties window.

(3) Select the Detail tab to define more properties for the class.

(4) Select the Attributes tab to add properties for the class. Click the Add a row icon, add the properties, or click the Add Attributes icon to open the properties of the other classes in the Selection window list model, select the properties that you want, and then click the OK button.

(5) Select the Operations tab, click the Add Operation icon, and open the Selection window, where you can select the actions that are contained by other classes in the model. When you have finished selecting, click the OK button and the selected action can be added to the current class.

(6) Select the Inner Classifies tab to define an inner class for the class. An inner class is a classifier of PowerDesigner, in which a classifier is a model element that contains attributes and operations. Once defined, you can use the Preview tab to observe the internal class code contained in the current class or interface, as shown in Figure 8-15.


Figure 8-15

(7) In addition to the above attributes, you can also define properties such as Associations,identifies. After the property has been defined, the contents are created as shown in Figure 8-16.

Figure 8-16

5.2 Creating contacts

In class diagrams, links are associated, dependencies, generalizations, and implementations.

6. Generate Java source code

Like the class diagram shown in Figure 8-17, generate Java source code.

Figure 8-17

(1) Select the Language-generate Java Code command in the class diagram and open the Generation window to display the classes contained in the model.

(2) Select the class in the Classes tab of the Selection tab and enter the target path of the Java source code in the directory bar.

(3) Define Java build options in the Options tab.

(4) Define the Java build task options in the Tasks tab, as shown in Figure 8-18.

Figure 8-18

(5) Click "OK" button to start generating Java source files, build complete display generated Files window.

(6) Select a source file and click the Edit button to display the contents of the file in a text editor. As shown in Figure 8-19.


Figure 8-19

7. Generate class diagrams from Java code

(1) Select the File-reverse engineer-object language pop-up as shown in Figure 8-20.

Figure 8-20

(2) Select Java in the Object language column, click OK to enter the following interface, as shown in Figure 8-21.

Figure 8-21

(3) Click Add, add Java file, and then click OK to generate the corresponding Java class diagram (in the Reverse engineer column can also choose Java bytecode file or file directory), as shown in Figure 8-23.


Figure 8-23


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.