31
Product Line Annotations with UML-F Wolfgang Pree Software Research Lab Univ. of Salzburg Austria [email protected] Marcus Fontoura IBM Almaden Research, San Jose U.S.A. [email protected] Bernhard Rumpe Software Engineering Munich Tech. Universi Germany [email protected]

Product Line Annotations with UML-F Wolfgang Pree Software Research Lab Univ. of Salzburg Austria [email protected] Marcus Fontoura IBM Almaden Research, San

Embed Size (px)

Citation preview

Product Line Annotations with UML-F

Wolfgang PreeSoftware Research Lab

Univ. of Salzburg Austria

[email protected]

Marcus FontouraIBM Almaden

Research, San JoseU.S.A.

[email protected]

Bernhard RumpeSoftware Engineering

Munich Tech. UniversityGermany

[email protected]

© 2002, M. Fontoura, W. Pree, B. Rumpe 2SPLC2, San Diego, CA, USA

Contents

Motivation UML-F

Presentation tags and basic modeling tags Tags for the essential framework construction

principles GoF framework pattern tags Tags for other pattern catalogs and domain-specific

patterns

© 2002, M. Fontoura, W. Pree, B. Rumpe 3SPLC2, San Diego, CA, USA

Motivation What is a profile? Why UML-F? Goals

© 2002, M. Fontoura, W. Pree, B. Rumpe 4SPLC2, San Diego, CA, USA

What is a UML profile?

an extension of the UML standard language with specific elements

A profile provides new notational elements, and usually specializes the semantics of some

elements. It may also restrict the use of UML elements.

© 2002, M. Fontoura, W. Pree, B. Rumpe 5SPLC2, San Diego, CA, USA

Why UML-F?

It takes a considerable effort to learn and understand a framework. Standard UML does not offer the notational elements tailored to that purpose.

The extensions summarized as UML-F profile support framework development and adaptation. The UML-F profile focuses on pinpointing a framework’s variation points.

© 2002, M. Fontoura, W. Pree, B. Rumpe 6SPLC2, San Diego, CA, USA

Goals of UML-F

UML-F provides the notational elements to precisely annotate and document design patterns.

UML-F is itself structured in the spirit of frameworks, i.e., an extensible profile.

UML-F comprises a lean, memonic set of notational elements.

UML-F relies on the UML standard, that is, UML-F extends UML using existing UML extension mechanisms.

The UML-F notational elements are adequate for being integrated in UML tool environments.

© 2002, M. Fontoura, W. Pree, B. Rumpe 7SPLC2, San Diego, CA, USA

UML-F

© 2002, M. Fontoura, W. Pree, B. Rumpe 8SPLC2, San Diego, CA, USA

UML-F extension structure

aa

UML-F tag sets for framework construction principles

UML-F tag sets for framework-related GoF patterns

UML-F tags for templates and hooks

UML-F tag sets for other pattern catalogs or domain-specific patterns

Basic UML-F modeling and presentation tags

relies on

Factory Method

Template Method Bridge

State

Strategy

Observer

Command

Builder Abstract Factory

Prototype

Interpreter

Unification Separation

Composite

Chain-Of-Responsibility

Decorator

«template» «hook»

Calculation . . .

© 2002, M. Fontoura, W. Pree, B. Rumpe 9SPLC2, San Diego, CA, USA

UML-F diagrams

UML-F only enhances the following UML diagrams:

class/object diagrams sequence diagrams

© 2002, M. Fontoura, W. Pree, B. Rumpe 10SPLC2, San Diego, CA, USA

UML-F tag mechanism

UML 1.3/1.4 provides «stereotypes» and {tag=value} pairs stereotypes are restricted: no value attached, only one

per model element Tagged value pairs are more flexible and combinable

UML-F unifies both in the “tag-mechanism”, by writing «tag:5» and {tag=5} interchangeably «tag» is short for «tag:True» «tag1,tag2» is OK Special forms of tags, e.g. “©” instead of

«complete:True» Tag values have types (e.g. Boolean,String,Integer)

© 2002, M. Fontoura, W. Pree, B. Rumpe 11SPLC2, San Diego, CA, USA

Presentation tags

© 2002, M. Fontoura, W. Pree, B. Rumpe 12SPLC2, San Diego, CA, USA

Presentation tags (I)

Human

getHeight()celebrateBirthday()

height: Int

Human

Human

getHeight()celebrateBirthday()

age: Intheight: Int

©

©

completeness tag

incompleteness tag

© 2002, M. Fontoura, W. Pree, B. Rumpe 13SPLC2, San Diego, CA, USA

Presentation tags (II)

Employee

+acceptNewJob()+isMarried()+celebrateBirthday()

+salary: Money new

redefined withsuper()-call

new defined

Human

getHeight()isMarried()celebrateBirthday()

age: Int height: Int

Employee

acceptNewJob()isMarried()celebrateBirthday()

salary: Money

Human

#getHeight()+isMarried()+celebrateBirthday()

+age: Int#height: Int

©

©

Employee

getHeight()acceptNewJob()isMarried()celebrateBirthday()

salary: Money age: Int height: Int

(a) Standard UML (b) Hierarchical view in UML-F

(c) Expanded (flat) view in UML-F

©

indicates expanded (flat) view

indicates hierarchical view

inherited

abstract

newly defined

redefined incl. super()-call

© 2002, M. Fontoura, W. Pree, B. Rumpe 14SPLC2, San Diego, CA, USA

Presentation tags (III)

white rectangle: the method is inherited and not redefined

gray rectangle: the method is either newly defined, or it is inherited, but completely redefined

half gray / half white rectangle: the method is redefined, but uses the inherited method through a super() call

don’t care rectangle: the diagram does not reveal any information (can actually be either of the above three)

© 2002, M. Fontoura, W. Pree, B. Rumpe 15SPLC2, San Diego, CA, USA

Basic modeling tags

© 2002, M. Fontoura, W. Pree, B. Rumpe 16SPLC2, San Diego, CA, USA

Basic modeling tags (I)

«framework»Composite

*

parts

«application»Leaf1

«application»Leaf2

«framework»Component

«utility»String

«utility»FileOutputStream

where a class belongs

© 2002, M. Fontoura, W. Pree, B. Rumpe 17SPLC2, San Diego, CA, USA

Basic modeling tags (II)

…«application»MyTest

foo()

…«framework»Test

foo() «fixed»

no overridingof a «fixed» methodin «application» classes

© 2002, M. Fontoura, W. Pree, B. Rumpe 18SPLC2, San Diego, CA, USA

Basic modeling tags (III)

…A

foo() «adapt-static»

… «adapt-static» method can be overridden in subclasses

… A-sub2

foo()

… A-sub3

foo()

… A-sub1

foo()

© 2002, M. Fontoura, W. Pree, B. Rumpe 19SPLC2, San Diego, CA, USA

Basic modeling tags (IV)

«framework»A1

«application»B2

«application»B1

«framework»A

«framework»A2

«fixed»

A «fixed» generalization forbidsadding direct subclasses on that level

© 2002, M. Fontoura, W. Pree, B. Rumpe 20SPLC2, San Diego, CA, USA

UML-F tags for the essential framework

construction principles

© 2002, M. Fontoura, W. Pree, B. Rumpe 21SPLC2, San Diego, CA, USA

Template and hook tags (I)

aaa

CurrencyConverter

convert(...)

round(val: double): double. . .

«template»

«hook»

«template, hook»

aaa

CurrencyConverter

convert(...)round(val : double): double

«template, hook: Rounding»

«template: Rounding»«hook: Rounding»

© 2002, M. Fontoura, W. Pree, B. Rumpe 22SPLC2, San Diego, CA, USA

Template and hook tags (II)

aaa

Account

calcBalance(...). . .

«template: Conversion»

«template: Conversion»

CurrencyConverter

convert(...)round(val: double): double

«template, hook: Rounding»

«template: Rounding»«hook: Rounding»

«hook: Conversion»

«hook: Conversion»

aaaa

CurrencyConverter

convert(...)

round(val: double): double. . .

Account

calcBalance(...)

. . .

template: Conversion hook: Conversion

Template-Hook Groups

RoundingConversion. . .

possible tool support:

© 2002, M. Fontoura, W. Pree, B. Rumpe 23SPLC2, San Diego, CA, USA

Tags for Unification (I)

aaa

TH

t()

h()

«Unif–t»

«Unif–h»

«Unif–TH»tags are derived

from the structure

aaa

CurrencyConverter

convert(...)round(val: double): double

«Unif–TH: Rounding»

«Unif–t: Rounding»

«Unif–h: Rounding»

example:

© 2002, M. Fontoura, W. Pree, B. Rumpe 24SPLC2, San Diego, CA, USA

Tags for Unification (II)

rationale behind the tags:

aaa

TH

t()

h()

Unificationconstruction principle

CurrencyConverter

convert(...)round(val: double): double

«Unif–TH: Rounding»

«Uni f–t: Rounding»«Uni f–h: Rounding»

«template»

«hook»

© 2002, M. Fontoura, W. Pree, B. Rumpe 25SPLC2, San Diego, CA, USA

Tags for Separation

example:

aa

T

t()

H

h()«Sep–t» «Sep–h»

«Sep–T» «Sep–H»

aaa

Account

calcBalance(...). . .

«Sep–T: Conversion»

«Sep–t: Conversion»

CurrencyConverter

convert(...)round(val: double) : double

«Sep–H: Conversion»

«Sep–h: Conversion»

© 2002, M. Fontoura, W. Pree, B. Rumpe 26SPLC2, San Diego, CA, USA

UML-F tags for the GoF framework patterns

© 2002, M. Fontoura, W. Pree, B. Rumpe 27SPLC2, San Diego, CA, USA

UML-F extension structure

aa

UML-F tag sets for framework construction principles

UML-F tag sets for framework-related GoF patterns

UML-F tags for templates and hooks

relies on

Factory Method

Template Method Bridge

State

Strategy

Observer

Command

Builder Abstract Factory

Prototype

Interpreter

Unification Separation

Composite

Chain-Of-Responsibility

Decorator

«template» «hook»

© 2002, M. Fontoura, W. Pree, B. Rumpe 28SPLC2, San Diego, CA, USA

Strategy pattern (I)

aaaaa

Context

contextInterface()

Strategy

algorithmInterface()

algorithmInterface()

ConcreteStrategy

strategy

«adapt-static»

anOp()

strategy.algorithmInterface()

Structure (according to GoF book):

«Strategy–Context», «Strategy–anOp», «Strategy–contextInterface»,

«Strategy–strategy»,

«Strategy–Strategy», «Strategy–algInt»,«Strategy–ConcreteStrategy», «Strategy–algInt»

© 2002, M. Fontoura, W. Pree, B. Rumpe 29SPLC2, San Diego, CA, USA

Strategy pattern (II)

Sample annotation:

aaaaa

CurrencyConverter

convert(...)

RoundingPolicy

round(val: double): double

round(val: double): double

RPol10

round(val: double): double

RPol100

«Strat–Ctxt»

«Strat–anOp»

«Strat–Strat»

«Strat–algInt»

«Strat–strat»rPol

round(val: double): double

DefaultRPol

«Strat–ConcreteStrat»

«Strat–algInt»

© 2002, M. Fontoura, W. Pree, B. Rumpe 30SPLC2, San Diego, CA, USA

UML-F extension structure

aa

UML-F tag sets for framework construction principles

UML-F tag sets for framework-related GoF patterns

UML-F tag sets for other pattern catalogs or domain-specific patterns

relies on

Factory Method

Template Method Bridge

State

Strategy

Observer

Command

Builder Abstract Factory

Prototype

Interpreter

Unification Separation

Composite

Chain-Of-Responsibility

Decorator

Calculation . . .

© 2002, M. Fontoura, W. Pree, B. Rumpe 31SPLC2, San Diego, CA, USA

Domain-specific patterns or other catalog pattterns

aaaaa

Calculator

calcOp()

CalcAlgorithm

calcAlg()

calcAlg()

ConcreteAlgorithm

«Strat–Ctxt»

«Strat–anOp»

«Strat–Strat»

«Strat–algInt»

«Strat–algInt»

«Strat–ConcreteStrat»

«Strat–strat»