® ibm software group © 2009 ibm corporation essentials of modeling with ibm rational software...

34
® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

Upload: kristian-doyle

Post on 17-Jan-2018

217 views

Category:

Documents


0 download

DESCRIPTION

3 Where are we?  Asset- and pattern-based development  Applying design patterns  Applying transformations  Packaging reusable assets

TRANSCRIPT

Page 1: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

®

IBM Software Group

© 2009 IBM Corporation

Essentials of Modeling with IBM Rational Software Architect, V7.5

Module 18: Applying Patterns and Transformations

Page 2: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

2

Applying patterns and transformationsObjectives:

Apply reusable assets in the development process. Apply a pre-built design pattern in Rational Software

Architect. Perform model transformations

– Forward transformations– Reverse transformations

Page 3: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

3

Where are we?Asset- and pattern-based developmentApplying design patterns Applying transformationsPackaging reusable assets

Page 4: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

4

What is a pattern? A solution to a recurring problem in a given context.

Patterns abstract a way of solving a design problem from the details of any particular technology

A pattern:Provides a solution to a specific problemRequires a strategy for applying the pattern in its context.Comes with consequences (advantages and

disadvantages) of applying the pattern.

Page 5: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

5

Benefits of using patternsPatterns:

Increase productivity Simplify and accelerate building and testing Eliminate repetitive work Make development easier and more instructive for beginners

Improve software governance, for: Achieving architecture consistency Enforcing architectural decisions Enforcing design and coding standards

Increase quality Apply best practices for functional and non-functional requirements Leverage expert skills within the development organization

Increase openness Reuse and share existing architectural specifications Create less dependency on a specific tools vendor or platform

Page 6: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

6

Patterns in Rational Software ArchitectThree features for automating model development with patterns: Design Patterns: Add details to the

model. Provide model markup and structures that can be transformed into code. Observer pattern Session Facade pattern

Transformations: Translate elements from one model into elements in a different model1. Model-to-model 2. Model-to-code3. Code-to-model

Java Emitter Templates (JET) transformations: a type of transformation that provides customizable, text-based transformations and code templates Transformations

Pattern

1

2

3

Page 7: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

7

The Pattern Explorer view

Design Pattern

Transformation

JET Transformation

Right-click to apply, copy, move, or configure the pattern, or to view documentation.

Icons in the Pattern Explorer view

Page 8: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

8

Accelerating model-driven development

Platform-Independent

Model

Code-based Development

Apply Patterns

Apply Patterns

Apply Patterns

ITER

ATE

Forward Transform(embedded patterns) Reverse Transform

(embedded patterns)

Apply Patterns

Forward Transform(embedded patterns) Reverse Transform

(embedded patterns)

Forward Transform(embedded patterns) Reverse Transform

(embedded patterns)

Forward Transform(embedded patterns) Reverse Transform

(embedded patterns)

Application Design (high abstraction)

Implementation

Application Use-Cases

Application Analysis

ComputationalIndependent

Model

Platform-Specific Model

Business AnalysisBusiness Process Models

Business Use-Cases

Model-Driven Architecture RUP Methodology

Platform-specific model markup

Page 9: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

9

Reuse sets of artifacts: reusable assetsA reusable asset is an organized collection of

artifacts that provides a solution to a problem for a given context.

A reusable asset contains:Artifacts: Patterns,

transformations, profiles, pluglets, model templates, and so on.

Variability points:Allow users to customize the asset for a specific project Artifact

Artifact

Artifact

Artifact

Variability Point

Problem

Solution

Page 10: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

10

Asset-driven developmentReuse requirements, design, test, and

deployment assets to develop new or enhance existing applications

Supported by IBM® Rational® products with:Process

guidanceToolingStandardsAssets

AssetManagement

Asset Production

AssetConsumption

Feedback

Feedback

Asset Identification

CandidateAsset

Program Management

The Asset Lifecycle

Page 11: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

11

Where are we?Asset- and pattern-based developmentApplying design patterns Applying transformationsPackaging reusable assets

Page 12: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

12

Design patterns in Rational Software Architect A design pattern in Rational Software Architect adds

details to a model automatically. Use design patterns to add:

Model elements and relationships Classes, packages, and so on

Details to model elements Attributes, operations

Markup to the model Stereotypes from a UML profile

recognized by transformations A design pattern:

Has parameters that are used to bind the pattern to the model

Can be reapplied to or unbound fromthe model

Usually affect small areas of the model when applied

Page 13: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

13

Design pattern notation

Parameters

Pattern InstanceA UML Collaboration

Binding Indicator

Parameter Type

Multiplicity Bound Arguments

Page 14: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

14

Applying a design patternCreate a pattern instance by dragging a pattern from the Pattern Explorer view to an open diagram, or to a model in the Project Explorer view.

1

Drag an existing class from the diagram or Project Explorer view to a pattern parameter to make it an argument of the pattern, or…

2Use the action bar to create an argument value for a parameter.3

Page 15: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

15

Gang of Four (GoF) design patterns Rational Software Architect

has the 23 GoF design patterns built in:Can be used as the basis for

custom patternsThese patterns support widely

recognized best practicesHelp seed the code with

transformation extensions Example

Observer is a GoF behavioral design pattern:

One-to-many dependency between objects

When one object changes state, observers are notified and updated automatically

Page 16: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

16

Demo: Applying a design patternThe instructor will now show you how to:Select the patternCreate a pattern instanceBind new elements to the patternBind existing elements to the pattern

Page 17: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

17

In this lab, you will complete the following tasks:Examine the Patterns Explorer viewApply a design pattern

Lab 18.1: Apply patterns

To begin the lab:

In the workbench, click Help > Cheat Sheets to open the Cheat Sheet Selection dialog.

Expand Essentials of Modeling Labs. Double-click 18 Apply patterns and run transformations.

Select Apply patterns in the Cheat Sheet view

Follow the directions indicated on the Cheat Sheet.

Page 18: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

18

Where are we?Asset- and pattern-based developmentApplying design patterns Applying transformationsPackaging reusable assets

Page 19: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

19

Transformations Transformations create elements in a

target model (domain) based on elements from a source modelOften, the source domain is more abstract

than the target domain Examples:

Based on a use-case model, create an analysis model that realizes the use cases following a modeling standard

Based on the analysis model, create a design model that incorporates elements of the company’s security and persistence frameworks, and follows a modeling standard

Starting with a UML model, apply a built-in transformation to create code elements

Take existing code and apply a transformation to abstract out the design elements.

Transformations

Page 20: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

20

Transformations in Rational Software Architect The following transformations

are built in to Rational Software Architect:UML to UML

UML to LDMUML to code

UML to Java V1.4 UML to Java V5.0 UML to C++ UML to EJB UML to WSDL UML to XSD

Code to UML C++ to UML Java to UML

Transformations can be custom built using the Plug-in Development Environment.

Page 21: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

21

Running a transformation Create a new instance (configuration) of the

transformation Choose an appropriate project target Choose how to manage source-to-target traceability

Transformation Configuration

Source

Transformation

Target

Page 22: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

22

Create a transformation configurationA transformation configuration is an instance of a transformation with a specific:NameSourceTarget

Page 23: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

23

Synchronization properties Control source and target synchronization with the Protocol

setting:Conceptual: Changes in the source are propogated to the target

(source-focused)Mixed: Transformed elements in the source are replaced with references

to target elements (target-focused)Reconciled: Source and target evolve independently and need to be

synchronized Enables the reverse transformation

Page 24: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

24

Reconciliation: Merge the transformed modelThe combine dissimilar models feature is used when you apply a reverse transformation to update a conceptual model from code.

Pending Changes•Mark changes from source model to be applied to target model.

Source Model Target Model

Change Description

Page 25: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

25

UML visual developmentC++ and Java code can be visualized with class and sequence diagramsChanges to the code update the diagramChanges to the diagram update the codeHarvest classes into UML models

Page 26: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

26

Concurrent code and model development

Reverse transformations allow for the concurrent development of UML models and code

ArchitectureV1.0

ArchitectureV1.1

ArchitectureV1.1+

ReconcileUML Model of

Implementationv1.1

ImplementationV1.0

ImplementationV1.1

ImplementationV1.1+

Model CombineAccepted change

Reverse Transformation

Iterate

Forward Transformation(omit rejected change)

IterateIntroduce an architectural deviation

Forward Transformation

Page 27: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

27

Demo: Apply a transformationThe instructor will now show you how to:

Create a UML to Java transformationTransform UML classes to Java classesReview the code

Page 28: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

28

In this lab, you will complete the following tasks:Create a transformationTransform UML classes to Java codeReview the codeModify a generated Java class and reconcile the code with the UML

model

Lab 18.2: Run a UML to Java transformation

To begin the lab:

In the workbench, click Help > Cheat Sheets to open the Cheat Sheet Selection dialog.

Expand Essentials of Modeling Labs. Double-click 18 Apply patterns and run transformations.

Select Run a UML to Java Transformation in the Cheat Sheet view

Follow the directions indicated on the Cheat Sheet.

Page 29: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

29

Where are we?Asset- and pattern-based developmentApplying design patterns Applying transformationsPackaging reusable assets

Page 30: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

30

Building custom artifacts

Supporting creation of these artifacts in Rational Software Architect are:The Plug-in Development Environment (PDE)Reusable Asset Specification (RAS) Import and Export

Plug-ins PlugletsModel Templates

UML Profiles TransformationsDesign Patterns

Page 31: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

31

Sources for artifacts

Patterns, transformations, and other artifacts are not limited to artifacts you create for yourself. They can come from a variety of sources.

IBM Rational Software

Peer Groups

Your Group

Third-Party Software Companies

Solution inRational Software

Architect

Page 32: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

32

Patterns and transformations as reusable assets Related patterns and

transformations can be grouped in libraries.

Patterns and transformations can reside in the same Eclipse plug-in.

Plug-ins can be grouped and exchanged in RAS format.

Eclipse Plug-in

Patterns Library

RAS Asset

Eclipse Plug-in

Patterns Library

Page 33: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

33

Review How many levels of abstraction are needed

when creating a software solution? What is a pattern? What tools exist to help build your own

patterns?

Page 34: ® IBM Software Group © 2009 IBM Corporation Essentials of Modeling with IBM Rational Software Architect, V7.5 Module 18: Applying Patterns and Transformations

34

Further information Web sites Books Articles