19
PowerDesigner 与与与与与

PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

Embed Size (px)

Citation preview

Page 1: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

PowerDesigner 与对象建模

Page 2: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

2

Why Using UML?

• Visually define and communicate the structure and behavior of an application

• Represent systems using Object-Oriented concepts

• Link OO concepts to executable code

Page 3: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

3

Brief Overview of UML

• UML is defined by OMG.• UML consists of 9 diagrams:

– Static– Class diagram– Object diagram

– Dynamic– Use Case diagram– Sequence diagram– Statechart diagram– Collaboration diagram – Activity diagram

– Implementation– Component diagram – Deployment diagram

Page 4: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

4

UML Support in PowerDesigner

• PowerDesigner supports all nine UML diagrams

• PowerDesigner supports UML 1.4

• Future version of PowerDesigner will support UML 2.0

Page 5: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

5

Use Case Diagram

• A Use Case Diagram describes the Actors, the Use Cases and the interaction between the Actors and the Use Cases.

<<includes>>

<<includes>>

Logon

Logoff

CustomerShip To Address

Purchase

Display Catalog

List Orders

List Cart

News

Shipping

Page 6: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

6

Collaboration Diagram

• A Collaboration Diagram describes the interaction between objects (instance of classes) by exchanging messages.

• Collaboration Diagram can be used to identify classes and operations

2.2: OK

1: Login

Customer<<JSP>>

Main page

<<Servlet>>

Validate Login<<Servlet>>

Display Catalog

4: Purchase

2.2: OK

3: Product List

2.1: Error

1: Login

Customer

<<JSP>>

Main page

<<Servlet>>

Validate Login

Display Error

<<Servlet>>

Display Catalog

Add in Shopping Cart

Page 7: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

7

Sequence Diagram

• A Sequence Diagram describes the interaction between objects and how the messages are exchanged over time.

• Sequence Diagram is used to identify classes and operations

open

4: Purchase

2.2: OK

3: Product List

2.1: Error

1: Login

<<JSP>>

Main page

<<Servlet>>

Validate Login Display Error<<Servlet>>

Display Catalog Add in Shopping Cart

Customer

Page 8: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

8

Activity Diagram

• An Activity Diagram describes the logic and the control flow of a Use Case, an Operation or another Activity.

[No]

[Yes]

Main Page

Login

Display Catalog

Purchase

Select Product

OK?Login Error

Purchase Products Action Steps

Check Out

Page 9: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

9

Statechart Diagram

• A Statechart Diagram is used to model the States and Transitions of a Class

Intial

Play

Pause

Page 10: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

10

Object Diagram

• An Object Diagram shows the relationships between Object Instances

:Customer

idname

= 101 = "XiaoYun Wang"

:Order

iddate

= 1 = 3/25/2004

Page 11: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

11

Class Diagram

• A Class Diagram defines the Classes, Interfaces, Attributes, Operations, Relationships, Inheritances, …

• A Class Diagram can be used to define persistent objects, control objects and user-interface objects.

• A Class Diagram can be used to generate the Physical Data Model and the application implementation code.

0..*peripheral

0..1personalcomputers <<Persistent>>

parallelPeripheral

+++

periphIdperiphCodeNamevendorName

: String: String: String

++++

registerPeriph ()testPort ()testPwSupply ()testMotherBd ()

: void: void: void: void

printer

++

laserprintSpeed

: boolean: int

+ printPage () : void

scanner

++

flatBedresolution

: boolean: int

+++++

preview ()registerPeriph ()testPort ()testPwSupply ()testMotherBd ()

: void: void: void: void: void

Peripheral

++++

registerPeriph ()testPort ()testPwSupply ()testMotherBd ()

: void: void: void: void

peripheral tester

+++

test #testNametestDate

: int: String: java.util.Date

+ printReport () : void

Computer

++

serial #ownerName

: String: String

Page 12: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

12

Component Diagram

• A Component Diagram can be used to define the components you need to create for an application

• A Component can use Classes, Interfaces

• PowerDesigner uses Components to represent EJBs, Servlets, JSPs, ASPs and Web Services

Product

EntityBean_CMP

GetProductList

Servlet

GetProductPageJSP

Page 13: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

13

Deployment Diagram

• A Deployment Diagram is used to define the deployment architecture

• Deployment Diagram shows the Nodes (machines, servers), the Component Instances deployed in a Node and the Links between Nodes

<<J2EE Server>>

Jaguar

easerver.sybase.comCustomerBeanOrderBeanProductBean

<<Web Service>>Web Service158.126.19.3

<<Database>>CRM

Page 14: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

14

Object/Relational (O/R) Mapping

• Generate a Class Diagram from a Physical Data Model with O/R mapping

• Generate a Physical Data Model from a Class Diagram with O/R mapping

• Manually define complex O/R mapping

• Generate select, insert, update, delete SQL statements

• Use O/R mapping to generate EJB CMP (WebLogic, WebSphere, EAServer), JDO, Cocobase, .NET (future)

Page 15: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

15

O/R Mapping Example

Generate O/R mapping when generating a PDM from an OOM

Use O/R mapping to generate SQL

Page 16: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

16

Java Support

• Provide wizards to automatically create EJBs, Servlets, JSPs, Web Services

• Generate and reverse engineer Java code

• Generate collection management accessor functions

• Generate deployment descriptors

• Generate O/R mapping descriptor for WebLogic, WebSphere, EAServer, JDO, JBoss (future)

• Generate project files for JBuilder and Eclipse

• Generate Ant script to compile, package and deploy J2EE application

Page 17: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

17

<<EJBEntity>>CustomerBean

{abstract}

-----

idnameemailphoneejbContext

: java.lang.Integer: java.lang.String: java.lang.String: java.lang.String: EntityContext

++++++++

<<Constructor>> CustomerBean ()ejbActivate ()ejbLoad ()ejbPassivate ()ejbRemove ()ejbStore ()setEntityContext (..)unsetEntityContext ()

: void: void: void: void: void: void: void

<<EJBPrimaryKey>>

CustomerPK

- id : java.lang.Integer

+++

<<Constructor>> CustomerPK ()equals (..)hashCode ()

: boolean: int

<<EJBRemote>>

Customer

<<EJBLocal>>

CustomerLocal

<<EJBRemoteHome>>

CustomerHome

+ <<EJBFinderMethod>> findByPrimaryKey (..) : Customer

<<EJBLocalHome>>

CustomerLocalHome

+ <<EJBFinderMethod>> findByPrimaryKey (..) : CustomerLocal

Example of EJB

EJB wizard

EJB Classes and Interfaces

Customer

EntityBean_CMP

EJB Component

Page 18: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

18

.NET Support

• Reverse engineer C# and Visual Basic .NET code

• Reverse engineer .NET binary code in C# or VB .NET

• Generate C# and VB .NET code

• Generate collection management accessor functions

• Generate Visual Studio .NET project files

• Create Web Services for C# or VB .NET (.asmx files)

Page 19: PowerDesigner 与对象建模. 2 Why Using UML? Visually define and communicate the structure and behavior of an application Represent systems using Object-Oriented

19

Code Generation

• Templates and macros based code generator

• Generate Java, C#, VB .NET, VB, C++, PowerBuilder, …

• User could add their own code generation templates

C# code preview