Sei sulla pagina 1di 18

Using a fUML Action Language to construct UML models

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,


Department of Computer Science, Babe s-Bolyai University, Cluj-Napoca, Romania

September 2009

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Using a fUML Action Language to construct UML models

Outline

1. Introduction
1.1 Executable Models 1.2 Foundational Executable UML 1.3 Action Languages

2. fUML-based Action Language 3. Further Work

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Using a fUML Action Language to construct UML models

1. Introduction 1.1. Executable Models


verication techniques may be applied early in the development cycle execution infrastructures
Domain specic
e.g. AADL (embedded domain, hardware and software)

Domain and Platform independent


e.g. UML (large, many variation points)

ComDeValCo (Framework for Software Component Denition, Validation, and Composition)


based on UML Action Language needed to model the functionality of components

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Using a fUML Action Language to construct UML models

1. Introduction 1.2. Foundational Executable UML


fUML Specication Object Management Group (OMG) Standard
2008, Rev. 1.0, Beta 1 http://www.omg.org/spec/FUML/

a computationally complete and compact subset of UML provides a simplied subset of UML Action Semantics package simplies the context to which the actions may be applied enforces a data ow abstract representation fUML Reference Implementation ModelDriven.org 2009, version 0.2.0

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Using a fUML Action Language to construct UML models

1. Introduction 1.3. Action Languages


Object Action Language (OAL)
Mentor Graphics BridgePoint product

Action Specication Language (ASL)


Kennedy Carters iUML product

Shlaer-Mellor Action Language (SMALL)


Project Technology, Inc.

Platform Independent Action Language (PAL)


Pathnder Solutions PathMATE product

ITU-T Recommendation Z.109


a UML prole that maps to SDL (Specication and Description Language) semantics

Action Language for Business Logic (ABL) +CAL OCL4X OMG issued a Request for Proposal: Concrete Syntax for a UML Action Language (2008)
I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar, Using a fUML Action Language to construct UML models

2. fUML-based Action Language

the abstract syntax is compliant with fUML enforces structured programming concrete syntax similar to Java and OCL used to model the behavior of class operations code generation for object-oriented programming languages (Java, C++, C#)

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Using a fUML Action Language to construct UML models

Types UML primitive types


Boolean Integer UnlimitedNatural String fUML Model Library operations (primitive function behaviors)
(e.g. +, -, And, Or, ListGet, ListSize).

List (array)
list[index] list.add(object) list.remove(object) list.size

user dened types: Classes or Enumerations

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Using a fUML Action Language to construct UML models

POS +makeNewSale() +addSaleItem( code : String, quantity : Integer ) : Boolean SaleItem +quantity : Integer * +item 0..1 +currentSale Sale +addItem( product : Product, quantity : Integer ) * +product +product 1 Product +code : String +price : Integer

Figure: POS Example Model

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Using a fUML Action Language to construct UML models

the activity is the implementation (method) of the operation activity with no parameters activity execution
starts with the intial node runs main structured node
runs assign statement

1 2 3

makeNewSale() { self.currentSale := new Sale; }

activity makeNewSale MAIN_BLOCK [lines 1-3] ASSIGN_STMT [line 2] <<readSelf>> result result <<createObject>> self Sale value object <<addStructuralFeatureValue>> currentSale

ends with the nal node

self keyword (ReadSelfAction) constructor with no arguments (CreateObjectAction)

Figure: POS::makeNewSale

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Using a fUML Action Language to construct UML models

activity with 2 parameters parameter value provided by parameter node variable simulated with fork node the actions for a statement are contained inside a structured node control ows between statement nodes enforce sequential execution
1 2 3 4 5 6 addItem(product:Product, quantity:Integer) { def newItem : SaleItem := new SaleItem; newItem.product := product; newItem.quantity := quantity; self.item.add(newItem); }
product : Product product quantity : Integer ASSIGN_STMT [line 4] value <<addStructuralFeatureValue>> object quantity quantity ADD_STMT [line 5] result result <<readSelf>> <<valueSpecification>> self * object insertAt <<addStructuralFeatureValue>> value item activity addItem ( product : Product, quantity : Integer ) MAIN_BLOCK [lines 1-6] DEF_STMT [line 2] result : SaleItem <<createObject>> SaleItem newItem ASSIGN_STMT [line 3] value <<addStructuralFeatureValue>> object product

Figure: Sale:addItem
Using a fUML Action Language to construct UML models

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

If statement represented with a conditional node


2 clauses: then and else each clause references its test and body actions then clause - its test is the condition else clause - its test is always true
1 addSaleItem(code:String, quantity:Integer ) : Boolean { def product:Product := self->findProduct(code); if (product = null) { return false; } else { self.currentSale.addItem( product, quantity); return true; } }

activity addSaleItem ( code : String, quantity : Integer ) : Boolean MAIN_BLOCK [lines 1-9] DEF_STMT [line 2] code findProduct return : Product

code code : String test IF_STMT [lines 3-8]

product result first ListSize <<testIdentity>> second list = <<valueSpecification>> 0 result : Boolean result THEN_BLOCK [lines 3-5] RETURN_STMT [line 4] <<valueSpecification>> result false

body

else quantity : Integer

ELSE_BLOCK [lines 5-8] CALL_OP_STMT [line 6] quantity product

quantity

2 3 4 5 6 7 8 9

addItem <<readSelf>> result self target object <<readStructuralFeature>> currentSale result RETURN_STMT [line 7] result

<<valueSpecification>> true

return : Boolean

Figure: POS::addSaleItem
Using a fUML Action Language to construct UML models

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Call operation addItem result : Boolean result

<<valueSpecification>> 0

self.currentSale is the target object body product quantity and are the arguments THEN_BLOCK [lines 3-5]
RETURN_STMT [line 4]

self.currentSale.addItem( <<valueSpecification>> result product, falsequantity);


else ELSE_BLOCK [lines 5-8] CALL_OP_STMT [line 6] quantity product quantity addItem <<readSelf>> result self target object <<readStructuralFeature>> currentSale result RETURN_STMT [line 7] <<valueSpecification>> POS::addSaleItem [line 6] result true
Using a fUML Action Language to construct UML models

quantity : Integer

Figure:

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Call activity findProduct


self keyword tells that the activity is private and belongs to the same class

public global activities may be invoked


no self keyword

def product:Product := self->findProduct(code);

activity addSaleItem ( code : String, quantity : Integer ) : Boolean MAIN_BLOCK [lines 1-9] DEF_STMT [line 2] code findProduct return : Product

code code : String test IF_STMT [lines 3-8]

product

result first ListSize <<testIdentity>> second list Figure: POS::addSaleItem [line 2] = <<valueSpecification>> result result : Boolean I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar, Using a fUML Action0 Language to construct UML models

null equality test


null is represented as having no token empty list is represented by having no token fUML Model Library operation: ListSize equality test is done using the TestIdentityAction activity addSaleItem ( code : String, quantity : Integer ) : Boolean
for primitive types - compares values MAIN_BLOCK [lines 1-9] for objects - compares references

3
code code : String

code if

(product = return null) { : Product findProduct


product IF_STMT [lines 3-8]

DEF_STMT [line 2]

test

result first ListSize <<testIdentity>> second list = <<valueSpecification>> 0 result : Boolean result THEN_BLOCK [lines 3-5]

body

Figure: POS::addSaleItem [line 3] RETURN_STMT [line 4]


<<valueSpecification>> result false I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar, Using a fUML Action Language to construct UML models

activity addSaleItem ( code : String, quantity : Integer ) : Boolean MAIN_BLOCK [lines 1-9] if (product = null) { DEF_STMT [line 2] return false; return : Product code findProduct } else { code self.currentSale.addItem( product code : String IF_STMT [lines 3-8] product, quantity); result test first 7 return true; ListSize <<testIdentity>> second list 8 } =

3 4 5 6

Multiple return statements


the return tokens are sent by the actions to a merge node
the data token reaches the return parameter node

result : Boolean result body

<<valueSpecification>> 0

THEN_BLOCK [lines 3-5] RETURN_STMT [line 4] <<valueSpecification>> result false

else quantity : Integer

ELSE_BLOCK [lines 5-8] CALL_OP_STMT [line 6] quantity product

quantity

the control tokens are sent by the structured nodes containing the actions to a merge node
the control token reaches the nal node

addItem <<readSelf>> result self target object <<readStructuralFeature>> currentSale result RETURN_STMT [line 7] result

<<valueSpecification>> true

return : Boolean

Figure: POS::addSaleItem [3-8]


I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar, Using a fUML Action Language to construct UML models

activity findProduct( code : String ) : Product MAIN_BLOCK [lines 1-8] FOR_EACH_STMT [lines 2-6] result <<readSelf>> self object <<readStructuralFeature>> result product

For-each statement represented with an expansion region


iterates over a list of elements body actions executed for each element in sequential order
1 2 3 4 5 6 7 8 findProduct(code:String) : Product { foreach (prod in self.product) { if (code = prod.code) { return prod; } } return null; }

<<iterative>> FOR_EACH [lines 2-6] BLOCK [lines 2-6] prod code : String test first IF_STMT [lines 3-5] second result object <<readStructuralFeature>> code

code

<<testIdentity>> = result : Boolean body

BLOCK [line 3-5] RETURN_STMT [line 4] return : Product

RETURN_STMT [line 7] <<valueSpecification>> result : Product null

return : Product

Figure: POS:ndProduct
I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar, Using a fUML Action Language to construct UML models

3. Further Work

create a fully functional editor based on this action language simulate the execution for more complex models apply transformations to the models generate code in different programming languages

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Using a fUML Action Language to construct UML models

Thank you for your attention

I. Lazar, B. Prv, S. Motogna and I.-G. Czibula C.-L. Lazar,

Using a fUML Action Language to construct UML models

Potrebbero piacerti anche