Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7,...
-
Upload
magdalene-jacobs -
Category
Documents
-
view
220 -
download
0
Transcript of Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7,...
![Page 1: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/1.jpg)
Exploring a Model-Oriented and Executable Syntax for UML Attributes
SERA 2013 (August 7, 2013 in Prague, Czech Republic)
Omar Badreddin, Andrew Forward, Timothy C. Lethbridge1 University of [email protected] / [email protected] [email protected] / [email protected]@site.uottawa.cahttp://umple.org
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
1
![Page 2: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/2.jpg)
Overview• Model Oriented Programming• Umple Overview• Attributes in Practice• Umple Attribute Syntax• Attribute Code Generation
2
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 3: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/3.jpg)
The philosophy of Model-Oriented Programming (MOP)
MOP
3
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 4: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/4.jpg)
Embed Models In Code
4
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 5: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/5.jpg)
Unify programs and models
5
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 6: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/6.jpg)
Supports Modeller and Programmer workflows
Model-First Incremental Re-Engineering
6
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 7: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/7.jpg)
Text Diagram Duality
7
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 8: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/8.jpg)
Reduce Need to Round-Trip
8
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 9: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/9.jpg)
Easily Integrate with Text-Based Tooling
9
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 10: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/10.jpg)
A MOP technology and language family
Umple
10
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 11: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/11.jpg)
Why call it Umple?
UML Programming LanguageAmpleSimple
11
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 12: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/12.jpg)
What does Umple support?• Modeling abstractions
• Associations, Attributes, State machines (both simple and composite), model based tracing, and simple debugging.
• Supported languages• Java, C++, Ruby, PhP
• Integration support• XMI for model exchange, Ecore, textUML, Yuml,
GraphViz, SQL
12
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 13: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/13.jpg)
Attributes In PracticeGoogle Code:• fizzbuzz• ExcelLibrary• Ndependencyinjection• Java Bug Reporting SourceForge:• jEdit• FreemakerFreecode:• Java Financial Library
• 1831 variables• 620 static• 1211 instance
• 469 classes
13
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 14: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/14.jpg)
Variable Distribution
14
Static (Class) Variables
Member (Object) Variables
E.g. avoiding magic numbers and state symbols (i.e. LEFT_NODE, RIGHT_NODE)
Mostly counts, names and booleans (51%)
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
A lot of other object types
![Page 15: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/15.jpg)
Attribute Identification
15
About 33% had attribute-like methods implementations
Surprising that 35% had no external access at all
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 16: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/16.jpg)
Attribute Code Generation
16
Over half were simple boiler-plate implementations
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 17: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/17.jpg)
Observations• Many simple set and get methods
• Drastic reduction in boiler-plate code
• Few truly immutable attributes• Few attributes set in constructor• Immutability needed for proper hash code (Java)
• Attribute multiplicities typically ‘one’• Basic multiplicity (0..1, 1, 0..*) available for attributes
17
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 18: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/18.jpg)
Umple Attributesclass Student{ // defaults to String studentNumber; String grade; Integer entryAverage;}
18
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 19: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/19.jpg)
Umple Data Types
Umple treats the following attribute types as specialString (always the default if unspecified)IntegerDoubleBooleanDate, Time
• Code generation from the above will generate suitable types in the underlying language (Java, PHP, etc.)
• Umple classes can be used as types, but consider associations instead 19
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 20: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/20.jpg)
Initializing Attributesclass Student{ // Initial value set to “Unknown”, // not required in class constructor name = "Unknown";
// Initialized, but can also be reset defaulted type = “FullTime”; // Name initialized to null in // constructor lazy program;}
20
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 21: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/21.jpg)
Immutable Attributesclass Student{ // Cannot be changed after set in constructor immutable idNumber;
// Can be set once, right after construction, // and is immutable after that // Useful for frameworks where objects are // created without initializing values lazy immutable barcode;}
21
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 22: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/22.jpg)
Derived Attributesclass Rectangle{ Integer l; Integer w; // Derived Attributes Integer perimeter = { 2*getL() + 2*getW() } Integer area = { getL() * getW() }}
22
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 23: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/23.jpg)
Additional Attribute Optionsclass Student{ // Umple assigns the next // available number autounique id; // Creates a constant value const Integer MAX_NUM_COURSES = 8;}
class Address{ // An address has many lines String[] lines;}
23
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 24: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/24.jpg)
Attribute Code Generation (1)
class Rectangle{ name = "Rectangle";
Integer length;
Integer width; Integer area = {getLenth() * getWidth()} }
24
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 25: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/25.jpg)
Attribute Code Generation (2)// line 2 "model.ump"public class Rectangle{ @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) public @interface umplesourcefile{int[] line();String[] file();int[] javaline();int[] length();}
//------------------------ // MEMBER VARIABLES //------------------------
//Rectangle Attributes private String name; private int length; private int width;
//------------------------ // CONSTRUCTOR //------------------------
public Rectangle(int aLength, int aWidth) { name = "Rectangle"; length = aLength; width = aWidth; }
//------------------------ // INTERFACE //------------------------
public boolean setName(String aName) { boolean wasSet = false; name = aName; wasSet = true; return wasSet; } public boolean setLength(int aLength) { boolean wasSet = false; length = aLength; wasSet = true; return wasSet; }
public boolean setWidth(int aWidth) { boolean wasSet = false; width = aWidth; wasSet = true; return wasSet; }
public String getName() { return name; }
public int getLength() { return length; }
public int getWidth() { return width; }
@umplesourcefile(line={7},file={"model.ump"},javaline={79},length={2}) public int getArea() { return getLenth() * getWidth(); }
public void delete() {}
public String toString() { String outputString = ""; return super.toString() + "["+ "name" + ":" + getName()+ "," + "length" + ":" + getLength()+ "," + "width" + ":" + getWidth()+ "," + "area" + ":" + getArea()+ "]" + outputString; }}
25
Constructor based on attributes missing an initial value
Set method returns a boolean (was it “set” or not)
Simple get method
Derived methods do not have internal members
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 26: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/26.jpg)
http://try.umple.org
Try It Yourself
26
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 27: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/27.jpg)
Summary
27
Umple features can be created and viewed diagrammatically or textually
Umple extends a base language in a minimally invasive way
Intermediate generated code should not be edited
=
Modeling is programming and vice versa
No round-trip engineering required
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 28: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/28.jpg)
Getting involved• Open source project: https://code.google.com/p/umple/• Teaching
• Use Umple to introduce UML and MDE.• Umplification
• Incrementally replace boilerplate code with modeling abstractions
• Lightweight Modeling and Analysis• Visualize Umple source as UML diagrams to analyze it
• Model driven development• Generate code in one of the supported base languages
Comments and feedback: [email protected] 28
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 29: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/29.jpg)
More information
• Publications on Umple:
https://code.google.com/p/umple/wiki/Publications
• The User Manual:
http://cruise.eecs.uottawa.ca/umple/GettingStarted.html
• Umple Home page: http://cruise.eecs.uottawa.ca/umple/
• Download Umple:
http://cruise.eecs.uottawa.ca/umpleonline/download_eclipse
_umple_plugin.html
• Report an issue:
https://code.google.com/p/umple/issues/entry
29
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes
![Page 30: Exploring a Model-Oriented and Executable Syntax for UML Attributes SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew.](https://reader035.fdocuments.in/reader035/viewer/2022062516/56649dc45503460f94ab785d/html5/thumbnails/30.jpg)
30
Expl
orin
g a
Mod
el-O
rient
ed a
nd E
xecu
tabl
e Sy
ntax
for U
ML
Attrib
utes