SlideShare a Scribd company logo
19 March 2018
Copyright © 2018 Model Driven Solutions, Inc.
Programming in UML:
An Introduction to fUML and Alf
Updated for fUML 1.3 and Alf 1.1
Page 2
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Agenda
I. Introduction
II. Elements of Executable UML
III. Standard Model Library
Page 3
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
I. Introduction
A. A Motivating Example
B. Executable UML
C. The Standards
Page 4
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
A. A Motivating Example
• E-Commerce Ordering System
– Loosely based on the Online Bookstore Domain Case Study given
in Appendix B of the book Executable UML: A Foundation for Model
Driven Architecture by Stephen J. Mellor and Marc J. Balcer
(Addison-Wesley, 2002)
• To be designed in UML
– Class models for structure
– State machine models for behavior
• To be implemented on the Web
– Using Java/JEE
– …or maybe C#/.Net
– …or maybe LAMP
– …or whatever…
Page 5
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Ordering: Class Model
Order is an active class
whose classifier behavior
is responsible for handling
ordering functionality.
Order is an active class
whose classifier behavior
is responsible for handling
ordering functionality.
Page 6
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Order: Classifier Behavior
A state machine abstracts
system behavior into a
finite number of states.
A state machine abstracts
system behavior into a
finite number of states.
The system is modeled as
having discrete transitions
between the states.
The system is modeled as
having discrete transitions
between the states.
A transition may trigger
further system behavior or
system behavior may be
dependent on the current
state.
A transition may trigger
further system behavior or
system behavior may be
dependent on the current
state.
Page 7
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Order Behavior: EstablishCustomer Activity
An activity specifies
behavior as the
coordinated
execution of a set of
subordinate actions.
An activity specifies
behavior as the
coordinated
execution of a set of
subordinate actions.
An action in one
activity may call
another activity.
An action in one
activity may call
another activity.
Data and control
flow between the
various actions.
Data and control
flow between the
various actions.
Other actions provide
various data and
computational functions.
Other actions provide
various data and
computational functions.
Full executability requires
complete specification of
behavior and computation. This
is often much more easy to
specify using a textual notation.
Full executability requires
complete specification of
behavior and computation. This
is often much more easy to
specify using a textual notation.
Page 8
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
The Question Is…
• If we are going to take the time to carefully design our system
using UML, e.g.,
– Structural models of classes and associations
– Behavioral models using state machines or operations and messages
• Then why can’t we use these directly to execute our system?
The answer is: We can!
• Just add detailed behavior…
– …which is best done using a textual action language…
– …which should be at the same semantic level as the rest of the model.
Page 9
B. Executable UML: Perceived Issues
• Making models detailed enough for machine execution defeats
the purpose of models for human communication.
• UML is not specified precisely enough to be executed (at least
not in a standard way).
• Graphical modeling notations are not good for detailed
programming.
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Page 10
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Executable UML: Issue Resolutions
• Making models detailed enough for machine execution defeats
the purpose of models for human communication.
– Executable models can still be more understandable than
executable code.
– Non-executable models are still useful, too.
• UML is not specified precisely enough to be executed (at least
not in a standard way).
– The Foundational UML (fUML) standard specifies precise
semantics for an executable subset of UML.
– fUML Version 1.0 formal specification now available.
• Graphical modeling notations are not good for detailed
programming.
– The Action Language for fUML (Alf) standard specifies a
textual action language with fUML semantics.
– Alf Version 1.0 finalization in progress.
Page 11
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
C. The Standards
• Unified Modeling Language (UML)
• Executable UML Foundation (fUML)
• UML Action Language (Alf)
Page 12
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Unified Modeling Language (UML)
The Unified Modeling Language (UML) is a graphical language for
modeling the structure, behavior and interactions of software,
hardware and business systems, standardized by the Object
Management Group (OMG).
• UML Version 1.1 (first standard) – December 1997
• UML Version 1.5 (with action semantics) – March 2003
• UML Version 2.0 (new version) – July 2005
• UML Version 2.4.1 – July 2011
• UML Version 2.5 (spec simplification) – May 2015
• UML Version 2.5.1 (current standard) – December 2017
Page 13
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Executable UML Foundation (fUML)
Foundational UML (fUML) is an executable subset of standard
UML that can be used to define, in an operational style, the
structural and behavioral semantics of systems.
• fUML Version 1.0 – January 2011
• fUML Version 1.1 – July 2013
• fUML Version 1.2.1 – December 2016
• fUML Version 1.3 (current standard) – October 2017
• fUML Version 1.4 (migration to UML 2.5.1) – 2018 (planned)
Page 14
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Key Components
• Foundational UML Subset (fUML) – A computationally
complete subset of the abstract syntax of UML (Version 2.4.1)
– Kernel – Basic object-oriented capabilities
– Common Behavior – General behavior and asynchronous
communication
– Activities – Activity modeling, including structured activities (but not
including variables, exceptions, swimlanes, streaming or other
“higher level” activity modeling)
• Execution Model – A model of the execution semantics of user
models within the fUML subset
• Foundational Model Library
– Primitive Types – Boolean, String, Integer, Real, Unlimited Natural
– Primitive Behaviors – Boolean, String and Arithmetic Functions
– Basic Input/Output – Based on the concept of “Channels”
Added in fUML
1.1
Added in fUML
1.1
Page 15
Other Precise Semantics Specifications
The following specifications build on the foundation of fUML:
•Precise Semantics of UML Composite Structure (PSCS)
– Version 1.1 (beta) – June 2017
•Precise Semantics of UML State Machines (PSCS)
– Version 1.0 (alpha) – December 2016 (in finalization)
•Precise Semantics of Time for Foundational UML
– RFP issued – December 2017
– Revised submissions due – August 2019
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Page 16
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
UML Action Language (Alf)
The Action Language for Foundational UML (Alf) is a textual
surface representation for UML modeling elements with the
primary purpose of acting as the surface notation for specifying
executable (fUML) behaviors within an overall graphical UML
model. (But which also provides an extended notation for
structural modeling within the fUML subset.)
• Alf Version 1.0 (beta) – November 2012
• Alf Version 1.0.1 (migration to fUML 1.1) – September 2013
• Alf Version 1.1 (current standard) – June 2017
• Alf Version 1.2 (migration to fUML 1.4) – 2018/2019 (planned)
Page 17
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Key Components
• Concrete Syntax – A BNF specification of the legal textual syntax
of the Alf language.
• Abstract Syntax – A MOF metamodel of the abstract syntax tree
that is synthesized during parsing of an Alf text, with additional
derived attributes and constraints that specify the static semantic
analysis of that text.
• Semantics – The semantics of Alf are defined by mapping the Alf
abstract syntax metamodel to the fUML abstract syntax metamodel.
• Standard Model Library
– From the fUML Foundational Model Library
• Primitive Types (plus Natural and Bit String)
• Primitive Behaviors (plus Bit String Functions and Sequence Functions)
• Basic Input/Output
– Collection Functions – Similar to OCL collection operations for
sequences
– Collection Classes – Set, Ordered Set, Bag, List, Queue, Deque, Map
Page 18
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
II. Elements of Executable UML
A. Activities
B. Actions
C. Structure
D. Asynchronous Communication
Page 19
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
A. Activities
• Activities and Parameters
• Actions and Flows
• Textual Notation
• Tokens
• Offers
• Control Nodes
• Structured Nodes
Page 20
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Activities and Parameters
An activity is a specification of behavior as
the coordinated execution of subordinate
actions, using a control and data flow
model.
An activity is a specification of behavior as
the coordinated execution of subordinate
actions, using a control and data flow
model.
An activity may have input,
output and return parameters.
An activity may have input,
output and return parameters.
The parameters have corresponding activity
parameter node on the boundary of the
diagrammatic representation of an activity.
The parameters have corresponding activity
parameter node on the boundary of the
diagrammatic representation of an activity.
Page 21
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Actions and Flows
An action is a fundamental
unit of executable behavior
within an activity.
An action is a fundamental
unit of executable behavior
within an activity.
A pin is an activity node that
either accepts input to or
provides output from an action.
A pin is an activity node that
either accepts input to or
provides output from an action.
An object flow provides
a path for passing
objects or data.
An object flow provides
a path for passing
objects or data.
A control flow specifies
the sequencing of
actions.
A control flow specifies
the sequencing of
actions.
An activity diagram is a graph structure
consisting of activity nodes connected by
activity edges.
An activity diagram is a graph structure
consisting of activity nodes connected by
activity edges.
Page 22
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Textual Notation
activity DoSomething(in input: Integer, out output Integer): Integer {
output = A(input);
return B();
}
activity DoSomething(in input: Integer, out output Integer): Integer {
output = A(input);
return B();
}
Alf behavioral notation
maps to fUML activity
models.
Alf behavioral notation
maps to fUML activity
models.
The semantics of the Alf notation
is defined by its mapping to
fUML
The semantics of the Alf notation
is defined by its mapping to
fUML
Page 23
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Tokens
a = DoSomething(1, b);a = DoSomething(1, b);
A token is a container for an object, datum
or locus of control that may be present at an
activity node.
A token is a container for an object, datum
or locus of control that may be present at an
activity node.
The activity is invoked
with an argument of 1
for its input parameter.
The activity is invoked
with an argument of 1
for its input parameter.
An object token with a
value of 1 is placed on
the input activity
parameter node.
An object token with a
value of 1 is placed on
the input activity
parameter node.
The object token flows to
the input pin of action A
along the object flow.
The object token flows to
the input pin of action A
along the object flow.
Action A fires and
produces an object
token on its output pin.
Action A fires and
produces an object
token on its output pin.
The object token flows
to the output activity
parameter node along
the object flow.
The object token flows
to the output activity
parameter node along
the object flow.
When it is done, action A
produces a control token,
which flows to action B
along the control flow.
When it is done, action A
produces a control token,
which flows to action B
along the control flow.
Action B accepts the
control token and fires,
producing an object
token on its output pin.
Action B accepts the
control token and fires,
producing an object
token on its output pin.
The object token flows
to the output activity
parameter node along
the object flow.
The object token flows
to the output activity
parameter node along
the object flow.
Values on the output activity
parameter nodes are copied
to the output arguments.
Values on the output activity
parameter nodes are copied
to the output arguments.
Page 24
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Offers
An output pin offers its
tokens to the targets of
all outgoing object flows.
An output pin offers its
tokens to the targets of
all outgoing object flows.
A single token can only flow to one
target. If two competing targets are
both ready to accept an offer for the
same token, it is indeterminate
which will get the token.
A single token can only flow to one
target. If two competing targets are
both ready to accept an offer for the
same token, it is indeterminate
which will get the token.
Note: fUML semantics do not guarantee
“liveliness” or “fairness” in the execution of
actions competing for tokens.
Note: fUML semantics do not guarantee
“liveliness” or “fairness” in the execution of
actions competing for tokens.
Actions with no control constraints
execute concurrently. This means that
they may execute in parallel – or they
may execute sequentially in any order.
Actions with no control constraints
execute concurrently. This means that
they may execute in parallel – or they
may execute sequentially in any order.
Page 25
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Fork and Join Nodes
order = 'Create Order'();
//@parallel
{
'Fulfill Order'(order);
'Invoice Order'(order);
}
'Close Out Order'(order);
order = 'Create Order'();
//@parallel
{
'Fulfill Order'(order);
'Invoice Order'(order);
}
'Close Out Order'(order);
A fork node copies the
tokens it is offered,
and offers a copy on
each outgoing flow.
A fork node copies the
tokens it is offered,
and offers a copy on
each outgoing flow.
A join node waits for a token
to be offered on all incoming
flows and then offers tokens
on its outgoing flow.
A join node waits for a token
to be offered on all incoming
flows and then offers tokens
on its outgoing flow.
In the Alf textual notation,
forks and joins are implicit in
the parallel block notation.
In the Alf textual notation,
forks and joins are implicit in
the parallel block notation.
Note: Alf does not actually provide any
notation for competition for tokens on
output pins. A fork node is always inserted
for multiple flows out of any output pin.
Note: Alf does not actually provide any
notation for competition for tokens on
output pins. A fork node is always inserted
for multiple flows out of any output pin.
Page 26
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Control Nodes
An initial node
generates a single
control token.
An initial node
generates a single
control token.A merge node
passes on any
tokens it receives.
A merge node
passes on any
tokens it receives.
A decision node
routes tokens based
on a decision input
value.
A decision node
routes tokens based
on a decision input
value. An activity final
node terminates
the activity when it
receives a token.
An activity final
node terminates
the activity when it
receives a token.
A control node is an activity
node used to coordinate the
flow of (the offers for) tokens
between other nodes.
A control node is an activity
node used to coordinate the
flow of (the offers for) tokens
between other nodes.
Note: A data store node
is used so a “card”
token is available for
each iteration.
Note: A data store node
is used so a “card”
token is available for
each iteration.
Note: Since the decision
node “gates” control flow,
it must be provided with an
incoming control token.
Note: Since the decision
node “gates” control flow,
it must be provided with an
incoming control token.
Added in fUML
1.3
Added in fUML
1.3
Page 27
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Structured Nodes
card = 'Select Credit Card'();
do {
charge = 'Create Credit Card Charge'(card);
if ('Check Charge Approval'(charge)) {
'Notify Customer of Approval'(charge);
declined = false;
} else {
'Notify Customer of Denial'(charge);
declined = true;
}
} while (declined);
card = 'Select Credit Card'();
do {
charge = 'Create Credit Card Charge'(card);
if ('Check Charge Approval'(charge)) {
'Notify Customer of Approval'(charge);
declined = false;
} else {
'Notify Customer of Denial'(charge);
declined = true;
}
} while (declined);
A structured node is an activity
node used to group subordinate
nodes into a control structure.
A structured node is an activity
node used to group subordinate
nodes into a control structure.
An loop node iterates
the execution of its
body while a
condition is true.
An loop node iterates
the execution of its
body while a
condition is true.
By default, the
condition is tested
after execution of
the body.
By default, the
condition is tested
after execution of
the body.
A conditional node
executes one
clause or another
based on the result
of a test (or tests).
A conditional node
executes one
clause or another
based on the result
of a test (or tests).
Inputs to the loop node
initialize loop variables
available across all
iterations of the loop.
Inputs to the loop node
initialize loop variables
available across all
iterations of the loop.
Note: There is no normative UML
graphical notation for loop or
conditional nodes.
Note: There is no normative UML
graphical notation for loop or
conditional nodes.
break;
true
Alf also provides
a traditional
break statement.
Alf also provides
a traditional
break statement.
Page 28
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Expansion Regions
'Get Outstanding Orders'(customer) ->
select order ('Is Delinquent?'(order)) ->
iterate order ('Refer for Collection'(order));
'Get Outstanding Orders'(customer) ->
select order ('Is Delinquent?'(order)) ->
iterate order ('Refer for Collection'(order));
An expansion region is
used to apply subordinate
actions on all members of
an input collection
An expansion region is
used to apply subordinate
actions on all members of
an input collection
A parallel expansion
region applies nested
behavior concurrently
to all collection
elements.
A parallel expansion
region applies nested
behavior concurrently
to all collection
elements.
An iterative expansion
region applies nested
behavior sequentially
to all collection
elements.
An iterative expansion
region applies nested
behavior sequentially
to all collection
elements.
Alf provides specialized
notation that maps to typical
uses of expansion regions.
Alf provides specialized
notation that maps to typical
uses of expansion regions.
Page 29
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Reduction
A reduction action “inserts”
a binary function between
the elements of a
sequence of values.
A reduction action “inserts”
a binary function between
the elements of a
sequence of values.
this.totalAmount =
this.lineItems.amount->reduce MoneyFunctions::Add;
this.totalAmount =
this.lineItems.amount->reduce MoneyFunctions::Add;
this.totalAmount =
this.lineItems.amount->reduce MoneyFunctions::Add
?? new Money(0, 0);
this.totalAmount =
this.lineItems.amount->reduce MoneyFunctions::Add
?? new Money(0, 0);
This is shorthand for
“this.lineItems->collect item (item.amount)”.
This is shorthand for
“this.lineItems->collect item (item.amount)”.
If the input sequence is empty, then
reduction results in “null” (the empty
sequence). An Alf null-coalescing
expression can be used to provide a
default value for this case. (Corresponding
UML not shown.)
If the input sequence is empty, then
reduction results in “null” (the empty
sequence). An Alf null-coalescing
expression can be used to provide a
default value for this case. (Corresponding
UML not shown.)
Page 30
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
B. Actions
• Invocation Actions
• Object Actions
• Structural Feature Actions
• Link Actions
NOTE: Some of these actions will be discussed in more detail later.NOTE: Some of these actions will be discussed in more detail later.
Page 31
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Invocation Actions
• Call Behavior
– Calling an activity
– Calling a primitive behavior
• Call Operation
• Send Signal
• Accept Event
PlaceOrder(customer, product)
Max(throttle, limit) count + quantity
order.addProduct(product, quantity)
vehicle.EngageBrake(pressure)
accept (signal: EngageBrake)
Page 32
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Object Actions
• Value Specification
• Create Object
• Destroy Object
• Test Identity
• Read Self
• Read Extent
• Read Is Classified Object
• Reclassify Object
1 true "Hello"
new Order()
order.destroy()
order == myOrder name != customerName
this
Order.allInstances()
vehicle instanceof Car car hastype Hatchback
reclassify order from PendingOrder to ClosedOrder
Page 33
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Structural Feature Actions
• Read Structural Feature
• Add Structural Feature Value
• Remove Structural Feature Value
• Clear Structural Feature Value
order.customer
order.datePlaced = today
order.lineItems->add(item)
order.lineItems->addAt(1,item)
order.lineItems->remove(item)
order.lineItems->removeAt(1)
order.card = null
Page 34
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Link Actions
• Read Link
• Create Link
• Destroy Link
• Clear Association
Owns.person(house=>thisHouse) thisHouse.person
Owns.addLink(person=>jack, house=>newHouse)
Owns.removeLink(person=>jack, house=>oldHouse)
Owns.clearAssoc(jack)
Page 35
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Computation
• Indexing (from 1 , not 0)
• Increment/Decrement
• Arithmetic/Logic
• Comparison
• Conditional
• Isolation
order.lineItems[i] order.lineItems->at(i)
index++ ++count
total + value address & mask
total > threshold index <= count
count != 0 && total/count > limit
count < min || count > max
$this.sensor.getReading().value
Page 36
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
C. Structure
• Structural and Behavioral Models
• Classes
• Associations
Page 37
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Structural and Behavioral Models
• A structural model (e.g., a class model) specifies the relevant
(types of) instances in a domain that may exist at any one point
in time.
– Structural semantics define how a structural model constrains
allowable instances.
• A behavioral model (e.g., an activity model) specifies behavior
over time
– Behavioral semantics define how a behavioral model changes the
state of instances over time.
Page 38
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Classes
• Attributes
• Data Types
• Primitive Types
• Operations and Methods
• Structural Semantics
• Behavioral Semantics
A class is a classifier of objects that persist in the extent of
the class, with an identity that is independent of the value of
their attributes at any one time.
A class is a classifier of objects that persist in the extent of
the class, with an identity that is independent of the value of
their attributes at any one time.
Page 39
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Classes and Attributes
A class may have
attributes whose types
are primitive, data
types or other classes.
A class may have
attributes whose types
are primitive, data
types or other classes.
A referential attribute,
whose type is a class, is
conventionally notated as
an association with a class-
owned association end.
A referential attribute,
whose type is a class, is
conventionally notated as
an association with a class-
owned association end.
A bidirectional association
results in corresponding
referential attributes on
both associated classes.
A bidirectional association
results in corresponding
referential attributes on
both associated classes.
Page 40
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Data Types
A data type is a classifier of transient data
values whose identity is based on the values
of their attributes.
A data type is a classifier of transient data
values whose identity is based on the values
of their attributes.
Data types may
have attributes, but
not operations.
Data types may
have attributes, but
not operations.
Page 41
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Primitive Types
• From UML 2.4.1 PrimitiveTypes Package
– Boolean
– Integer
– Real
– UnlimitedNatural
– String
Used since fUML
1.1
Used since fUML
1.1
Page 42
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Classes: Operations and Methods
An operation specifies a
behavior that may be
synchronously invoked
on an instance of a class.
An operation specifies a
behavior that may be
synchronously invoked
on an instance of a class.
A method defines
the actual behavior
that is invoked.
A method defines
the actual behavior
that is invoked.
Page 43
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Classes: Structural Semantics
Structural semantics specify how
a structural model constrains
allowable instances.
Structural semantics specify how
a structural model constrains
allowable instances.
Objects are instances
of classes with values
for each attribute.
Objects are instances
of classes with values
for each attribute.
Class-owned association
ends are structural features
with values, like attributes.
Class-owned association
ends are structural features
with values, like attributes.
fUML does not actually give
semantics to an association
with class-owned ends, only to
the ends as structural features.
fUML does not actually give
semantics to an association
with class-owned ends, only to
the ends as structural features.
Note: fUML does provide
“reified” semantics for
associations that own their own
ends, as will be discussed later.
Note: fUML does provide
“reified” semantics for
associations that own their own
ends, as will be discussed later.
Page 44
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Classes: Behavioral Semantics
• Creating an Order
• Adding a Line Item
• Canceling an Order
Behavioral semantics specify how a behavioral model
changes the state of instances over time.
Behavioral semantics specify how a behavioral model
changes the state of instances over time.
Page 45
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Creating an Order
order = new Order (customer, today)
Before After
@Create
public Order (in customer: Customer, in datePlaced: Date) {
this.datePlaced = datePlaced;
this.totalAmount = new Money(dollars=>0, cents=>0);
this.customer = customer;
this.customer.orders->add(this);
}
@Create
public Order (in customer: Customer, in datePlaced: Date) {
this.datePlaced = datePlaced;
this.totalAmount = new Money(dollars=>0, cents=>0);
this.customer = customer;
this.customer.orders->add(this);
}
A new object is created
and the constructor
operation is invoked.
A new object is created
and the constructor
operation is invoked.
The constructor initializes
the new order’s attribute
values…
The constructor initializes
the new order’s attribute
values…
…and adds the order
to the customer’s list.
…and adds the order
to the customer’s list.
Page 46
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Adding a Line Item
Before After
order.addProduct (product, 2)
public addProduct
(in product: Product, in quantity: Integer) {
lineItem = new LineItem(product, quantity);
this.lineItems->add(lineItem);
this.totalAmount = MoneyFunctions::Add
(this.totalAmount, lineItem.amount);
}
public addProduct
(in product: Product, in quantity: Integer) {
lineItem = new LineItem(product, quantity);
this.lineItems->add(lineItem);
this.totalAmount = MoneyFunctions::Add
(this.totalAmount, lineItem.amount);
}
The method for the
operation creates a
new line item object…
The method for the
operation creates a
new line item object…
The addProduct
operation is invoked
on an existing Order
object.
The addProduct
operation is invoked
on an existing Order
object.
…adds the new object
to the list of line items
for the order…
…adds the new object
to the list of line items
for the order…
…and updates
the total order
amount.
…and updates
the total order
amount.
Page 47
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Canceling an Order
Before After
order.cancel()
@Destroy
public cancel() {
this.customer.orders->remove(this);
}
@Destroy
public cancel() {
this.customer.orders->remove(this);
}
A destructor operation is
invoked, after which the
order object is destroyed.
A destructor operation is
invoked, after which the
order object is destroyed.
Because line items
are aggregated by
composition, they
are destroyed, too.
Because line items
are aggregated by
composition, they
are destroyed, too.
References to the
destroyed object must
be explicitly removed.
References to the
destroyed object must
be explicitly removed.
Page 48
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Associations
• Classes and Associations
• Structural Semantics
• Behavioral Semantics
An association is a classifier whose instances are links that
relate other instances.
An association is a classifier whose instances are links that
relate other instances.
Page 49
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Classes and Associations
An association (that owns its
ends) is a classifier of
persistent links between the
associated classes, which exist
in the extent of the association.
An association (that owns its
ends) is a classifier of
persistent links between the
associated classes, which exist
in the extent of the association.
Page 50
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Associations: Structural Semantics
Links are now semantic
instances of the indicated
associations.
Links are now semantic
instances of the indicated
associations.
Structural semantics specify how
a structural model constrains
allowable instance models.
Structural semantics specify how
a structural model constrains
allowable instance models.
Page 51
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Associations: Behavioral Semantics
• Creating an Order (revised)
• Canceling an Order (revised)
Behavioral semantics specify how a behavioral model
changes the state of instances over time.
Behavioral semantics specify how a behavioral model
changes the state of instances over time.
Page 52
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Creating an Order (revised)
order = new Order (customer, today)
Before After
@Create
public Order (in customer: Customer, in datePlaced: Date) {
this.datePlaced = datePlaced;
this.totalAmount = new Money(dollars=>0, cents=>0);
Customer_Order.addLink(customer, this);
}
@Create
public Order (in customer: Customer, in datePlaced: Date) {
this.datePlaced = datePlaced;
this.totalAmount = new Money(dollars=>0, cents=>0);
Customer_Order.addLink(customer, this);
}
A single action creates
a bidirectional link.
A single action creates
a bidirectional link.
Page 53
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Canceling an Order (revised)
Before After
order.cancel()
@Destroy
public cancel() { }
@Destroy
public cancel() { }
A destructor operation is
invoked, after which the
order object is destroyed.
A destructor operation is
invoked, after which the
order object is destroyed.
Links in which the
destroyed object
participates are now also
automatically destroyed.
Links in which the
destroyed object
participates are now also
automatically destroyed.
Page 54
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
D. Asynchronous Communication
• Signals and Receptions
• Classifier Behaviors
• Asynchronous Behavior
Page 55
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Signals and Receptions
A signal is a classifier
whose instances may
be communicated
asynchronously.
A signal is a classifier
whose instances may
be communicated
asynchronously.
A reception is a
declaration of the ability
to receive a signal.
A reception is a
declaration of the ability
to receive a signal.
A signal may have
attributes that represent
transmittable data.
A signal may have
attributes that represent
transmittable data.
More than one
class can receive
the same signal.
More than one
class can receive
the same signal.
Page 56
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Classifier Behaviors
An active class is one that
has a classifier behavior.
Only active class may
receive signals.
An active class is one that
has a classifier behavior.
Only active class may
receive signals.
A classifier behavior is an
autonomous behavior
started when an active
class is instantiated.
A classifier behavior is an
autonomous behavior
started when an active
class is instantiated.
Page 57
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Asynchronous Behavior
accept (submission: SubmitCharge);
card = submission.card;
do {
new CreditCardCharge(card, this);
accept (response: ChargeApproved) {
this.customer.ChargeApproved(response.charge);
break;
} or accept (response: ChargeDeclined) {
this.customer.ChargeDeclined(response.charge);
}
while (true);
accept (submission: SubmitCharge);
card = submission.card;
do {
new CreditCardCharge(card, this);
accept (response: ChargeApproved) {
this.customer.ChargeApproved(response.charge);
break;
} or accept (response: ChargeDeclined) {
this.customer.ChargeDeclined(response.charge);
}
while (true);
The order object
accepts a signal to
submit a charge.
The order object
accepts a signal to
submit a charge.
The order object creates
a new credit card charge
object, which begins its
asynchronous behavior.
The order object creates
a new credit card charge
object, which begins its
asynchronous behavior.
Note: UML semantics require a separate action
to start the behavior of a new object. However,
Alf notation for creating an active class maps to
both create and start object behavior actions.
Note: UML semantics require a separate action
to start the behavior of a new object. However,
Alf notation for creating an active class maps to
both create and start object behavior actions.
The order object
accepts a signal from
the charge object that
the charge is approved.
The order object
accepts a signal from
the charge object that
the charge is approved.The order object
sends a signal to the
customer that the
charge is approved.
The order object
sends a signal to the
customer that the
charge is approved.
Page 58
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
III. Standard Model Library
• Primitive Behaviors
• Collection Functions
• Collection Classes
• Basic Input/Output
Page 59
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Primitive Behaviors
• Integer Functions – Arithmetic, Comparison, Conversion
• Unlimited Natural Functions – Comparison, Conversion
• Boolean Functions – Logical Operations, Conversion
• Bit String Functions – Bit-wise operations, Conversion
• String Functions – Concatenation, Size, Substring
• RealFunctions – Arithmetic, Comparison, Conversion
Added in fUML 1.1Added in fUML 1.1
Page 60
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Collection Functions
Collection functions operate on sequences of values of any type.
• Testing and accessing functions
– Examples: seq->isEmpty(), seq1->equals(seq2), seq->at(n)
• Non-mutating funtions
– Examples: seq2 = seq->including(x), seq3 = seq1->union(seq2)
• Mutating “in place” functions
– Examples: seq->add(x), seq1->addAll(seq2), seq2->remove(x)
Page 61
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Collection Classes
Collection classes define objects that represent collections of
values of a given type.
Page 62
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Basic Input Output: Channels
Page 63
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Basic Input Output: Reading and Writing Lines
activity ReadLine
(out errorStatus: Status[0..1]): String {
return StandardIntputChannel.allInstances().readLine(status);
}
activity ReadLine
(out errorStatus: Status[0..1]): String {
return StandardIntputChannel.allInstances().readLine(status);
}
activity WriteLine
(in value: String, out errorStatus: Status[0..1]) {
StandardOutputChannel.allInstances().writeLine(result, status);
}
activity WriteLine
(in value: String, out errorStatus: Status[0..1]) {
StandardOutputChannel.allInstances().writeLine(result, status);
}
Page 64
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
Hello World
activity Hello() {
WriteLine("Hello World!");
}
activity Hello() {
WriteLine("Hello World!");
}
Page 65
Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
References
• Foundational UML (fUML)
– Semantics of a Foundational Subset for Executable UML Models
standard, http://www.omg.org/spec/FUML
– fUML Open Source (Reference) Implementation Project,
http://fuml.modeldriven.org/
• Action Language for fUML (Alf)
– Action Language for Foundational UML (Alf) standard,
http://www.omg.org/spec/ALF
– Alf Open Source (Reference) Implementation Repository,
http://alf.modeldriven.org/
• Contact
– Email: ed-s@modeldriven.com
– Twitter: @seidewitz or http://twitter.com/seidewitz

More Related Content

What's hot (20)

PDF
[SiriusCon 2020] Realization of Model-Based Safety Analysis and Integration w...
Obeo
 
PPT
Executable UML and SysML Workshop
Ed Seidewitz
 
PDF
Simulation with Python and MATLAB® in Capella
Obeo
 
PDF
CapellaDays2022 | ThermoFisher - ESI TNO | A method for quantitative evaluati...
Obeo
 
PDF
CapellaDays2022 | Saratech | Interface Control Document Generation and Linkag...
Obeo
 
PDF
Tailoring Arcadia Framework in Thales UK
Obeo
 
PDF
CapellaDays2022 | Thales | Stairway to heaven: Climbing the very first steps
Obeo
 
PDF
SiriusCon2016 - ASML's MDE Going Sirius
Obeo
 
PDF
Capella Days 2021 | Introduction to CAPELLA/ARCADIA and NASA Systems Engineer...
Obeo
 
PPTX
The Very Model of a Modern Metamodeler
Ed Seidewitz
 
PPTX
STPA Analysis of Automotive Safety Using Arcadia and Capella
David Hetherington
 
PPT
Ch7 v70 scl_en
Marcos Romanholo
 
PPTX
Introduction to the OMG Systems Modeling Language (SysML), Version 2
Ed Seidewitz
 
PDF
CapellaDays2022 | SIEMENS | Expand MBSE into Model-based Production Engineeri...
Obeo
 
PPTX
SysML v2 and the Next Generation of Modeling Languages
Ed Seidewitz
 
PPTX
Interaction Flow Modeling Language: updates on the Beta2 version - by the OMG...
Marco Brambilla
 
PDF
Defining Viewpoints for Ontology-Based DSLs
Obeo
 
PDF
[Capella Day 2019] Model execution and system simulation in Capella
Obeo
 
PDF
Connecting Textual Requirements with Capella Models
Obeo
 
PDF
Ewm ppt1
Mohiuddin khan
 
[SiriusCon 2020] Realization of Model-Based Safety Analysis and Integration w...
Obeo
 
Executable UML and SysML Workshop
Ed Seidewitz
 
Simulation with Python and MATLAB® in Capella
Obeo
 
CapellaDays2022 | ThermoFisher - ESI TNO | A method for quantitative evaluati...
Obeo
 
CapellaDays2022 | Saratech | Interface Control Document Generation and Linkag...
Obeo
 
Tailoring Arcadia Framework in Thales UK
Obeo
 
CapellaDays2022 | Thales | Stairway to heaven: Climbing the very first steps
Obeo
 
SiriusCon2016 - ASML's MDE Going Sirius
Obeo
 
Capella Days 2021 | Introduction to CAPELLA/ARCADIA and NASA Systems Engineer...
Obeo
 
The Very Model of a Modern Metamodeler
Ed Seidewitz
 
STPA Analysis of Automotive Safety Using Arcadia and Capella
David Hetherington
 
Ch7 v70 scl_en
Marcos Romanholo
 
Introduction to the OMG Systems Modeling Language (SysML), Version 2
Ed Seidewitz
 
CapellaDays2022 | SIEMENS | Expand MBSE into Model-based Production Engineeri...
Obeo
 
SysML v2 and the Next Generation of Modeling Languages
Ed Seidewitz
 
Interaction Flow Modeling Language: updates on the Beta2 version - by the OMG...
Marco Brambilla
 
Defining Viewpoints for Ontology-Based DSLs
Obeo
 
[Capella Day 2019] Model execution and system simulation in Capella
Obeo
 
Connecting Textual Requirements with Capella Models
Obeo
 
Ewm ppt1
Mohiuddin khan
 

Similar to Programming in UML: An Introduction to fUML 1.3 and Alf 1.1 (20)

PPSX
Programming in UML: An Introduction to fUML and Alf
Ed Seidewitz
 
PPTX
UML: Once More with Meaning
Ed Seidewitz
 
PPTX
Standards-Based Executable UML: Today's Reality and Tomorrow's Promise
Ed Seidewitz
 
PPSX
UML: This Time We Mean It!
Ed Seidewitz
 
PPT
Executable UML – UML2
elliando dias
 
PPTX
Action Languages for UML execution: Where we are and where we are heading
Federico Ciccozzi
 
PPTX
Executable UML Roadmap (as of September 2014)
Ed Seidewitz
 
PPT
Programming in UML: Why and How
Ed Seidewitz
 
PDF
MDD with Executable UML Models
Rafael Chaves
 
PPTX
Unified Modeling Language
surana college
 
PDF
Code Generation 2014 - ALF, the Standard Programming Language for UML
JĂĽrgen Mutschall
 
PPT
xUMLFinalPresentation.ppt
ssuser2ef938
 
PPTX
Chapter 2.pptx
RobaDechasa
 
PPTX
Introduction to Unified Modeling Language
AMITJain879
 
PDF
PhD Core Paper Unit 5 _Part 1 Software Design and UML Use Case Modeling.pdf
JAYANTHIKANNAN8
 
DOCX
Behavioural modelling
Benazir Fathima
 
PPTX
Precise Semantics Standards at OMG: Executing on the Vision
Ed Seidewitz
 
PDF
UML with Action Semantics
elliando dias
 
PPT
4.o o design tools=uml -_lecture 4
Warui Maina
 
PPTX
UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015
Luca Berardinelli
 
Programming in UML: An Introduction to fUML and Alf
Ed Seidewitz
 
UML: Once More with Meaning
Ed Seidewitz
 
Standards-Based Executable UML: Today's Reality and Tomorrow's Promise
Ed Seidewitz
 
UML: This Time We Mean It!
Ed Seidewitz
 
Executable UML – UML2
elliando dias
 
Action Languages for UML execution: Where we are and where we are heading
Federico Ciccozzi
 
Executable UML Roadmap (as of September 2014)
Ed Seidewitz
 
Programming in UML: Why and How
Ed Seidewitz
 
MDD with Executable UML Models
Rafael Chaves
 
Unified Modeling Language
surana college
 
Code Generation 2014 - ALF, the Standard Programming Language for UML
JĂĽrgen Mutschall
 
xUMLFinalPresentation.ppt
ssuser2ef938
 
Chapter 2.pptx
RobaDechasa
 
Introduction to Unified Modeling Language
AMITJain879
 
PhD Core Paper Unit 5 _Part 1 Software Design and UML Use Case Modeling.pdf
JAYANTHIKANNAN8
 
Behavioural modelling
Benazir Fathima
 
Precise Semantics Standards at OMG: Executing on the Vision
Ed Seidewitz
 
UML with Action Semantics
elliando dias
 
4.o o design tools=uml -_lecture 4
Warui Maina
 
UML Modeling and Profiling Lab - Advanced Software Engineering Course 2014/2015
Luca Berardinelli
 
Ad

More from Ed Seidewitz (10)

PPTX
SysML v2 - What's the big deal, anyway?
Ed Seidewitz
 
PPTX
SysML v2 and MBSE: The next ten years
Ed Seidewitz
 
PPTX
Model Driven Architecture without Automation
Ed Seidewitz
 
PPT
A Unified View of Modeling and Programming
Ed Seidewitz
 
PPTX
UML as a Programming Language
Ed Seidewitz
 
PPTX
Essence: A Common Ground for Flexible Methods
Ed Seidewitz
 
PPSX
Succeeding with Agile in the Federal Government: A Coach's Perspective
Ed Seidewitz
 
PPTX
UML 2.5: Specification Simplification
Ed Seidewitz
 
PPT
Models, Programs and Executable UML
Ed Seidewitz
 
PPT
Architecting Your Enterprise
Ed Seidewitz
 
SysML v2 - What's the big deal, anyway?
Ed Seidewitz
 
SysML v2 and MBSE: The next ten years
Ed Seidewitz
 
Model Driven Architecture without Automation
Ed Seidewitz
 
A Unified View of Modeling and Programming
Ed Seidewitz
 
UML as a Programming Language
Ed Seidewitz
 
Essence: A Common Ground for Flexible Methods
Ed Seidewitz
 
Succeeding with Agile in the Federal Government: A Coach's Perspective
Ed Seidewitz
 
UML 2.5: Specification Simplification
Ed Seidewitz
 
Models, Programs and Executable UML
Ed Seidewitz
 
Architecting Your Enterprise
Ed Seidewitz
 
Ad

Recently uploaded (20)

PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
A Complete Guide to Salesforce SMS Integrations Build Scalable Messaging With...
360 SMS APP
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Import Data Form Excel to Tally Services
Tally xperts
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 

Programming in UML: An Introduction to fUML 1.3 and Alf 1.1

  • 1. 19 March 2018 Copyright © 2018 Model Driven Solutions, Inc. Programming in UML: An Introduction to fUML and Alf Updated for fUML 1.3 and Alf 1.1
  • 2. Page 2 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Agenda I. Introduction II. Elements of Executable UML III. Standard Model Library
  • 3. Page 3 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 I. Introduction A. A Motivating Example B. Executable UML C. The Standards
  • 4. Page 4 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 A. A Motivating Example • E-Commerce Ordering System – Loosely based on the Online Bookstore Domain Case Study given in Appendix B of the book Executable UML: A Foundation for Model Driven Architecture by Stephen J. Mellor and Marc J. Balcer (Addison-Wesley, 2002) • To be designed in UML – Class models for structure – State machine models for behavior • To be implemented on the Web – Using Java/JEE – …or maybe C#/.Net – …or maybe LAMP – …or whatever…
  • 5. Page 5 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Ordering: Class Model Order is an active class whose classifier behavior is responsible for handling ordering functionality. Order is an active class whose classifier behavior is responsible for handling ordering functionality.
  • 6. Page 6 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Order: Classifier Behavior A state machine abstracts system behavior into a finite number of states. A state machine abstracts system behavior into a finite number of states. The system is modeled as having discrete transitions between the states. The system is modeled as having discrete transitions between the states. A transition may trigger further system behavior or system behavior may be dependent on the current state. A transition may trigger further system behavior or system behavior may be dependent on the current state.
  • 7. Page 7 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Order Behavior: EstablishCustomer Activity An activity specifies behavior as the coordinated execution of a set of subordinate actions. An activity specifies behavior as the coordinated execution of a set of subordinate actions. An action in one activity may call another activity. An action in one activity may call another activity. Data and control flow between the various actions. Data and control flow between the various actions. Other actions provide various data and computational functions. Other actions provide various data and computational functions. Full executability requires complete specification of behavior and computation. This is often much more easy to specify using a textual notation. Full executability requires complete specification of behavior and computation. This is often much more easy to specify using a textual notation.
  • 8. Page 8 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 The Question Is… • If we are going to take the time to carefully design our system using UML, e.g., – Structural models of classes and associations – Behavioral models using state machines or operations and messages • Then why can’t we use these directly to execute our system? The answer is: We can! • Just add detailed behavior… – …which is best done using a textual action language… – …which should be at the same semantic level as the rest of the model.
  • 9. Page 9 B. Executable UML: Perceived Issues • Making models detailed enough for machine execution defeats the purpose of models for human communication. • UML is not specified precisely enough to be executed (at least not in a standard way). • Graphical modeling notations are not good for detailed programming. Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
  • 10. Page 10 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Executable UML: Issue Resolutions • Making models detailed enough for machine execution defeats the purpose of models for human communication. – Executable models can still be more understandable than executable code. – Non-executable models are still useful, too. • UML is not specified precisely enough to be executed (at least not in a standard way). – The Foundational UML (fUML) standard specifies precise semantics for an executable subset of UML. – fUML Version 1.0 formal specification now available. • Graphical modeling notations are not good for detailed programming. – The Action Language for fUML (Alf) standard specifies a textual action language with fUML semantics. – Alf Version 1.0 finalization in progress.
  • 11. Page 11 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 C. The Standards • Unified Modeling Language (UML) • Executable UML Foundation (fUML) • UML Action Language (Alf)
  • 12. Page 12 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Unified Modeling Language (UML) The Unified Modeling Language (UML) is a graphical language for modeling the structure, behavior and interactions of software, hardware and business systems, standardized by the Object Management Group (OMG). • UML Version 1.1 (first standard) – December 1997 • UML Version 1.5 (with action semantics) – March 2003 • UML Version 2.0 (new version) – July 2005 • UML Version 2.4.1 – July 2011 • UML Version 2.5 (spec simplification) – May 2015 • UML Version 2.5.1 (current standard) – December 2017
  • 13. Page 13 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Executable UML Foundation (fUML) Foundational UML (fUML) is an executable subset of standard UML that can be used to define, in an operational style, the structural and behavioral semantics of systems. • fUML Version 1.0 – January 2011 • fUML Version 1.1 – July 2013 • fUML Version 1.2.1 – December 2016 • fUML Version 1.3 (current standard) – October 2017 • fUML Version 1.4 (migration to UML 2.5.1) – 2018 (planned)
  • 14. Page 14 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Key Components • Foundational UML Subset (fUML) – A computationally complete subset of the abstract syntax of UML (Version 2.4.1) – Kernel – Basic object-oriented capabilities – Common Behavior – General behavior and asynchronous communication – Activities – Activity modeling, including structured activities (but not including variables, exceptions, swimlanes, streaming or other “higher level” activity modeling) • Execution Model – A model of the execution semantics of user models within the fUML subset • Foundational Model Library – Primitive Types – Boolean, String, Integer, Real, Unlimited Natural – Primitive Behaviors – Boolean, String and Arithmetic Functions – Basic Input/Output – Based on the concept of “Channels” Added in fUML 1.1 Added in fUML 1.1
  • 15. Page 15 Other Precise Semantics Specifications The following specifications build on the foundation of fUML: •Precise Semantics of UML Composite Structure (PSCS) – Version 1.1 (beta) – June 2017 •Precise Semantics of UML State Machines (PSCS) – Version 1.0 (alpha) – December 2016 (in finalization) •Precise Semantics of Time for Foundational UML – RFP issued – December 2017 – Revised submissions due – August 2019 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018
  • 16. Page 16 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 UML Action Language (Alf) The Action Language for Foundational UML (Alf) is a textual surface representation for UML modeling elements with the primary purpose of acting as the surface notation for specifying executable (fUML) behaviors within an overall graphical UML model. (But which also provides an extended notation for structural modeling within the fUML subset.) • Alf Version 1.0 (beta) – November 2012 • Alf Version 1.0.1 (migration to fUML 1.1) – September 2013 • Alf Version 1.1 (current standard) – June 2017 • Alf Version 1.2 (migration to fUML 1.4) – 2018/2019 (planned)
  • 17. Page 17 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Key Components • Concrete Syntax – A BNF specification of the legal textual syntax of the Alf language. • Abstract Syntax – A MOF metamodel of the abstract syntax tree that is synthesized during parsing of an Alf text, with additional derived attributes and constraints that specify the static semantic analysis of that text. • Semantics – The semantics of Alf are defined by mapping the Alf abstract syntax metamodel to the fUML abstract syntax metamodel. • Standard Model Library – From the fUML Foundational Model Library • Primitive Types (plus Natural and Bit String) • Primitive Behaviors (plus Bit String Functions and Sequence Functions) • Basic Input/Output – Collection Functions – Similar to OCL collection operations for sequences – Collection Classes – Set, Ordered Set, Bag, List, Queue, Deque, Map
  • 18. Page 18 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 II. Elements of Executable UML A. Activities B. Actions C. Structure D. Asynchronous Communication
  • 19. Page 19 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 A. Activities • Activities and Parameters • Actions and Flows • Textual Notation • Tokens • Offers • Control Nodes • Structured Nodes
  • 20. Page 20 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Activities and Parameters An activity is a specification of behavior as the coordinated execution of subordinate actions, using a control and data flow model. An activity is a specification of behavior as the coordinated execution of subordinate actions, using a control and data flow model. An activity may have input, output and return parameters. An activity may have input, output and return parameters. The parameters have corresponding activity parameter node on the boundary of the diagrammatic representation of an activity. The parameters have corresponding activity parameter node on the boundary of the diagrammatic representation of an activity.
  • 21. Page 21 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Actions and Flows An action is a fundamental unit of executable behavior within an activity. An action is a fundamental unit of executable behavior within an activity. A pin is an activity node that either accepts input to or provides output from an action. A pin is an activity node that either accepts input to or provides output from an action. An object flow provides a path for passing objects or data. An object flow provides a path for passing objects or data. A control flow specifies the sequencing of actions. A control flow specifies the sequencing of actions. An activity diagram is a graph structure consisting of activity nodes connected by activity edges. An activity diagram is a graph structure consisting of activity nodes connected by activity edges.
  • 22. Page 22 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Textual Notation activity DoSomething(in input: Integer, out output Integer): Integer { output = A(input); return B(); } activity DoSomething(in input: Integer, out output Integer): Integer { output = A(input); return B(); } Alf behavioral notation maps to fUML activity models. Alf behavioral notation maps to fUML activity models. The semantics of the Alf notation is defined by its mapping to fUML The semantics of the Alf notation is defined by its mapping to fUML
  • 23. Page 23 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Tokens a = DoSomething(1, b);a = DoSomething(1, b); A token is a container for an object, datum or locus of control that may be present at an activity node. A token is a container for an object, datum or locus of control that may be present at an activity node. The activity is invoked with an argument of 1 for its input parameter. The activity is invoked with an argument of 1 for its input parameter. An object token with a value of 1 is placed on the input activity parameter node. An object token with a value of 1 is placed on the input activity parameter node. The object token flows to the input pin of action A along the object flow. The object token flows to the input pin of action A along the object flow. Action A fires and produces an object token on its output pin. Action A fires and produces an object token on its output pin. The object token flows to the output activity parameter node along the object flow. The object token flows to the output activity parameter node along the object flow. When it is done, action A produces a control token, which flows to action B along the control flow. When it is done, action A produces a control token, which flows to action B along the control flow. Action B accepts the control token and fires, producing an object token on its output pin. Action B accepts the control token and fires, producing an object token on its output pin. The object token flows to the output activity parameter node along the object flow. The object token flows to the output activity parameter node along the object flow. Values on the output activity parameter nodes are copied to the output arguments. Values on the output activity parameter nodes are copied to the output arguments.
  • 24. Page 24 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Offers An output pin offers its tokens to the targets of all outgoing object flows. An output pin offers its tokens to the targets of all outgoing object flows. A single token can only flow to one target. If two competing targets are both ready to accept an offer for the same token, it is indeterminate which will get the token. A single token can only flow to one target. If two competing targets are both ready to accept an offer for the same token, it is indeterminate which will get the token. Note: fUML semantics do not guarantee “liveliness” or “fairness” in the execution of actions competing for tokens. Note: fUML semantics do not guarantee “liveliness” or “fairness” in the execution of actions competing for tokens. Actions with no control constraints execute concurrently. This means that they may execute in parallel – or they may execute sequentially in any order. Actions with no control constraints execute concurrently. This means that they may execute in parallel – or they may execute sequentially in any order.
  • 25. Page 25 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Fork and Join Nodes order = 'Create Order'(); //@parallel { 'Fulfill Order'(order); 'Invoice Order'(order); } 'Close Out Order'(order); order = 'Create Order'(); //@parallel { 'Fulfill Order'(order); 'Invoice Order'(order); } 'Close Out Order'(order); A fork node copies the tokens it is offered, and offers a copy on each outgoing flow. A fork node copies the tokens it is offered, and offers a copy on each outgoing flow. A join node waits for a token to be offered on all incoming flows and then offers tokens on its outgoing flow. A join node waits for a token to be offered on all incoming flows and then offers tokens on its outgoing flow. In the Alf textual notation, forks and joins are implicit in the parallel block notation. In the Alf textual notation, forks and joins are implicit in the parallel block notation. Note: Alf does not actually provide any notation for competition for tokens on output pins. A fork node is always inserted for multiple flows out of any output pin. Note: Alf does not actually provide any notation for competition for tokens on output pins. A fork node is always inserted for multiple flows out of any output pin.
  • 26. Page 26 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Control Nodes An initial node generates a single control token. An initial node generates a single control token.A merge node passes on any tokens it receives. A merge node passes on any tokens it receives. A decision node routes tokens based on a decision input value. A decision node routes tokens based on a decision input value. An activity final node terminates the activity when it receives a token. An activity final node terminates the activity when it receives a token. A control node is an activity node used to coordinate the flow of (the offers for) tokens between other nodes. A control node is an activity node used to coordinate the flow of (the offers for) tokens between other nodes. Note: A data store node is used so a “card” token is available for each iteration. Note: A data store node is used so a “card” token is available for each iteration. Note: Since the decision node “gates” control flow, it must be provided with an incoming control token. Note: Since the decision node “gates” control flow, it must be provided with an incoming control token. Added in fUML 1.3 Added in fUML 1.3
  • 27. Page 27 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Structured Nodes card = 'Select Credit Card'(); do { charge = 'Create Credit Card Charge'(card); if ('Check Charge Approval'(charge)) { 'Notify Customer of Approval'(charge); declined = false; } else { 'Notify Customer of Denial'(charge); declined = true; } } while (declined); card = 'Select Credit Card'(); do { charge = 'Create Credit Card Charge'(card); if ('Check Charge Approval'(charge)) { 'Notify Customer of Approval'(charge); declined = false; } else { 'Notify Customer of Denial'(charge); declined = true; } } while (declined); A structured node is an activity node used to group subordinate nodes into a control structure. A structured node is an activity node used to group subordinate nodes into a control structure. An loop node iterates the execution of its body while a condition is true. An loop node iterates the execution of its body while a condition is true. By default, the condition is tested after execution of the body. By default, the condition is tested after execution of the body. A conditional node executes one clause or another based on the result of a test (or tests). A conditional node executes one clause or another based on the result of a test (or tests). Inputs to the loop node initialize loop variables available across all iterations of the loop. Inputs to the loop node initialize loop variables available across all iterations of the loop. Note: There is no normative UML graphical notation for loop or conditional nodes. Note: There is no normative UML graphical notation for loop or conditional nodes. break; true Alf also provides a traditional break statement. Alf also provides a traditional break statement.
  • 28. Page 28 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Expansion Regions 'Get Outstanding Orders'(customer) -> select order ('Is Delinquent?'(order)) -> iterate order ('Refer for Collection'(order)); 'Get Outstanding Orders'(customer) -> select order ('Is Delinquent?'(order)) -> iterate order ('Refer for Collection'(order)); An expansion region is used to apply subordinate actions on all members of an input collection An expansion region is used to apply subordinate actions on all members of an input collection A parallel expansion region applies nested behavior concurrently to all collection elements. A parallel expansion region applies nested behavior concurrently to all collection elements. An iterative expansion region applies nested behavior sequentially to all collection elements. An iterative expansion region applies nested behavior sequentially to all collection elements. Alf provides specialized notation that maps to typical uses of expansion regions. Alf provides specialized notation that maps to typical uses of expansion regions.
  • 29. Page 29 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Reduction A reduction action “inserts” a binary function between the elements of a sequence of values. A reduction action “inserts” a binary function between the elements of a sequence of values. this.totalAmount = this.lineItems.amount->reduce MoneyFunctions::Add; this.totalAmount = this.lineItems.amount->reduce MoneyFunctions::Add; this.totalAmount = this.lineItems.amount->reduce MoneyFunctions::Add ?? new Money(0, 0); this.totalAmount = this.lineItems.amount->reduce MoneyFunctions::Add ?? new Money(0, 0); This is shorthand for “this.lineItems->collect item (item.amount)”. This is shorthand for “this.lineItems->collect item (item.amount)”. If the input sequence is empty, then reduction results in “null” (the empty sequence). An Alf null-coalescing expression can be used to provide a default value for this case. (Corresponding UML not shown.) If the input sequence is empty, then reduction results in “null” (the empty sequence). An Alf null-coalescing expression can be used to provide a default value for this case. (Corresponding UML not shown.)
  • 30. Page 30 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 B. Actions • Invocation Actions • Object Actions • Structural Feature Actions • Link Actions NOTE: Some of these actions will be discussed in more detail later.NOTE: Some of these actions will be discussed in more detail later.
  • 31. Page 31 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Invocation Actions • Call Behavior – Calling an activity – Calling a primitive behavior • Call Operation • Send Signal • Accept Event PlaceOrder(customer, product) Max(throttle, limit) count + quantity order.addProduct(product, quantity) vehicle.EngageBrake(pressure) accept (signal: EngageBrake)
  • 32. Page 32 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Object Actions • Value Specification • Create Object • Destroy Object • Test Identity • Read Self • Read Extent • Read Is Classified Object • Reclassify Object 1 true "Hello" new Order() order.destroy() order == myOrder name != customerName this Order.allInstances() vehicle instanceof Car car hastype Hatchback reclassify order from PendingOrder to ClosedOrder
  • 33. Page 33 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Structural Feature Actions • Read Structural Feature • Add Structural Feature Value • Remove Structural Feature Value • Clear Structural Feature Value order.customer order.datePlaced = today order.lineItems->add(item) order.lineItems->addAt(1,item) order.lineItems->remove(item) order.lineItems->removeAt(1) order.card = null
  • 34. Page 34 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Link Actions • Read Link • Create Link • Destroy Link • Clear Association Owns.person(house=>thisHouse) thisHouse.person Owns.addLink(person=>jack, house=>newHouse) Owns.removeLink(person=>jack, house=>oldHouse) Owns.clearAssoc(jack)
  • 35. Page 35 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Computation • Indexing (from 1 , not 0) • Increment/Decrement • Arithmetic/Logic • Comparison • Conditional • Isolation order.lineItems[i] order.lineItems->at(i) index++ ++count total + value address & mask total > threshold index <= count count != 0 && total/count > limit count < min || count > max $this.sensor.getReading().value
  • 36. Page 36 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 C. Structure • Structural and Behavioral Models • Classes • Associations
  • 37. Page 37 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Structural and Behavioral Models • A structural model (e.g., a class model) specifies the relevant (types of) instances in a domain that may exist at any one point in time. – Structural semantics define how a structural model constrains allowable instances. • A behavioral model (e.g., an activity model) specifies behavior over time – Behavioral semantics define how a behavioral model changes the state of instances over time.
  • 38. Page 38 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Classes • Attributes • Data Types • Primitive Types • Operations and Methods • Structural Semantics • Behavioral Semantics A class is a classifier of objects that persist in the extent of the class, with an identity that is independent of the value of their attributes at any one time. A class is a classifier of objects that persist in the extent of the class, with an identity that is independent of the value of their attributes at any one time.
  • 39. Page 39 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Classes and Attributes A class may have attributes whose types are primitive, data types or other classes. A class may have attributes whose types are primitive, data types or other classes. A referential attribute, whose type is a class, is conventionally notated as an association with a class- owned association end. A referential attribute, whose type is a class, is conventionally notated as an association with a class- owned association end. A bidirectional association results in corresponding referential attributes on both associated classes. A bidirectional association results in corresponding referential attributes on both associated classes.
  • 40. Page 40 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Data Types A data type is a classifier of transient data values whose identity is based on the values of their attributes. A data type is a classifier of transient data values whose identity is based on the values of their attributes. Data types may have attributes, but not operations. Data types may have attributes, but not operations.
  • 41. Page 41 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Primitive Types • From UML 2.4.1 PrimitiveTypes Package – Boolean – Integer – Real – UnlimitedNatural – String Used since fUML 1.1 Used since fUML 1.1
  • 42. Page 42 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Classes: Operations and Methods An operation specifies a behavior that may be synchronously invoked on an instance of a class. An operation specifies a behavior that may be synchronously invoked on an instance of a class. A method defines the actual behavior that is invoked. A method defines the actual behavior that is invoked.
  • 43. Page 43 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Classes: Structural Semantics Structural semantics specify how a structural model constrains allowable instances. Structural semantics specify how a structural model constrains allowable instances. Objects are instances of classes with values for each attribute. Objects are instances of classes with values for each attribute. Class-owned association ends are structural features with values, like attributes. Class-owned association ends are structural features with values, like attributes. fUML does not actually give semantics to an association with class-owned ends, only to the ends as structural features. fUML does not actually give semantics to an association with class-owned ends, only to the ends as structural features. Note: fUML does provide “reified” semantics for associations that own their own ends, as will be discussed later. Note: fUML does provide “reified” semantics for associations that own their own ends, as will be discussed later.
  • 44. Page 44 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Classes: Behavioral Semantics • Creating an Order • Adding a Line Item • Canceling an Order Behavioral semantics specify how a behavioral model changes the state of instances over time. Behavioral semantics specify how a behavioral model changes the state of instances over time.
  • 45. Page 45 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Creating an Order order = new Order (customer, today) Before After @Create public Order (in customer: Customer, in datePlaced: Date) { this.datePlaced = datePlaced; this.totalAmount = new Money(dollars=>0, cents=>0); this.customer = customer; this.customer.orders->add(this); } @Create public Order (in customer: Customer, in datePlaced: Date) { this.datePlaced = datePlaced; this.totalAmount = new Money(dollars=>0, cents=>0); this.customer = customer; this.customer.orders->add(this); } A new object is created and the constructor operation is invoked. A new object is created and the constructor operation is invoked. The constructor initializes the new order’s attribute values… The constructor initializes the new order’s attribute values… …and adds the order to the customer’s list. …and adds the order to the customer’s list.
  • 46. Page 46 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Adding a Line Item Before After order.addProduct (product, 2) public addProduct (in product: Product, in quantity: Integer) { lineItem = new LineItem(product, quantity); this.lineItems->add(lineItem); this.totalAmount = MoneyFunctions::Add (this.totalAmount, lineItem.amount); } public addProduct (in product: Product, in quantity: Integer) { lineItem = new LineItem(product, quantity); this.lineItems->add(lineItem); this.totalAmount = MoneyFunctions::Add (this.totalAmount, lineItem.amount); } The method for the operation creates a new line item object… The method for the operation creates a new line item object… The addProduct operation is invoked on an existing Order object. The addProduct operation is invoked on an existing Order object. …adds the new object to the list of line items for the order… …adds the new object to the list of line items for the order… …and updates the total order amount. …and updates the total order amount.
  • 47. Page 47 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Canceling an Order Before After order.cancel() @Destroy public cancel() { this.customer.orders->remove(this); } @Destroy public cancel() { this.customer.orders->remove(this); } A destructor operation is invoked, after which the order object is destroyed. A destructor operation is invoked, after which the order object is destroyed. Because line items are aggregated by composition, they are destroyed, too. Because line items are aggregated by composition, they are destroyed, too. References to the destroyed object must be explicitly removed. References to the destroyed object must be explicitly removed.
  • 48. Page 48 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Associations • Classes and Associations • Structural Semantics • Behavioral Semantics An association is a classifier whose instances are links that relate other instances. An association is a classifier whose instances are links that relate other instances.
  • 49. Page 49 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Classes and Associations An association (that owns its ends) is a classifier of persistent links between the associated classes, which exist in the extent of the association. An association (that owns its ends) is a classifier of persistent links between the associated classes, which exist in the extent of the association.
  • 50. Page 50 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Associations: Structural Semantics Links are now semantic instances of the indicated associations. Links are now semantic instances of the indicated associations. Structural semantics specify how a structural model constrains allowable instance models. Structural semantics specify how a structural model constrains allowable instance models.
  • 51. Page 51 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Associations: Behavioral Semantics • Creating an Order (revised) • Canceling an Order (revised) Behavioral semantics specify how a behavioral model changes the state of instances over time. Behavioral semantics specify how a behavioral model changes the state of instances over time.
  • 52. Page 52 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Creating an Order (revised) order = new Order (customer, today) Before After @Create public Order (in customer: Customer, in datePlaced: Date) { this.datePlaced = datePlaced; this.totalAmount = new Money(dollars=>0, cents=>0); Customer_Order.addLink(customer, this); } @Create public Order (in customer: Customer, in datePlaced: Date) { this.datePlaced = datePlaced; this.totalAmount = new Money(dollars=>0, cents=>0); Customer_Order.addLink(customer, this); } A single action creates a bidirectional link. A single action creates a bidirectional link.
  • 53. Page 53 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Canceling an Order (revised) Before After order.cancel() @Destroy public cancel() { } @Destroy public cancel() { } A destructor operation is invoked, after which the order object is destroyed. A destructor operation is invoked, after which the order object is destroyed. Links in which the destroyed object participates are now also automatically destroyed. Links in which the destroyed object participates are now also automatically destroyed.
  • 54. Page 54 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 D. Asynchronous Communication • Signals and Receptions • Classifier Behaviors • Asynchronous Behavior
  • 55. Page 55 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Signals and Receptions A signal is a classifier whose instances may be communicated asynchronously. A signal is a classifier whose instances may be communicated asynchronously. A reception is a declaration of the ability to receive a signal. A reception is a declaration of the ability to receive a signal. A signal may have attributes that represent transmittable data. A signal may have attributes that represent transmittable data. More than one class can receive the same signal. More than one class can receive the same signal.
  • 56. Page 56 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Classifier Behaviors An active class is one that has a classifier behavior. Only active class may receive signals. An active class is one that has a classifier behavior. Only active class may receive signals. A classifier behavior is an autonomous behavior started when an active class is instantiated. A classifier behavior is an autonomous behavior started when an active class is instantiated.
  • 57. Page 57 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Asynchronous Behavior accept (submission: SubmitCharge); card = submission.card; do { new CreditCardCharge(card, this); accept (response: ChargeApproved) { this.customer.ChargeApproved(response.charge); break; } or accept (response: ChargeDeclined) { this.customer.ChargeDeclined(response.charge); } while (true); accept (submission: SubmitCharge); card = submission.card; do { new CreditCardCharge(card, this); accept (response: ChargeApproved) { this.customer.ChargeApproved(response.charge); break; } or accept (response: ChargeDeclined) { this.customer.ChargeDeclined(response.charge); } while (true); The order object accepts a signal to submit a charge. The order object accepts a signal to submit a charge. The order object creates a new credit card charge object, which begins its asynchronous behavior. The order object creates a new credit card charge object, which begins its asynchronous behavior. Note: UML semantics require a separate action to start the behavior of a new object. However, Alf notation for creating an active class maps to both create and start object behavior actions. Note: UML semantics require a separate action to start the behavior of a new object. However, Alf notation for creating an active class maps to both create and start object behavior actions. The order object accepts a signal from the charge object that the charge is approved. The order object accepts a signal from the charge object that the charge is approved.The order object sends a signal to the customer that the charge is approved. The order object sends a signal to the customer that the charge is approved.
  • 58. Page 58 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 III. Standard Model Library • Primitive Behaviors • Collection Functions • Collection Classes • Basic Input/Output
  • 59. Page 59 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Primitive Behaviors • Integer Functions – Arithmetic, Comparison, Conversion • Unlimited Natural Functions – Comparison, Conversion • Boolean Functions – Logical Operations, Conversion • Bit String Functions – Bit-wise operations, Conversion • String Functions – Concatenation, Size, Substring • RealFunctions – Arithmetic, Comparison, Conversion Added in fUML 1.1Added in fUML 1.1
  • 60. Page 60 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Collection Functions Collection functions operate on sequences of values of any type. • Testing and accessing functions – Examples: seq->isEmpty(), seq1->equals(seq2), seq->at(n) • Non-mutating funtions – Examples: seq2 = seq->including(x), seq3 = seq1->union(seq2) • Mutating “in place” functions – Examples: seq->add(x), seq1->addAll(seq2), seq2->remove(x)
  • 61. Page 61 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Collection Classes Collection classes define objects that represent collections of values of a given type.
  • 62. Page 62 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Basic Input Output: Channels
  • 63. Page 63 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Basic Input Output: Reading and Writing Lines activity ReadLine (out errorStatus: Status[0..1]): String { return StandardIntputChannel.allInstances().readLine(status); } activity ReadLine (out errorStatus: Status[0..1]): String { return StandardIntputChannel.allInstances().readLine(status); } activity WriteLine (in value: String, out errorStatus: Status[0..1]) { StandardOutputChannel.allInstances().writeLine(result, status); } activity WriteLine (in value: String, out errorStatus: Status[0..1]) { StandardOutputChannel.allInstances().writeLine(result, status); }
  • 64. Page 64 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 Hello World activity Hello() { WriteLine("Hello World!"); } activity Hello() { WriteLine("Hello World!"); }
  • 65. Page 65 Copyright © 2018 Model Driven Solutions, Inc. 19 February 2018 References • Foundational UML (fUML) – Semantics of a Foundational Subset for Executable UML Models standard, http://www.omg.org/spec/FUML – fUML Open Source (Reference) Implementation Project, http://fuml.modeldriven.org/ • Action Language for fUML (Alf) – Action Language for Foundational UML (Alf) standard, http://www.omg.org/spec/ALF – Alf Open Source (Reference) Implementation Repository, http://alf.modeldriven.org/ • Contact – Email: [email protected] – Twitter: @seidewitz or http://twitter.com/seidewitz

Editor's Notes