SlideShare a Scribd company logo
Hands On With the Alf Action Language
Making Executable Modeling Even Easier
No Magic World Symposium, Allen TX
Ed Seidewitz
Director of Research and Development
nMeta LLC ● http://www.nmeta.us
ed@nmeta.us ● @seidewitz
Copyright © 2017 Ed Seidewitz
23 May 2017
Page 2
Goals
• To learn the basics of the Alf action language for Executable UML.
• To learn how to use the Alf Plugin for MagicDraw.
• To practice hands-on using Alf with Cameo Simulation Toolkit.
Copyright © 2017 Ed Seidewitz
Page 3
Prerequisites
• Participant
– Basic knowledge of class, activity and state machine modeling
using MagicDraw
– Some experience with model execution using Cameo Simulation
Toolkit
– General familiarity with programming/scripting (particularly in a
language like C++, Java, JavaScript, etc.)
• System (for hands-on exercises)
– MagicDraw 18.4 or 18.5
– Cameo Simulation Toolkit 18.4 or 18.5
– Alf plugin v18.5
Copyright © 2017 Ed Seidewitz
Page 4
4
Installing the Alf plugin
Copyright © 2017 Ed Seidewitz
Plugin documentation is available at:
https://docs.nomagic.com/display/ALFP185/Alf+plugin
Under Plugins (no
cost), download/
install the Alf plugin
v18.5 beta.
Select Help ► Resource/Plugin
Manager to open the Resource/
Plugin Manager window.
 Commercial release
planned for v19.0 in
Q4 2017.
Page 5
Background
Copyright © 2017 Ed Seidewitz
Page 6
Executable UML
Executable UML is a (growing) subset of standard UML that can be
used to define, in an executable, operational style, the structural and
behavioral semantics of systems.
• Foundational UML (structural and activity models)
– http://www.omg.org/spec/FUML
• Precise Semantics of UML Composite Structure (PSCS)
– http://www.omg.org/spec/PSCS
• Precise Semantics of UML State Machines (PSSM)
– http://www.omg.org/spec/PSSM
Copyright © 2017 Ed Seidewitz
• Action Language for Foundational UML (Alf)
– http://www.omg.org/spec/ALF
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.
Alf Plugin
Page 7
Why an action language?
• Graphical notations are good for…
Copyright © 2017 Ed Seidewitz
Structural models
High-level behavioral models
Page 8
Why an action language?
• …but not so good for detailed behavior
Copyright © 2017 Ed Seidewitz
Full executability requires complete
specification of behavior and
computation. This is often much more
easy to specify using a textual notation.
Page 9
Why not just use a scripting language?
• Scripting language:
No standard syntactic or semantic integration with UML
• Alf:
Full, standardized syntactic and semantic integration with UML
Copyright © 2017 Ed Seidewitz
this.lineItems->remove(item)
this.totalAmount = Subtract(this.totalAmount, item.amount)
ALH.removeValue(self, "lineItems", item);
arguments = ALH.createList();
arguments.add(ALH.getValue(self, "totalAmount"));
arguments.add(ALH.getValue(item, "amount”));
ALH.setValue(self, "totalAmount",
ALH.callBehavior("Subtract", arguments));
Example using the MagicDraw-
specific Action Language
Helper API for JavaScript.
Page 10
The basic idea: Alf maps to fUML
Copyright © 2017 Ed Seidewitz
activity DoSomething(in input: Integer, out output Integer): Integer {
output = A(input);
return B();
}
Alf behavioral notation
maps to fUML activity
models.
The semantics of the Alf notation is
defined by its mapping to fUML
Page 11
Hands On
Hello World
Copyright © 2017 Ed Seidewitz
Page 12
Create an Alf Project
Copyright © 2017 Ed Seidewitz
In the Alf folder,
select the Alf
template.
 The Alf template automatically
loads the Alf Library model and
sets Alf as the default language
for opaque behaviors, actions
and expressions.
Under Other,
select Project
from Template.
Select File ► New Project to
open the project creation window.
Create a Hello
World project.
Page 13
Create the Hello World activity
Copyright © 2017 Ed Seidewitz
Create a
new Activity.
Enter the Alf code in
the Alf editor window.
When the code is
correct, click OK.
Right-click on
the Activity and
select Alf.
Page 14
Executing the activity
Copyright © 2017 Ed Seidewitz
Right click on the
Activity and select
Simulation ► Run.
Set Animation Speed
to the highest level…
…and click
here to run.
Output appears in
the console pane.
Page 15
Basic Concepts
Copyright © 2017 Ed Seidewitz
Page 16
Assignment as data flow
Copyright © 2017 Ed Seidewitz
a = +1;
b = -a;
a = A(a) + B(b);
Local names map to
forked object flows.
Subexpressions are
evaluated concurrently.
A re-assigned local
name actually maps
to a new flow.
 The literal “1” has type
Natural. The expression
“+1” has type Integer. The
expression “A(a) + B(b)” has
type Integer, which is not
compatible with Natural.
The local name a implicitly
gets the type Integer.
Statements map to structured
activity nodes with control flows
to enforce sequential execution.
a = 1;
a = A(a); ✗
type conformance
Page 17
Using Alf for behaviors
Copyright © 2017 Ed Seidewitz
lineItem = new LineItem(product, quantity);
this.lineItems->add(lineItem);
this.totalAmount = this.totalAmount + lineItem.amount;
Method of an operation
this.lineItems = checkOut.items;
Customer_Order.createLink(checkOut.customer, this);
this.datePlace = CurrentDate();
this.totalAmount = lineItems.amount->reduce '+';
this.SubmitCharge(checkOut.card);
Behavior on a state machine
battFrac = battCond / this.maxBattLevel;
gThrottle = Max(accelPos * (1-battFrac), this.maxGThrottle);
eThrottle = Max(accelPos * battFrac, this.maxEThrottle);
Body of an action
Page 18
Using Alf for expressions
Copyright © 2017 Ed Seidewitz
Activity Edge Guards
State Machine Transition Guards
Page 19
Hands On
Stopwatch
Copyright © 2017 Ed Seidewitz
Page 20
Open the StopWatch sample project
Copyright © 2017 Ed Seidewitz
…
Click Samples on
the Welcome Screen
Under Simulation,
choose the StopWatch
sample project.
 Select File ► Save Project As…
to save a local copy of the project
before continuing.
Page 21
Setup the project for Alf
Copyright © 2017 Ed Seidewitz
Remove the existing
Project Usage for
fUML_Library.
Select File ► Use Project ►
Use Local Project to open the
Use Project window.
From the modelLibraries
directory, choose
Alf-Library.mdzip.
Click Finish to
load the library.
Page 22
Open the StopWatch state machine
Copyright © 2017 Ed Seidewitz
Page 23
Replace the ready state behavior
Copyright © 2017 Ed Seidewitz
Open the Specification
window for the ready
state.
Under Entry, change
the Behavior Type to
Opaque Behavior.
 Be sure to select the ready
state as a whole, not just the
line for the entry behavior.
Page 24
Replace the reset timer activity with Alf code
Copyright © 2017 Ed Seidewitz
 Be sure to click on the line
for the entry behavior, not
the entire state.
Right click on the entry
behavior and select Alf.
Enter the code
into the Alf
editor window.
replaced by
 The use of the prefix this
is required to access an
attribute value in Alf.
Page 25
Show the Alf code on the state machine diagram
Copyright © 2017 Ed Seidewitz
Open the Symbol
Properties window for
the ready state.
Set the Opaque
Behavior Display Mode
property to Body.
Page 26
Replace the Increase time activity with Alf code
Copyright © 2017 Ed Seidewitz
replaced by
 The ++ operator
increments its argument.
Page 27
Executing the StopWatch model
Copyright © 2017 Ed Seidewitz
Right click on the
StopWatch class and select
Simulation ► Run.
Start the simulation, then
trigger the start signal.
Output is displayed
in the console tab.
The current state
machine configuration
is animated.
Page 28
Sequences
Copyright © 2017 Ed Seidewitz
Page 29
Sequences
Copyright © 2017 Ed Seidewitz
activity GetReadings(in sensors: Sensor[*]): Integer[*] {
readings = sensors->collect sensor (sensor.reading);
return readings;
}
The input parameter has
an unordered set of
values (by default).
Object flows always carry
ordered sequences of
values.
Values are handled one
by one within the
expansion region.
The read actions
happen concurrently.
The result is a sequence
ordered respective to the
input sequence.
The return parameter
gets an unordered set
of values (by default).
 The Alf on the left could be
written more simply as:
return sensors.reading;
The local name reading
implicitly gets the type Integer
and the multiplicity [0..*].
 Arbitrary sequences cannot
be assigned to local names
with multiplicity [0..1].
reading = -1;
readings = reading;
reading = readings;
Implicitly gets the multiplicity [0..1]
A single value is really just a
sequence of length 1.
✗ multiplicity conformance
Page 30
Null as the empty sequence
Copyright © 2017 Ed Seidewitz
A LiteralNull is intended to be used to explicitly model the lack of a value.
In the context of a MultiplicityElement with a multiplicity lower bound of 0,
this corresponds to the empty set (i.e., a set of no values). It is equivalent
to specifying no values for the Element.
null = any [ ] { }
From the UML 2.5 specification (clause 8.2.3):
The Alf interpretation: null is the (untyped) empty sequence
sensors = null;
sensors.readings;
WriteLine(null);
WriteLine(name ?? "no name");
“null” can be assigned to any target with
a multiplicity lower bound of 0.
This is not an error. It is equivalent to
sensors->collect sensor (sensor.reading);
which evaluates to “null”.
 An argument for
a parameter of
multiplicity 1..1
cannot be null.
✗
multiplicity conformance
A null-coalescing expression can be used
to provide a non-null “default value”.
Page 31
Hands On
Address Book
Copyright © 2017 Ed Seidewitz
Page 32
Create the Address Book project
Copyright © 2017 Ed Seidewitz
Create a new project
using the Alf
template, as before.
Page 33
Create the Address Book class model
Copyright © 2017 Ed Seidewitz
Make sure these Entry
attributes are public.
Give this association
end a multiplicity of *.
Page 34
Create Address Book and Entry operations
Copyright © 2017 Ed Seidewitz
This is a constructor operation.
Create it in the usual way, and then
apply the standard Create stereotype.
Page 35
Create the Entry constructor method
Copyright © 2017 Ed Seidewitz
Right click on the Entry
operation and select
Create Method ►
Behavior to open this
selection window.
Choose either
Activity or
Opaque Behavior.
Right click on the
Entry operation again
and select Alf to open
the Alf editor.
Enter the Alf code to
initialize an Entry.
Page 36
Create Address Book operation methods
Copyright © 2017 Ed Seidewitz
Create methods for
the AddressBook
operations, and then
enter the Alf code
shown for them.
 A select expression is used to filter
a sequence based on a condition.
The index [1] ensures that at most
one value is selected.
 This expression will return either a
single value or null, as required by
the return multiplicity of 0..1.
 The constructor
operation is used when
creating an instance of
the Entry class.
 The braces { } are
required in if statement
clauses in Alf.
Page 37
Test the Address Book model
Copyright © 2017 Ed Seidewitz
Create an
AddressBookTest
activity with the
Alf code below.
Run the activity
and see if it works!
 A class can also be instantiated without
a constructor, as in new AddressBook().
 The ?? (null-coalescing) operator is
used here because get has return
multiplicity 0..1 and the + operator
requires argument multiplicity 1..1.

More Related Content

What's hot

Executable UML and SysML Workshop
Executable UML and SysML WorkshopExecutable UML and SysML Workshop
Executable UML and SysML Workshop
Ed Seidewitz
 
DDD - 4 - Domain Driven Design_ Architectural patterns.pdf
DDD - 4 - Domain Driven Design_ Architectural patterns.pdfDDD - 4 - Domain Driven Design_ Architectural patterns.pdf
DDD - 4 - Domain Driven Design_ Architectural patterns.pdf
Eleonora Ciceri
 
Togaf 9 template solution concept diagram
Togaf 9 template   solution concept diagramTogaf 9 template   solution concept diagram
Togaf 9 template solution concept diagram
Sandeep Sharma IIMK Smart City,IoT,Bigdata,Cloud,BI,DW
 
Presentation - Rational Unified Process
Presentation - Rational Unified ProcessPresentation - Rational Unified Process
Presentation - Rational Unified ProcessSharad Srivastava
 
[Capella Days 2020] Innovating with MBSE – Medical Device Example
[Capella Days 2020] Innovating with MBSE – Medical Device Example[Capella Days 2020] Innovating with MBSE – Medical Device Example
[Capella Days 2020] Innovating with MBSE – Medical Device Example
Obeo
 
MBSE and Model-Based Testing with Capella
MBSE and Model-Based Testing with CapellaMBSE and Model-Based Testing with Capella
MBSE and Model-Based Testing with Capella
Obeo
 
SysML v2 - What's the big deal, anyway?
SysML v2 - What's the big deal, anyway?SysML v2 - What's the big deal, anyway?
SysML v2 - What's the big deal, anyway?
Ed Seidewitz
 
Panorama 360 Enterprise Business Architecture Framework SAMPLE
Panorama 360  Enterprise Business Architecture Framework SAMPLEPanorama 360  Enterprise Business Architecture Framework SAMPLE
Panorama 360 Enterprise Business Architecture Framework SAMPLE
Pierre Gagne
 
Requirements Management for Safety-Critical Products
Requirements Management for Safety-Critical ProductsRequirements Management for Safety-Critical Products
Requirements Management for Safety-Critical Products
David Hetherington
 
Project Phases Showing Phase Content And Documents With Analysis And Design R...
Project Phases Showing Phase Content And Documents With Analysis And Design R...Project Phases Showing Phase Content And Documents With Analysis And Design R...
Project Phases Showing Phase Content And Documents With Analysis And Design R...
SlideTeam
 
CapellaDays2022 | Saratech | Interface Control Document Generation and Linkag...
CapellaDays2022 | Saratech | Interface Control Document Generation and Linkag...CapellaDays2022 | Saratech | Interface Control Document Generation and Linkag...
CapellaDays2022 | Saratech | Interface Control Document Generation and Linkag...
Obeo
 
People Process Technology Strategy Powerpoint Template
People Process Technology Strategy Powerpoint TemplatePeople Process Technology Strategy Powerpoint Template
People Process Technology Strategy Powerpoint Template
SlideTeam
 
System of systems modeling with Capella
System of systems modeling with CapellaSystem of systems modeling with Capella
System of systems modeling with Capella
Obeo
 
About Myself In Interview For Experienced PowerPoint Presentation Slides
About Myself In Interview For Experienced PowerPoint Presentation SlidesAbout Myself In Interview For Experienced PowerPoint Presentation Slides
About Myself In Interview For Experienced PowerPoint Presentation Slides
SlideTeam
 
Seamless MLOps with Seldon and MLflow
Seamless MLOps with Seldon and MLflowSeamless MLOps with Seldon and MLflow
Seamless MLOps with Seldon and MLflow
Databricks
 
Key Metrics Ppt Design
Key Metrics Ppt DesignKey Metrics Ppt Design
Key Metrics Ppt Design
SlideTeam
 
Change Management Evaluation Powerpoint Presentation Slides
Change Management Evaluation Powerpoint Presentation SlidesChange Management Evaluation Powerpoint Presentation Slides
Change Management Evaluation Powerpoint Presentation Slides
SlideTeam
 
Board Meeting Agenda Ppt Presentation Presentation Examples
Board Meeting Agenda Ppt Presentation Presentation ExamplesBoard Meeting Agenda Ppt Presentation Presentation Examples
Board Meeting Agenda Ppt Presentation Presentation Examples
SlideTeam
 
Project Management Metrics Dashboard Including Budget
Project Management Metrics Dashboard Including BudgetProject Management Metrics Dashboard Including Budget
Project Management Metrics Dashboard Including Budget
SlideTeam
 
OCL tutorial
OCL tutorial OCL tutorial
OCL tutorial
Jordi Cabot
 

What's hot (20)

Executable UML and SysML Workshop
Executable UML and SysML WorkshopExecutable UML and SysML Workshop
Executable UML and SysML Workshop
 
DDD - 4 - Domain Driven Design_ Architectural patterns.pdf
DDD - 4 - Domain Driven Design_ Architectural patterns.pdfDDD - 4 - Domain Driven Design_ Architectural patterns.pdf
DDD - 4 - Domain Driven Design_ Architectural patterns.pdf
 
Togaf 9 template solution concept diagram
Togaf 9 template   solution concept diagramTogaf 9 template   solution concept diagram
Togaf 9 template solution concept diagram
 
Presentation - Rational Unified Process
Presentation - Rational Unified ProcessPresentation - Rational Unified Process
Presentation - Rational Unified Process
 
[Capella Days 2020] Innovating with MBSE – Medical Device Example
[Capella Days 2020] Innovating with MBSE – Medical Device Example[Capella Days 2020] Innovating with MBSE – Medical Device Example
[Capella Days 2020] Innovating with MBSE – Medical Device Example
 
MBSE and Model-Based Testing with Capella
MBSE and Model-Based Testing with CapellaMBSE and Model-Based Testing with Capella
MBSE and Model-Based Testing with Capella
 
SysML v2 - What's the big deal, anyway?
SysML v2 - What's the big deal, anyway?SysML v2 - What's the big deal, anyway?
SysML v2 - What's the big deal, anyway?
 
Panorama 360 Enterprise Business Architecture Framework SAMPLE
Panorama 360  Enterprise Business Architecture Framework SAMPLEPanorama 360  Enterprise Business Architecture Framework SAMPLE
Panorama 360 Enterprise Business Architecture Framework SAMPLE
 
Requirements Management for Safety-Critical Products
Requirements Management for Safety-Critical ProductsRequirements Management for Safety-Critical Products
Requirements Management for Safety-Critical Products
 
Project Phases Showing Phase Content And Documents With Analysis And Design R...
Project Phases Showing Phase Content And Documents With Analysis And Design R...Project Phases Showing Phase Content And Documents With Analysis And Design R...
Project Phases Showing Phase Content And Documents With Analysis And Design R...
 
CapellaDays2022 | Saratech | Interface Control Document Generation and Linkag...
CapellaDays2022 | Saratech | Interface Control Document Generation and Linkag...CapellaDays2022 | Saratech | Interface Control Document Generation and Linkag...
CapellaDays2022 | Saratech | Interface Control Document Generation and Linkag...
 
People Process Technology Strategy Powerpoint Template
People Process Technology Strategy Powerpoint TemplatePeople Process Technology Strategy Powerpoint Template
People Process Technology Strategy Powerpoint Template
 
System of systems modeling with Capella
System of systems modeling with CapellaSystem of systems modeling with Capella
System of systems modeling with Capella
 
About Myself In Interview For Experienced PowerPoint Presentation Slides
About Myself In Interview For Experienced PowerPoint Presentation SlidesAbout Myself In Interview For Experienced PowerPoint Presentation Slides
About Myself In Interview For Experienced PowerPoint Presentation Slides
 
Seamless MLOps with Seldon and MLflow
Seamless MLOps with Seldon and MLflowSeamless MLOps with Seldon and MLflow
Seamless MLOps with Seldon and MLflow
 
Key Metrics Ppt Design
Key Metrics Ppt DesignKey Metrics Ppt Design
Key Metrics Ppt Design
 
Change Management Evaluation Powerpoint Presentation Slides
Change Management Evaluation Powerpoint Presentation SlidesChange Management Evaluation Powerpoint Presentation Slides
Change Management Evaluation Powerpoint Presentation Slides
 
Board Meeting Agenda Ppt Presentation Presentation Examples
Board Meeting Agenda Ppt Presentation Presentation ExamplesBoard Meeting Agenda Ppt Presentation Presentation Examples
Board Meeting Agenda Ppt Presentation Presentation Examples
 
Project Management Metrics Dashboard Including Budget
Project Management Metrics Dashboard Including BudgetProject Management Metrics Dashboard Including Budget
Project Management Metrics Dashboard Including Budget
 
OCL tutorial
OCL tutorial OCL tutorial
OCL tutorial
 

Similar to Hands On With the Alf Action Language: Making Executable Modeling Even Easier

Using Alf with Cameo Simulation Toolkit - Part 1: Basics
Using Alf with Cameo Simulation Toolkit - Part 1: BasicsUsing Alf with Cameo Simulation Toolkit - Part 1: Basics
Using Alf with Cameo Simulation Toolkit - Part 1: Basics
Ed Seidewitz
 
Standards-Based Executable UML: Today's Reality and Tomorrow's Promise
Standards-Based Executable UML: Today's Reality and Tomorrow's PromiseStandards-Based Executable UML: Today's Reality and Tomorrow's Promise
Standards-Based Executable UML: Today's Reality and Tomorrow's Promise
Ed Seidewitz
 
IN4308 1
IN4308 1IN4308 1
IN4308 1
Eelco Visser
 
C language
C languageC language
C language
Yasir Khan
 
Elm Detroit 9/7/17 - Planting Seeds with Elm
Elm Detroit 9/7/17 - Planting Seeds with ElmElm Detroit 9/7/17 - Planting Seeds with Elm
Elm Detroit 9/7/17 - Planting Seeds with Elm
Elm Detroit
 
Start with swift
Start with swiftStart with swift
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
Rohit Shrivastava
 
elm-d3 @ NYC D3.js Meetup (30 June, 2014)
elm-d3 @ NYC D3.js Meetup (30 June, 2014)elm-d3 @ NYC D3.js Meetup (30 June, 2014)
elm-d3 @ NYC D3.js Meetup (30 June, 2014)Spiros
 
Reduce course notes class xii
Reduce course notes class xiiReduce course notes class xii
Reduce course notes class xii
Syed Zaid Irshad
 
C programming
C programmingC programming
C programming
Rounak Samdadia
 
UI Testing with Earl Grey
UI Testing with Earl GreyUI Testing with Earl Grey
UI Testing with Earl Grey
Shyam Bhat
 
C programming
C programmingC programming
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World Haskell
Bryan O'Sullivan
 
Tutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng verTutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng ver
Qrembiezs Intruder
 
Functional programming in Java
Functional programming in Java  Functional programming in Java
Functional programming in Java
Haim Michael
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
Chiew Carol
 
Thinking In Swift
Thinking In SwiftThinking In Swift
Thinking In Swift
Janie Clayton
 
Best practices android_2010
Best practices android_2010Best practices android_2010
Best practices android_2010
Sunil Bhatia (Certified Scrum Master)
 
Functional Swift
Functional SwiftFunctional Swift
Functional Swift
Geison Goes
 

Similar to Hands On With the Alf Action Language: Making Executable Modeling Even Easier (20)

Using Alf with Cameo Simulation Toolkit - Part 1: Basics
Using Alf with Cameo Simulation Toolkit - Part 1: BasicsUsing Alf with Cameo Simulation Toolkit - Part 1: Basics
Using Alf with Cameo Simulation Toolkit - Part 1: Basics
 
Standards-Based Executable UML: Today's Reality and Tomorrow's Promise
Standards-Based Executable UML: Today's Reality and Tomorrow's PromiseStandards-Based Executable UML: Today's Reality and Tomorrow's Promise
Standards-Based Executable UML: Today's Reality and Tomorrow's Promise
 
IN4308 1
IN4308 1IN4308 1
IN4308 1
 
C language
C languageC language
C language
 
Elm Detroit 9/7/17 - Planting Seeds with Elm
Elm Detroit 9/7/17 - Planting Seeds with ElmElm Detroit 9/7/17 - Planting Seeds with Elm
Elm Detroit 9/7/17 - Planting Seeds with Elm
 
Start with swift
Start with swiftStart with swift
Start with swift
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
elm-d3 @ NYC D3.js Meetup (30 June, 2014)
elm-d3 @ NYC D3.js Meetup (30 June, 2014)elm-d3 @ NYC D3.js Meetup (30 June, 2014)
elm-d3 @ NYC D3.js Meetup (30 June, 2014)
 
Reduce course notes class xii
Reduce course notes class xiiReduce course notes class xii
Reduce course notes class xii
 
C programming
C programmingC programming
C programming
 
UI Testing with Earl Grey
UI Testing with Earl GreyUI Testing with Earl Grey
UI Testing with Earl Grey
 
C programming
C programmingC programming
C programming
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World Haskell
 
Tutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng verTutorial basic of c ++lesson 1 eng ver
Tutorial basic of c ++lesson 1 eng ver
 
Functional programming in Java
Functional programming in Java  Functional programming in Java
Functional programming in Java
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
Thinking In Swift
Thinking In SwiftThinking In Swift
Thinking In Swift
 
ASP.NET Basics
ASP.NET Basics ASP.NET Basics
ASP.NET Basics
 
Best practices android_2010
Best practices android_2010Best practices android_2010
Best practices android_2010
 
Functional Swift
Functional SwiftFunctional Swift
Functional Swift
 

More from Ed Seidewitz

The Very Model of a Modern Metamodeler
The Very Model of a Modern MetamodelerThe Very Model of a Modern Metamodeler
The Very Model of a Modern Metamodeler
Ed Seidewitz
 
SysML v2 and the Next Generation of Modeling Languages
SysML v2 and the Next Generation of Modeling LanguagesSysML v2 and the Next Generation of Modeling Languages
SysML v2 and the Next Generation of Modeling Languages
Ed Seidewitz
 
SysML v2 and MBSE: The next ten years
SysML v2 and MBSE: The next ten yearsSysML v2 and MBSE: The next ten years
SysML v2 and MBSE: The next ten years
Ed Seidewitz
 
Precise Semantics Standards at OMG: Executing on the Vision
Precise Semantics Standards at OMG: Executing on the VisionPrecise Semantics Standards at OMG: Executing on the Vision
Precise Semantics Standards at OMG: Executing on the Vision
Ed Seidewitz
 
Model Driven Architecture without Automation
Model Driven Architecture without AutomationModel Driven Architecture without Automation
Model Driven Architecture without Automation
Ed Seidewitz
 
UML: This Time We Mean It!
UML: This Time We Mean It!UML: This Time We Mean It!
UML: This Time We Mean It!
Ed Seidewitz
 
A Unified View of Modeling and Programming
A Unified View of Modeling and ProgrammingA Unified View of Modeling and Programming
A Unified View of Modeling and Programming
Ed Seidewitz
 
UML as a Programming Language
UML as a Programming LanguageUML as a Programming Language
UML as a Programming Language
Ed Seidewitz
 
Executable UML Roadmap (as of September 2014)
Executable UML Roadmap (as of September 2014)Executable UML Roadmap (as of September 2014)
Executable UML Roadmap (as of September 2014)Ed Seidewitz
 
Essence: A Common Ground for Flexible Methods
Essence: A Common Ground for Flexible MethodsEssence: A Common Ground for Flexible Methods
Essence: A Common Ground for Flexible MethodsEd Seidewitz
 
UML: Once More with Meaning
UML: Once More with MeaningUML: Once More with Meaning
UML: Once More with Meaning
Ed Seidewitz
 
Succeeding with Agile in the Federal Government: A Coach's Perspective
Succeeding with Agile in the Federal Government: A Coach's PerspectiveSucceeding with Agile in the Federal Government: A Coach's Perspective
Succeeding with Agile in the Federal Government: A Coach's PerspectiveEd Seidewitz
 
UML 2.5: Specification Simplification
UML 2.5: Specification SimplificationUML 2.5: Specification Simplification
UML 2.5: Specification Simplification
Ed Seidewitz
 
Models, Programs and Executable UML
Models, Programs and Executable UMLModels, Programs and Executable UML
Models, Programs and Executable UMLEd Seidewitz
 
Programming in UML: An Introduction to fUML and Alf
Programming in UML: An Introduction to fUML and AlfProgramming in UML: An Introduction to fUML and Alf
Programming in UML: An Introduction to fUML and Alf
Ed Seidewitz
 
Architecting Your Enterprise
Architecting Your EnterpriseArchitecting Your Enterprise
Architecting Your EnterpriseEd Seidewitz
 
Programming in UML: Why and How
Programming in UML: Why and HowProgramming in UML: Why and How
Programming in UML: Why and How
Ed Seidewitz
 

More from Ed Seidewitz (17)

The Very Model of a Modern Metamodeler
The Very Model of a Modern MetamodelerThe Very Model of a Modern Metamodeler
The Very Model of a Modern Metamodeler
 
SysML v2 and the Next Generation of Modeling Languages
SysML v2 and the Next Generation of Modeling LanguagesSysML v2 and the Next Generation of Modeling Languages
SysML v2 and the Next Generation of Modeling Languages
 
SysML v2 and MBSE: The next ten years
SysML v2 and MBSE: The next ten yearsSysML v2 and MBSE: The next ten years
SysML v2 and MBSE: The next ten years
 
Precise Semantics Standards at OMG: Executing on the Vision
Precise Semantics Standards at OMG: Executing on the VisionPrecise Semantics Standards at OMG: Executing on the Vision
Precise Semantics Standards at OMG: Executing on the Vision
 
Model Driven Architecture without Automation
Model Driven Architecture without AutomationModel Driven Architecture without Automation
Model Driven Architecture without Automation
 
UML: This Time We Mean It!
UML: This Time We Mean It!UML: This Time We Mean It!
UML: This Time We Mean It!
 
A Unified View of Modeling and Programming
A Unified View of Modeling and ProgrammingA Unified View of Modeling and Programming
A Unified View of Modeling and Programming
 
UML as a Programming Language
UML as a Programming LanguageUML as a Programming Language
UML as a Programming Language
 
Executable UML Roadmap (as of September 2014)
Executable UML Roadmap (as of September 2014)Executable UML Roadmap (as of September 2014)
Executable UML Roadmap (as of September 2014)
 
Essence: A Common Ground for Flexible Methods
Essence: A Common Ground for Flexible MethodsEssence: A Common Ground for Flexible Methods
Essence: A Common Ground for Flexible Methods
 
UML: Once More with Meaning
UML: Once More with MeaningUML: Once More with Meaning
UML: Once More with Meaning
 
Succeeding with Agile in the Federal Government: A Coach's Perspective
Succeeding with Agile in the Federal Government: A Coach's PerspectiveSucceeding with Agile in the Federal Government: A Coach's Perspective
Succeeding with Agile in the Federal Government: A Coach's Perspective
 
UML 2.5: Specification Simplification
UML 2.5: Specification SimplificationUML 2.5: Specification Simplification
UML 2.5: Specification Simplification
 
Models, Programs and Executable UML
Models, Programs and Executable UMLModels, Programs and Executable UML
Models, Programs and Executable UML
 
Programming in UML: An Introduction to fUML and Alf
Programming in UML: An Introduction to fUML and AlfProgramming in UML: An Introduction to fUML and Alf
Programming in UML: An Introduction to fUML and Alf
 
Architecting Your Enterprise
Architecting Your EnterpriseArchitecting Your Enterprise
Architecting Your Enterprise
 
Programming in UML: Why and How
Programming in UML: Why and HowProgramming in UML: Why and How
Programming in UML: Why and How
 

Recently uploaded

Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 

Recently uploaded (20)

Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 

Hands On With the Alf Action Language: Making Executable Modeling Even Easier

  • 1. Hands On With the Alf Action Language Making Executable Modeling Even Easier No Magic World Symposium, Allen TX Ed Seidewitz Director of Research and Development nMeta LLC ● http://www.nmeta.us ed@nmeta.us ● @seidewitz Copyright © 2017 Ed Seidewitz 23 May 2017
  • 2. Page 2 Goals • To learn the basics of the Alf action language for Executable UML. • To learn how to use the Alf Plugin for MagicDraw. • To practice hands-on using Alf with Cameo Simulation Toolkit. Copyright © 2017 Ed Seidewitz
  • 3. Page 3 Prerequisites • Participant – Basic knowledge of class, activity and state machine modeling using MagicDraw – Some experience with model execution using Cameo Simulation Toolkit – General familiarity with programming/scripting (particularly in a language like C++, Java, JavaScript, etc.) • System (for hands-on exercises) – MagicDraw 18.4 or 18.5 – Cameo Simulation Toolkit 18.4 or 18.5 – Alf plugin v18.5 Copyright © 2017 Ed Seidewitz
  • 4. Page 4 4 Installing the Alf plugin Copyright © 2017 Ed Seidewitz Plugin documentation is available at: https://docs.nomagic.com/display/ALFP185/Alf+plugin Under Plugins (no cost), download/ install the Alf plugin v18.5 beta. Select Help ► Resource/Plugin Manager to open the Resource/ Plugin Manager window.  Commercial release planned for v19.0 in Q4 2017.
  • 5. Page 5 Background Copyright © 2017 Ed Seidewitz
  • 6. Page 6 Executable UML Executable UML is a (growing) subset of standard UML that can be used to define, in an executable, operational style, the structural and behavioral semantics of systems. • Foundational UML (structural and activity models) – http://www.omg.org/spec/FUML • Precise Semantics of UML Composite Structure (PSCS) – http://www.omg.org/spec/PSCS • Precise Semantics of UML State Machines (PSSM) – http://www.omg.org/spec/PSSM Copyright © 2017 Ed Seidewitz • Action Language for Foundational UML (Alf) – http://www.omg.org/spec/ALF 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. Alf Plugin
  • 7. Page 7 Why an action language? • Graphical notations are good for… Copyright © 2017 Ed Seidewitz Structural models High-level behavioral models
  • 8. Page 8 Why an action language? • …but not so good for detailed behavior Copyright © 2017 Ed Seidewitz Full executability requires complete specification of behavior and computation. This is often much more easy to specify using a textual notation.
  • 9. Page 9 Why not just use a scripting language? • Scripting language: No standard syntactic or semantic integration with UML • Alf: Full, standardized syntactic and semantic integration with UML Copyright © 2017 Ed Seidewitz this.lineItems->remove(item) this.totalAmount = Subtract(this.totalAmount, item.amount) ALH.removeValue(self, "lineItems", item); arguments = ALH.createList(); arguments.add(ALH.getValue(self, "totalAmount")); arguments.add(ALH.getValue(item, "amount”)); ALH.setValue(self, "totalAmount", ALH.callBehavior("Subtract", arguments)); Example using the MagicDraw- specific Action Language Helper API for JavaScript.
  • 10. Page 10 The basic idea: Alf maps to fUML Copyright © 2017 Ed Seidewitz activity DoSomething(in input: Integer, out output Integer): Integer { output = A(input); return B(); } Alf behavioral notation maps to fUML activity models. The semantics of the Alf notation is defined by its mapping to fUML
  • 11. Page 11 Hands On Hello World Copyright © 2017 Ed Seidewitz
  • 12. Page 12 Create an Alf Project Copyright © 2017 Ed Seidewitz In the Alf folder, select the Alf template.  The Alf template automatically loads the Alf Library model and sets Alf as the default language for opaque behaviors, actions and expressions. Under Other, select Project from Template. Select File ► New Project to open the project creation window. Create a Hello World project.
  • 13. Page 13 Create the Hello World activity Copyright © 2017 Ed Seidewitz Create a new Activity. Enter the Alf code in the Alf editor window. When the code is correct, click OK. Right-click on the Activity and select Alf.
  • 14. Page 14 Executing the activity Copyright © 2017 Ed Seidewitz Right click on the Activity and select Simulation ► Run. Set Animation Speed to the highest level… …and click here to run. Output appears in the console pane.
  • 15. Page 15 Basic Concepts Copyright © 2017 Ed Seidewitz
  • 16. Page 16 Assignment as data flow Copyright © 2017 Ed Seidewitz a = +1; b = -a; a = A(a) + B(b); Local names map to forked object flows. Subexpressions are evaluated concurrently. A re-assigned local name actually maps to a new flow.  The literal “1” has type Natural. The expression “+1” has type Integer. The expression “A(a) + B(b)” has type Integer, which is not compatible with Natural. The local name a implicitly gets the type Integer. Statements map to structured activity nodes with control flows to enforce sequential execution. a = 1; a = A(a); ✗ type conformance
  • 17. Page 17 Using Alf for behaviors Copyright © 2017 Ed Seidewitz lineItem = new LineItem(product, quantity); this.lineItems->add(lineItem); this.totalAmount = this.totalAmount + lineItem.amount; Method of an operation this.lineItems = checkOut.items; Customer_Order.createLink(checkOut.customer, this); this.datePlace = CurrentDate(); this.totalAmount = lineItems.amount->reduce '+'; this.SubmitCharge(checkOut.card); Behavior on a state machine battFrac = battCond / this.maxBattLevel; gThrottle = Max(accelPos * (1-battFrac), this.maxGThrottle); eThrottle = Max(accelPos * battFrac, this.maxEThrottle); Body of an action
  • 18. Page 18 Using Alf for expressions Copyright © 2017 Ed Seidewitz Activity Edge Guards State Machine Transition Guards
  • 19. Page 19 Hands On Stopwatch Copyright © 2017 Ed Seidewitz
  • 20. Page 20 Open the StopWatch sample project Copyright © 2017 Ed Seidewitz … Click Samples on the Welcome Screen Under Simulation, choose the StopWatch sample project.  Select File ► Save Project As… to save a local copy of the project before continuing.
  • 21. Page 21 Setup the project for Alf Copyright © 2017 Ed Seidewitz Remove the existing Project Usage for fUML_Library. Select File ► Use Project ► Use Local Project to open the Use Project window. From the modelLibraries directory, choose Alf-Library.mdzip. Click Finish to load the library.
  • 22. Page 22 Open the StopWatch state machine Copyright © 2017 Ed Seidewitz
  • 23. Page 23 Replace the ready state behavior Copyright © 2017 Ed Seidewitz Open the Specification window for the ready state. Under Entry, change the Behavior Type to Opaque Behavior.  Be sure to select the ready state as a whole, not just the line for the entry behavior.
  • 24. Page 24 Replace the reset timer activity with Alf code Copyright © 2017 Ed Seidewitz  Be sure to click on the line for the entry behavior, not the entire state. Right click on the entry behavior and select Alf. Enter the code into the Alf editor window. replaced by  The use of the prefix this is required to access an attribute value in Alf.
  • 25. Page 25 Show the Alf code on the state machine diagram Copyright © 2017 Ed Seidewitz Open the Symbol Properties window for the ready state. Set the Opaque Behavior Display Mode property to Body.
  • 26. Page 26 Replace the Increase time activity with Alf code Copyright © 2017 Ed Seidewitz replaced by  The ++ operator increments its argument.
  • 27. Page 27 Executing the StopWatch model Copyright © 2017 Ed Seidewitz Right click on the StopWatch class and select Simulation ► Run. Start the simulation, then trigger the start signal. Output is displayed in the console tab. The current state machine configuration is animated.
  • 28. Page 28 Sequences Copyright © 2017 Ed Seidewitz
  • 29. Page 29 Sequences Copyright © 2017 Ed Seidewitz activity GetReadings(in sensors: Sensor[*]): Integer[*] { readings = sensors->collect sensor (sensor.reading); return readings; } The input parameter has an unordered set of values (by default). Object flows always carry ordered sequences of values. Values are handled one by one within the expansion region. The read actions happen concurrently. The result is a sequence ordered respective to the input sequence. The return parameter gets an unordered set of values (by default).  The Alf on the left could be written more simply as: return sensors.reading; The local name reading implicitly gets the type Integer and the multiplicity [0..*].  Arbitrary sequences cannot be assigned to local names with multiplicity [0..1]. reading = -1; readings = reading; reading = readings; Implicitly gets the multiplicity [0..1] A single value is really just a sequence of length 1. ✗ multiplicity conformance
  • 30. Page 30 Null as the empty sequence Copyright © 2017 Ed Seidewitz A LiteralNull is intended to be used to explicitly model the lack of a value. In the context of a MultiplicityElement with a multiplicity lower bound of 0, this corresponds to the empty set (i.e., a set of no values). It is equivalent to specifying no values for the Element. null = any [ ] { } From the UML 2.5 specification (clause 8.2.3): The Alf interpretation: null is the (untyped) empty sequence sensors = null; sensors.readings; WriteLine(null); WriteLine(name ?? "no name"); “null” can be assigned to any target with a multiplicity lower bound of 0. This is not an error. It is equivalent to sensors->collect sensor (sensor.reading); which evaluates to “null”.  An argument for a parameter of multiplicity 1..1 cannot be null. ✗ multiplicity conformance A null-coalescing expression can be used to provide a non-null “default value”.
  • 31. Page 31 Hands On Address Book Copyright © 2017 Ed Seidewitz
  • 32. Page 32 Create the Address Book project Copyright © 2017 Ed Seidewitz Create a new project using the Alf template, as before.
  • 33. Page 33 Create the Address Book class model Copyright © 2017 Ed Seidewitz Make sure these Entry attributes are public. Give this association end a multiplicity of *.
  • 34. Page 34 Create Address Book and Entry operations Copyright © 2017 Ed Seidewitz This is a constructor operation. Create it in the usual way, and then apply the standard Create stereotype.
  • 35. Page 35 Create the Entry constructor method Copyright © 2017 Ed Seidewitz Right click on the Entry operation and select Create Method ► Behavior to open this selection window. Choose either Activity or Opaque Behavior. Right click on the Entry operation again and select Alf to open the Alf editor. Enter the Alf code to initialize an Entry.
  • 36. Page 36 Create Address Book operation methods Copyright © 2017 Ed Seidewitz Create methods for the AddressBook operations, and then enter the Alf code shown for them.  A select expression is used to filter a sequence based on a condition. The index [1] ensures that at most one value is selected.  This expression will return either a single value or null, as required by the return multiplicity of 0..1.  The constructor operation is used when creating an instance of the Entry class.  The braces { } are required in if statement clauses in Alf.
  • 37. Page 37 Test the Address Book model Copyright © 2017 Ed Seidewitz Create an AddressBookTest activity with the Alf code below. Run the activity and see if it works!  A class can also be instantiated without a constructor, as in new AddressBook().  The ?? (null-coalescing) operator is used here because get has return multiplicity 0..1 and the + operator requires argument multiplicity 1..1.

Editor's Notes

  1. 4