Object-oriented model
Object-oriented model is a model that uses UML (Unified Modeling Language) to describe the system structure, and it realizes the working state of the system from different angles. These graphs facilitate information exchange between users, managers, system analysts, developers, testers, and other personnel. 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 structure of the system, which can be created by using the PowerDesigner object-oriented model. PowerDesigner supports the following graphics for UML.
- Use case diagram (user cases Diagram): typically used to define a high-level sketch of the system, it describes the system functions of the application from the user's perspective, and points out the external operators of each function.
- Sequence diagram (Sequence Diagram): Describes how the system actually accomplishes the functionality defined in the user case diagram. You can draw the timing relationship that occurs when you interact with an object (an instance of a class).
- Class Diagram: Describes the static relationship between a class and a class. These include a series of packages, classes, interfaces, and relationships between them. Class diagrams are the basis for defining other diagrams.
2. Creating 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 side is the Model type column, select the Object-oriented model (object-oriented models) option, and on the right, enter the name of the models, language, 8-1, as shown.
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 8-2 of the Model Properties window for Oom.
Figure 8-2
(5) Click the OK button when the definition is complete. Then select the File-save as command to save the defined model to the Pubinfosys.oom name.
(6) Set the selection of the model. Select the Tools-model Options command to open the Model Options window. As shown in 8-3.
Figure 8-3
(7) Click the Set as Default button, and then click the OK button.
3. Design use case diagram
The 3.1 use case diagram is used in the system requirements analysis phase for system requirements and functional design, which contains two elements of the performer and use case. The performer refers to the user's role in the system, and the use case is a user interaction with the computer. Use case diagrams are primarily used to describe which performers are involved in each use case.
- Define a use case: 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 role being the person in the system, but possibly the system itself.
- Define Association: A use case can participate in multiple relationships in the system, in addition to associating with its participants, allowing the defined associations to be associated, extended, use case generalization, including.
3.2 Defining a use case diagram
Define the use case diagram as follows:
(1) Click the "Use Case" icon to define 4 use cases, as shown in 8-4.
Figure 8-4
(2) Select the first case double-click, open the Use Case Properties window, modify the Name property to "find", and modify the Code property as shown in Search,8-5.
Figure 8-5
(3) Using the same method, modify the other 3 use case attribute 8-6 as shown.
Figure 8-6
(4) Click on the "Performer" icon to define 3 performers, as shown in 8-7.
Figure 8-7
(5) Select the first performer and double-click to open the Actor Properties window, modify the Name property to "Customer", and modify the Code property to Buyer,8-8 as shown.
Figure 8-8
(6) Use the same method to modify the properties of the other two performers.
(7) Define the relationship between the performer and the use case. Click the Relationship icon, click the performer "Customer" and drag the mouse to "find" in the use case to release the mouse, which establishes a relationship between the performer and the use case. Double-click the relationship, open the association Properties window, modify the Name property to query commodity, and modify the Code property to Searchproduct.
(8) Establish a relationship between other performers and use cases, as described in step (7).
(9) After the definition is complete, the use case 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 functionality defined in the use case diagram. You can draw the timing relationship that occurs when you interact with objects. It describes one interaction at a time, involving classes in class diagrams, and refining the description of use cases on the other.
Sequence diagrams have roles (Actor), objects (object), messages (message) and several elements of the activation period (Activation) if 8-10 are shown.
Figure 8-10
Message types are:
- Message: Messages
- Slef message Recursive messages
- Message with activation period for call message
- Self call message recursive message with activation period
- Return message
- Self return message recursive return messages
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 first diagram drop-down list box on the right, select the Java option in the object Language drop-down box, As shown in 8-11.
Figure 8-11
(2) Click the "OK" button to enter the PowerDesigner design workspace after the selection is complete.
(3) Click the object icon on the Palette toolbar, click on the right blank workspace, and the object symbol 8-12 appears.
Figure 8-12
(4) Right click in the blank area of the design area, the mouse pointer changes to the arrow shape, double-click the object symbol, pop up the actor Properties window, enter "Caller" in the Name text box, enter "Caller" in the Code text box, and click the "OK" button.
(5) Repeat Steps (3) (4), add the other two objects, name "switch" and "called Party", and code for Exchange and receiver respectively.
(6) Click the message icon in the Palette toolbar, click at the dotted line below the "Caller" object, drag the mouse to the dotted line below the "switch" object to release the mouse and add a message.
(7) Right click in the blank area of the design area, the mouse pointer becomes the arrow shape, double-click the object symbol, pop up the message Properties window, enter "Pick up microphone" in the Name text box, enter "Lift reciever" in the Code text box, and click the "OK" button.
(8) Repeat (6) (7) to add additional messages.
(9) The final sequence is shown in Figure 8-13.
Figure 8-13
(10) Select the File-save command to save the new object-oriented model
5 Design class diagram
A class diagram is an abstract way to describe the relationship between objects and objects, and does 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 first diagram drop-down list box on the right, and select the Java option in the object Language drop-down box. As shown in 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 for 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 to the class. Click the Add a row icon to add properties, or click the Add Attributes icon to open the properties of other classes in the Selection window list model, select the desired properties, and click the OK button.
(5) Select the Operations tab, click the Add Operation icon to open the Selection window, where you can select the actions that other classes in the model contain. When you have finished selecting, click the OK button and the selected action will be added to the current class.
(6) Select the Inner Classifies tab to define an inner class for this class. The inner class is a classifier of powerdesigner, in UML, a classifier is a model element that contains attributes and operations. After the definition is complete, you can observe the internal class code contained in the current class or interface through the Preview tab, as shown in 8-15.
Figure 8-15
(7) In addition to the above attributes, you can also define attributes such as associations,identifies. After the property is defined, it is created as shown in content 8-16.
Figure 8-16
5.2 Creating a contact
In the class diagram, contact is associated, dependent, generalized, and implemented.
6. Generating source code for Java
8-17 shows the class diagram, generating Java source code.
Figure 8-17
(1) Select the Language-generate Java Code command in the class diagram, open the Generation window, and display the classes contained in the model.
(2) On the Selection tab, in the Classes tab, select the class, and in the directory column, enter the destination path for the Java source code.
(3) Define Java build options in the Options tab.
(4) Define the Java build task options in the Tasks tab, as shown in 8-18.
Figure 8-18
(5) Click the "OK" button to start generating Java source files, and generate 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 8-19.
Figure 8-19
7. Generating class diagrams from Java code
(1) Select File-reverse Engineer-object language popup 8-20 shown.
Figure 8-20
(2) In the object Language bar select Java, click OK to enter the following interface, 8-21 shows.
Figure 8-21
(3) Click Add, add the Java file, click OK to generate the corresponding Java class diagram (in the reverse engineer bar can also select Java bytecode file or file directory), 8-23 shows.
Figure 8-23
PowerDesigner (eight)-object-oriented model (use case diagram, Sequence diagram, class diagram, generate Java source code and Java source code generation class diagram) (GO)