Download Session No. Presentation Title

Document related concepts
no text concepts found
Transcript
EN04
Object-Oriented Modeling with
PowerDesigner 9.5
Xiao Wang
PowerDesigner Chief Architect, EBD
[email protected]
Agenda

Introduction to modeling

Brief Overview of Object-Oriented Modeling and UML

PowerDesigner 9.5 overview

Designing an Object Model for a Java application
Creating J2EE components
Creating Web Service Components
Creating .NET applications
Reporting and Repository
Conclusion





Why Modeling?
Would you build a house without a blueprint?
The Architect will do the first
high level drawings to validate
the concept with its client
He will then make a detailed
plan for the Builders
The Builders will take this
blueprint and optimise it based
on technical constraints
History of Modeling & Design


Modeling techniques has been created a while ago
under the name CASE (Computer Aided Software
Engineering)
What is recognized has effective modeling and design
today?
 Database Modeling (Data Modeling), using E/R
(Entity/Relationship) techniques (standard), for IT users
 Application Modeling using UML (Unified Modeling
Language) techniques (standard), for IT users
 Business Process Modeling using emerging techniques, for
non IT users
Problem Statement




How to effectively model business-driven application?
Different techniques (E/R, UML, BP Modeling) have
forced corporations to buy different tools, raising
communication and co-ordination issues between
business analysts, IT analysts & designers and
application developers
Lack of common framework to store and manage
models and design induce inconsistencies across
applications and reduces ability to re-use existing
software
Heritage from CASE and complexity of techniques
and tools generate high costs in learning curve
Our Vision

An Enterprise Modeling and Design solution
 That will empowers our customers to model


software that meets the needs of end users
Fits the description of the business processes
Enable IT users to perform analysis and design,
and application development
Brief Overview of Object-Oriented Modeling

Why Use Object-Oriented Modeling?
 Visually define and communicate the structure and
behavior of an application
 Represent systems using OO concepts




Abstraction: Describe using relevant characteristics
Encapsulation: Combine Data and Methods
Inheritance: Supertype/Subtype
Polymorphism: Overloading and Overriding
 Link concepts to executable code
Brief Overview of UML

UML is defined by OMG.

UML consists of 9 diagrams:
 Static
 Class
and Object diagrams
 Dynamic
 Use
Case, Sequence, Statechart, Collaboration
and Activity diagrams
 Implementation

Component and Deployment diagrams
Use Case Diagram

A Use Case Diagram describes the Actors, the Use
Cases and the interaction between the Actors and
the Use Cases.
Display Catalog
<<includes>>
Logon
Purchase
<<includes>>
Logoff
Ship To Address
Customer
Shipping
List Orders
List Cart
Purchase Products
Main Use Case
News
Activity Diagram

An Activity Diagram
describes the logic of a
Use Case, a function or
another Activity.
Login Error
Main Page
Login
[No]
OK?
[Yes]
Display Catalog
Select Product
Purchase Products
Action Steps
Purchase
Check Out
Collaboration Diagram

A Collaboration Diagram describes the interaction
between objects by exchanging messages.
<<Servlet>>
Display Catalog
2.2: OK
3: Product List
<<Servlet>>
<<JSP>>
Main page
1: Login
Customer
Customer
2.1: Error
<<JSP>>
4: Purchase
Main page
Display Error
1: Login
2.2: OK
Add in Shopping Cart
<<Servlet>>
Validate Login
<<Servlet>>
Display Catalog
Validate Login
Sequence Diagram

A Sequence Diagram describes the interaction
between objects and how the messages are
exchanged over time.
<<JSP>>
<<Servlet>>
Main page
Validate Login
Display Error
Customer
open
1: Login
2.1: Error
2.2: OK
3: Product List
4: Purchase
<<Servlet>>
Display Catalog
Add in Shopping Cart
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 implementation code.
Example of a Class Diagram in
PowerDesigner
Peripheral
Computer
+ serial #
: String
+ ownerName : String
0..1
personalcomputers
+
+
+
+
registerPeriph ()
testPort ()
testPwSupply ()
testMotherBd ()
: void
: void
: void
: void
<<Persistent>>
parallelPeripheral
0..*
peripheral
+
+
+
+
+
+
+
peripheral tester
+
+
+
+
test #
: int
testName : String
testDate : java.util.Date
printReport () : void
periphId
: String
periphCodeName : String
vendorName
: String
registerPeriph () : void
testPort ()
: void
testPwSupply () : void
testMotherBd () : void
scanner
printer
+ laser
: boolean
+ printSpeed : int
+ printPage () : void
+
+
+
+
+
+
+
flatBed
: boolean
resolution : int
preview ()
: void
registerPeriph () : void
testPort ()
: void
testPwSupply () : void
testMotherBd () : void
Component Diagram



A Component Diagram can be used to define the
components we need to create for an appliacation
A Component can be using Classes, Interfaces,
Operations
EJBs, Servlets, JSPs and Web Services can be
represented as Components
Product
EntityBean_CMP
GetProductPageJSP
GetProductList
Servlet
Object-Oriented Modeling Best Practices
> Create an Analysis Object-Oriented Model (OOM) first
> Create Use Cases
> Create Collaboration Diagrams (identify classes)
> Create Sequence Diagrams (identify classes, operations)
> Create Architecture Diagram using Collaboration Diagram or
the Free Model
> Create Class Diagram
> Generate an Implementation OOM or refine the analysis OOM
> Create implementation components (EJBs, Servlets, Web
Services)
> Generate the code
> Complete the code with an IDE
> Reverse engineer the code to synchronize the model
PowerDesigner 9.5 Overview
Development
Source Sybase
Business-centric
Control Flow diagram
Entity/
Relationship
modeling
(and DW
extensions)
UML
modeling
(all diagrams)
RDBMS structures
Object Relational mapping
Java, .Net, XML, PB... support
IDEs & App Server support
Business
centric
Repository
Analysis
&
Design
Templates, Generic Generators,
UML profiles, model-to-model generation…
Business
Analysis
IT
centric
Repository
Architecture and Summary of Features
PowerDesigner
What’s new in 9.5 (1/3)



Data Modeling
 Database denormalization (table split or merge, copy columns)
UML/Object modeling
 Full UML support (all 9 diagrams)
Openness/Flexibility
 UML profile (sophisticated stereotypes): extension of meta classes,
customs symbols, custom checks, extended attributes, templates…
Model to model generation (logical model, several level of abstraction)
‘Free Model’ – graphical model customizable



BP Modeling
 Custom symbols, data (entity & items), swimlanes,
CRUD matrix, CDM generation from BP Model
PowerDesigner
What’s new in 9.5 (2/3)

Enhanced Web Services support
 Design and reverse-engineer (UDDI browser for meta


data extraction) Web Services
Deploy for Java and .NET
Enhanced J2EE support
 Servlet & JSP
 General improvements
 VBScript (repository, reports)
 Repository (logs and better property sheets)
 Custom symbols (shape, gradient, bitmap)
 Improved HTML report generator
PowerDesigner
What’s new in 9.5.1 (3/3)




Improve Web Services support (Web Services
deployment for J2EE (JSR109 specification))
Support new application servers (IBM WebSphere
5.0, BEA WebLogic 7, Apache Tomcat 4)
Integration with IDEs (JBuilder 7, Ant)
Support PowerBuilder 9.0
The PowerDesigner Object-Oriented Model

The PowerDesigner 9.5 OOM supports:
 All the 9 UML diagrams.
 Java, C#, VB .NET, C++, PowerBuilder, IDL, VB6, XML





and WSDL
Round-trip Java generation/reverse engineering
EJB including O/R mapping, Servlet, JSP
Web Services for Java and .NET
Data Model generation
O/R mapping
Designing an OOM for Java







Create a Class Diagram
Design packages, classes, interfaces,
attributes, operations, …
Preview the Java code
Implement the Java methods using an IDE
Generate the Java code
Reverse engineer Java classes
Iterative round-trip engineering
Defining Packages
Packages in UML:
 A logical container for objects that belong together
 Provides a way to partition and manage work
 Provides namespace scope for objects
 Packages in Java:
 Directory structure containing objects



Classes are known by their Package (path) and class
name
Packages in PowerDesigner:
 Add model management capabilities
 Ideally a container for related objects
Product Management
Defining Classes
 Generated Code:
Item
+
+
+
+
+
+
itemNumber : int
itemName : java.lang.String
itemPrice
: double
getItemNumber () : int
getItemName () : java.lang.String
getItemPrice ()
: double
The Item Class
/*************************************************
* Module: Item.java
* Author: xwang
* Modified: Friday, June 28, 2002 11:39:00 AM
* Purpose: Defines the Class Item
*************************************************/
package Product;
import java.util.*;
public class Item
{
public int itemNumber;
public java.lang.String itemName;
public double itemPrice;
public int getItemNumber()
{
return itemNumber;
}
public java.lang.String getItemName()
{
return itemName;
}
public double getItemPrice()
{
return itemPrice;
}
}
Defining Generalizations
> Generated Code:
Item
+ itemNumber : int
+ itemName : java.lang.String
+ itemPrice
: double
+ getItemNumber () : int
+ getItemName () : java.lang.String
+ getItemPrice ()
: double
/*************************************************
* Module: Product.java
* Author: xwang
* Modified: Friday, June 28, 2002 11:39:00 AM
* Purpose: Defines the Class Product
*************************************************/
package Product;
import java.util.*;
public class Product extends Item
{
public java.lang.String category;
Product
public java.lang.String getCategory()
{
return category;
}
+ category : java.lang.String
+ getCategory ()
: java.lang.String
+ setCategory (java.lang.String newCategory) : void
Generalization (Inheritance)
/** @param newCategory */
public void setCategory(java.lang.String
newCategory)
{
category = newCategory;
}
}
Defining Attributes
Defining Operations




Create operations
Generate default constructor, static initializer
Generate default getters and setters
Add operations defined in a parent classes or
interfaces
Implementing an Operation
Defining Associations


Associations are the relationships between
classes
Implementation depends on the definition of:
 Multiplicity: Is this a single reference or array?
 Navigability: Is there a reference variable?
 Visibility: Visibility of the reference variable
 Role Names: Name given to the reference
variable
Customer
+
+
+
+
customerID
customerName
phoneNumber
email
0..*
0..1
shippingAddress
Address
+
+
+
+
: int
: java.lang.String
: java.lang.String
: java.lang.String
0..*
0..1
billingAddress
addressID
street
zipCode
Attribute_4
: int
: java.lang.String
: int
: java.lang.String
Defining Interfaces
> Generated Code:
IItem
package Product;
import java.util.*;
+ getItemNumber () : int
+ getItemName () : java.lang.String
+ getItemPrice ()
: double
The IItem Interface
public interface IItem
{
int getItemNumber();
java.lang.String getItemName();
double getItemPrice();
}
Item
package Product;
import java.util.*;
+
+
+
+
+
+
itemNumber : int
itemName : java.lang.String
itemPrice
: double
getItemNumber () : int
getItemName () : java.lang.String
getItemPrice ()
: double
public class Item implements IItem
{
public int itemNumber;
public java.lang.String itemName;
public double itemPrice;
public int getItemNumber()
{
return itemNumber;
}
…
The Item Class
}
Object Reuse in PowerDesigner

Shortcuts
 PowerDesigner allows classes defined in one


package or model to be reused in other packages
and models via Shortcuts.
Shortcuts define an object that is outside the
model or package in question. It acts like a pointer
to the original object.
Replication Objects (new in V9.5)
 It is a copy of the original object. Users can
modify the original objects and the replicated
objects.
Preview the Java Code of a Class
Editing the Java Code in an IDE



PowerDesigner does not generate complete code
for all your methods. You have to implement them.
Users need to implement the methods using
PowerDesigner or an IDE (JBuilder, …)
You can use the Edit With feature to launch an
IDE. PowerDesigner will automatically copy the
modified Java code back in the model and
synchronize the model with the code.
Generating the Java Code

You can select the objects you want to generate,
the location and the generation options.
Generating the Java Code

You could compile the Java code, generate Java doc
and deploy components in an Application Server.
Develop, Deploy and Debug Using an IDE


You can use an IDE or a text editor to implement
the generated methods, compile the code, deploy
the application and debug the application.
PowerDesigner 9.5.1 generates a JBuilder 7
project file and an Ant build script that allow you to
compile and deploy you application outside
PowerDesigner.
Reverse Engineering Java Code
 Recover
Java code
 Reverse engineer from a .java or .class file
 Select from individual files, a directory or an
archive
 PowerDesigner
can create a new OOM or
extend an existing one
 Understand existing Java applications
 Capture a library for reference in other models
 Synchronize a model with externally edited
code
Iterative Round-Trip Engineering

Build and test as the Design matures:
 Create an OOM
 Generate Java code and edit in an IDE
 Reverse engineer the edited code to synchronize
the Model
 Modify the Model
 Generate new code from the updated Model
Creating J2EE Components



Creating Servlets
 Use Component and Class to represent a Servlet
Creating JSPs
 Use Component and File object to represent a JSP
Creating EJBs
 Use Component, Classes and Interfaces to represent an
EJB
Creating Servlets



Use the Create Servlet wizard to create a Servlet
Implement the Servlet code
Compile and deploy
GetProductList
Servlet
Servlet component
<<ServletClass>>
GetProductListServlet
+
+
+
+
+
init (..)
destroy ()
doGet (..)
doPut (..)
doPost (..)
: void
: void
: void
: void
: void
Servlet class
Creating Servlets

Implementing the Servlet methods
Creating Servlets



Generate Servlet code and Web Deployment Descriptor
Compile and create the .WAR file
Deploy the .WAR file
Creating JSPs
Use the Create JSP wizard to create a JSP
 Implement the JSP code
 Generate and deploy the .WAR file

GetProductPageJSP
Creating JSPs

Implementing the JSP code using the internal
editor or an external editor (DreamWaver, …)
GetProductPageJSP
Defining O/R Mapping and Creating EJBs






Designing the objects
Designing the database for objects persistence
Defining the O/R mapping
Creating EJBs (Enterprise Java Beans)
Generating EJBs and O/R mapping descriptor
Deploy EJBs
Designing the Database


PowerDesigner is also a very powerful Database
Design tool
Bi-level Database Design
 Conceptual Data Model (CDM)

Normalized, Implementation (RDBMS) independent
 Physical Data Model (PDM)

Database Specific: Generates DDL to a script or to database
live via an ODBC connection
Example of a PDM for Sybase SQL
Anywhere
/*======================================================*/
/* Table: customer
customer
id
fname
lname
address
city
state
zip
phone
company_name
integer <pk>
char(15)
char(20)
char(35)
char(20)
char(2)
char(10)
char(12)
char(35)
*/
/*======================================================*/
create table DBA.customer
(
id = cust_id
id
integer
not null default autoincrement,
fname
char(15)
not null,
lname
char(20)
not null,
address
char(35)
not null,
city
char(20)
not null,
state
char(2)
not null,
zip
char(10)
not null,
phone
char(12)
not null,
company_name char(35),
primary key (id)
sales_order
id
cust_id
order_date
fin_code_id
region
sales_rep
integer <pk>
integer <fk>
date
char(2)
char(7)
integer
);
/*======================================================*/
/* Index: ix_cust_name
*/
/*======================================================*/
create
index ix_cust_name on DBA.customer (
lname ASC,
fname ASC
)
with hash size 10;
Generating and Reverse Engineering
Database

PowerDesigner captures existing database
structures and translates them to Java:
 Reverse engineer the Database to a PDM
 Generate an OOM (Java) from the PDM




Gives Object Designers a view of existing database objects
Jump-start to building Business Logic
Generate the O/R mapping
PowerDesigner can translate a class diagram into a
PDM:
 Generate a PDM (tables, columns, indexes, references,
O/R mapping, …)
 Optimize the database (triggers, tablespace,
denormalization)
 Generate the database
Defining the Object/Relational Mapping





Generate O/R mapping when generating a PDM
from an OOM
Generate O/R mapping when generating an OOM
from a PDM
Customize the O/R mapping to support complex
mappings
Customize the O/R mapping syntax for each
application server
Support EJB-QL and stored-procedures
Example of the O/R Mapping

O/R mapping syntax for Sybase EAServer:
Java in the Database (RDBMS)

Use PowerDesigner to model Java in the
Database:
 Create OOM for Java Stored Procedures and Java Data



Types
Create a PDM for the Database (Target your RDBMS)
Reuse objects from the OOM in the PDM as Data Types
Generate .java from the OOM to “import” to server to
support Data Types and add Stored Procedures
Creating Enterprise Java Beans (EJBs)

PowerDesigner supports CMP Entity Beans, BMP Entity
Beans, Stateless Session Beans, Statefull Session Beans
and Message Driven Beans.

PowerDesigner generates the source code, the deployment
descriptor and the O/R mapping descriptor.

PowerDesigner could compile the code, create the JAR file,
run J2EE verifier and deploy the JAR file.

PowerDesigner supports Sybase EAServer, BEA WebLogic
and Cocobase today. Support of other servers could be
added by creating a profile.
Creating a Container Managed Persistence
(CMP) EJB








Create a package
Create a class inside the package
Generate or define the O/R mapping
Use the Create Enterprise JavaBean wizard to create
a CMP EJB
Set properties (transaction, …)
Implement additional business methods
Verify the source code and the deployment descriptor
Generate the code, compile, verify and deploy
Example of a CMP EJB

customer
EntityBean_CMP
Example of the EJB wizard:
The EJB component
<<EJBEntity>>
customerBean
{abstract}
+
+
+
+
+
+
+
+
+
-
id
fname
lname
address
city
state
zip
phone
company_name
ejbContext
: java.lang.Integer
: java.lang.String
: java.lang.String
: java.lang.String
: java.lang.String
: java.lang.String
: java.lang.String
: java.lang.String
: java.lang.String
: EntityContext
+
+
+
+
+
+
+
+
customerBean ()
ejbActivate ()
:
ejbLoad ()
:
ejbPassivate ()
:
ejbRemove ()
:
ejbStore ()
:
setEntityContext (EntityContext ctx) :
unsetEntityContext ()
:
The Bean class
void
void
void
void
void
void
void
Generating EJBs


Use Tools>Generate Java Code to generate EJBs
Select the tasks to perform after the code generation
Creating Web Services

PowerDesigner V9.5 supports:
 Creating Web Services components for Java and .NET
 Generating server side code for Java and .NET
 Generating client proxy code for Java and .NET
 Browsing UDDI to find Web Services (WSDL)
 Importig and generating WSDL
Creating Web Services for Java

For Java, PowerDesigner V9.5 supports:
 Java Web Service using JAXRPC
 Servlet Web Service using JAXM
 Generating server side code and client proxy using

JAXRPC tool
Deploying EJBs as Web Services when the « Web
Services for J2EE » (JSR109) specification will be
finalized
Creating a Servlet Web Service




Use the Create Web Service wizard to create a Servlet
Web Service
Select Java Servlet as the Component type
Implement the onMessage() method
Compile and deploy
<<Web Service>>
SalesOrder
Implementation
<<ServletClass>>
SalesOrderServlet
+ init (..)
: void
+ destroy ()
: void
+ onMessage (..) : javax.xml.soap.SOAPMessage
Create a Web Service Component Using
JAX-RPC






Use the Create Web Service wizard to create a Web
Service
Select Standard as the Component type
In the Java class, create one or several methods
Indicate these methods as Web Method
Implement these methods
Generate the Java code:
 In the generation window, select the XRPCC commands to
generate server side and/or client side code
Example of the Generated WSDL
Deploy EJBs as Web Service Components


PowerDesigner 9.5.1 uses the «J2EE for Web
Services» (JSR109) specification to generate
deployment descriptor and .EAR file to deploy
Stateless Session Beans as Web Services.
EAServer 5.0 will support JSR109.
Browse UDDI to Search Web Services

PowerDesigner V9.5 provides a UDDI browser to allow
users to search Web Services (search WSDL)
Import WSDL


PowerDesigner V9.5 imports WSDL files or URLs
(found in UDDI)
PowerDesigner creates Web Service component from
the WSDL
Creating .NET Applications

With PowerDesigner 9.5, you can:
 Create .NET applications for C# or VB .NET
 Generate C#, VB .NET code
 Compile C#, VB .NET code
 Create Web Services for .NET
 Create ASP .NET (ASPX) components
 Use the .NET Framework library model
 Future version will support reverse engineering for C#
and VB .NET
Extending PowerDesigner’s Features

Users could extend PowerDesigner’s features:
 Use the template based generic generator (GTL) to
generate other Java components (JDO, Ant build script,
unit test programs, …)
 Use VB Script or VBA to work directly with the
PowerDesigner models (import, export, generate more
complex code, …)
 Use XMI import/export to integrate with other code
generators
Documentation and Reporting

PowerDesigner provides comprehensive reporting
capabilities
 Print Graphics to see model diagrams
 Create Report to include objects metadata
 Multi-model report to span all models in a workspace
 Report Print Preview
 Generate HTML or RTF reports
 Multi-language support (English, Chinese, …)
Repository

PowerDesigner has an enterprise repository for
model sharing and management
 Consolidation/Extraction of Models and other non-




PowerDesigner files
Object level versioning
Branching, Configurations
Security
Open Database: (RDBMS vs. flat-file system)

Write your own reports using SQL or other reporting tools
(InfoMaker, Crystal Reports, etc…)
Conclusion

With PowerDesigner 9.5, you can:
 Create all UML diagrams
 Analyse, design and develop Java or .NET applications
 Generate the database and O/R mapping from your OO
design
 Support full Round-Trip Iterative development of Applications
 Produce documents and reports for your OO design
 Use the enterprise repository for team work and versioning

PowerDesigner 9.5 is a complete enterprise modeling
tool
More information


Sybase China web site for PowerDesigner:
http://www.sybase.com.cn/cn/content/goto.jsp
?resID=87
Sybase US web site for PowerDesigner:
http://www.sybase.com/powerdesigner/
 Whitepapers, knowledgebase, tech support, and
evaluation copies


News group:
powersoft.public.powerdesigner.general
SDN: http://www.sybase.com/developer