practical models in practice
DESCRIPTION
presented by Lukas Renggli at the CHOOSE Forum 2012TRANSCRIPT
![Page 1: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/1.jpg)
Practical Modelsin Practicewww.lukas-renggli.ch
![Page 2: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/2.jpg)
Practical Models of Models in Practice
www.lukas-renggli.ch
![Page 3: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/3.jpg)
Practical Meta-Models in Practice
www.lukas-renggli.ch
![Page 4: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/4.jpg)
‣ Software Engineer at GoogleYouTube Video Analytics
‣ SCG AlumniBachelor, Master and PhD
‣ Open-Source CommunitiesSeaside, Magritte and PierHelvetia, PetitParser
Lukas Renggli
![Page 5: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/5.jpg)
Roadmap1. Protocol Buffers
Meta-data model for serialization2. Magritte
Meta-model for generic services3. Google Web Toolkit
Model-driven web architecture4. Helvetia
Meta-model for programming languages
![Page 6: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/6.jpg)
1Protocol BuffersMeta-data model for serialization
![Page 7: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/7.jpg)
Protocol Buffers
‣ Encode structured data‣ Language-neutral‣ Platform-neutral‣ Extensible‣ Efficient
![Page 8: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/8.jpg)
Protocol Buffer IDL
message Person { required int32 id = 1; required string name = 2; optional string email = 3;}
![Page 9: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/9.jpg)
message Person { required int32 id = 1; required string name = 2; optional string email = 3;}
C++
protoc
![Page 10: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/10.jpg)
Serialize in C++
Person person;person.set_name("John Doe");person.set_id(1234);person.set_email("[email protected]");
fstream output("myfile", ios::out | ios::binary);person.SerializeToOstream(&output);
![Page 11: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/11.jpg)
Deserialize in Python
file = open("myfile", "rb")person = Person()person.ParseFromString(file.read())file.close
print "Name: ", person.nameprint "E-mail: ", person.email
![Page 12: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/12.jpg)
Demo
![Page 13: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/13.jpg)
Why not XML/JSON?
‣ Protocol Buffers are– 3—10 times smaller– 20—100 times faster– consistent code generators– less ambiguous– evolvable
![Page 14: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/14.jpg)
message Person { required int32 id = 1; required string name = 2; optional string email = 3;}
message Person { required int32 id = 1; required string name = 2; repeated string email = 3; repeated Phone phone = 4;}
:Person:Person
:Person
![Page 15: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/15.jpg)
‣ Describe your data once, and use it across platforms and languages‣ Evolution supported by design‣ Used at Google for almost all
– data storage (file formats, database)– remote procedure protocols (RPC)
![Page 16: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/16.jpg)
2MagritteMeta-model for generic services
![Page 17: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/17.jpg)
Address Object
street = 'Schützenmattstrasse'plz = 3012place = 'Bern'canton = 'Bern'
:Address
![Page 18: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/18.jpg)
Address Class
street = 'Schützenmattstrasse'plz = 3012place = 'Bern'canton = 'Bern'
:Address
street: Stringplz: Integerplace: Stringcanton: String
Address
class
![Page 19: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/19.jpg)
Address Description
street = 'Schützenmattstrasse'plz = 3012place = 'Bern'canton = 'Bern'
:Address
label = 'Street'
:StringDescription
label = 'PLZ'required = truerange = 1000..9999
:NumberDescription
label = 'Place'required = true
:StringDescription
label = 'Canton'required = truesorted = trueoptions = #( 'Bern' 'Zurich' ... )
:SingleOptionDescription
label = 'Address'
:Containerdescription
Magritte
![Page 20: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/20.jpg)
result := anAddress asMorph addButtons; addWindow; callInWorld
User Interfaces
![Page 21: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/21.jpg)
result := self call: (anAddress asComponent addValidatedForm; yourself)
Web Interfaces
*
*
*
![Page 22: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/22.jpg)
Other ServicesViewers
EditorsReports
ValidationFiltering
Serialization
Copying
IndexingInitialization
Initialization
ExtensionAdaptation
Customization
![Page 23: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/23.jpg)
Domain Model
Metamodel
Meta-
Metamodel
<described-by>
<described-by>
Developer
End User
![Page 24: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/24.jpg)
Domain Model
Metamodel
Meta-
Metamodel
Magritte
Developer
<described-by>
<described-by>
Magritte
End User
![Page 25: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/25.jpg)
Adaptive Object Model
Run-time
![Page 26: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/26.jpg)
End userscustomizability
![Page 27: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/27.jpg)
Demo
![Page 28: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/28.jpg)
‣ Very powerful and flexible‣ Runtime adaptive code‣ End-user programmable code‣ Can cause meta meta-confusion‣ Can be slower than hardcoding
Magritte
![Page 29: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/29.jpg)
3Google Web ToolkitModel-driven web architecture
![Page 30: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/30.jpg)
public class Main implements EntryPoint { public void onModuleLoad() { Label label = new Label(“Hello World”); RootPanel.add(label); }}
Is this really a model?
![Page 31: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/31.jpg)
public class Main implements EntryPoint { public void onModuleLoad() { Label label = new Label(“Hello World”); RootPanel.add(label); }}
Is this really a model?
High-levelWidgets
![Page 32: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/32.jpg)
public class Main implements EntryPoint { public void onModuleLoad() { Label label = new Label(“Hello World”); RootPanel.add(label); }}
Is this really a model?
High-levelWidgets
DescriptionLanguage
![Page 33: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/33.jpg)
platformindependentmodel
modeltransformation
public class Main implements EntryPoint { public void onModuleLoad() { Label label = new Label(“Hello World”); RootPanel.add(label); }}
![Page 34: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/34.jpg)
Transformation
Mozilla Chrome Safari IE ...
English
French
German
...
![Page 35: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/35.jpg)
‣ Write JavaScript using a high-level widget library in a well defined (statically typed) language‣ Translate and optimize code towards
specific browsers‣ Debugging actually works nowadays
GWT
![Page 36: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/36.jpg)
4HelvetiaMeta-model for programming languages
He vetia
![Page 37: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/37.jpg)
![Page 38: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/38.jpg)
![Page 39: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/39.jpg)
![Page 40: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/40.jpg)
ProgrammingLanguage
Model
![Page 41: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/41.jpg)
a..z a..z
0..9
ID ::= letter { letter | digit } ;
![Page 42: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/42.jpg)
scanIdentifier self step. ((currentCharacter between: $A and: $Z) or: [ currentCharacter between: $a and: $z ]) ifTrue: [ [ self recordMatch: #IDENTIFIER. self step. (currentCharacter between: $0 and: $9)or: [ (currentCharacter between: $A and: $Z) or: [ currentCharacter between: $a and: $z ] ] ] whileTrue. ^ self reportLastMatch ]
![Page 43: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/43.jpg)
#(#[1 0 9 0 25 0 13 0 34 0 17 0 40 0 21 0 41] #[1 0 9 0 25 0 13 0 34 0 93 0 76 0 157 0 112] #[1 2 38 0 21 2 38 0 25 2 38 0 26 0 13 0 34] #[0 1 154 0 16 0 21 0 25 0 26 0 34 0 40 0 41] #[0 1 210 0 76 0 81] #[0 1 214 0 76 0 81] #[1 0 173 0 76 0 177 0 81] #[0 1 134 0 16 0 21 0 25 0 26 0 34 0 40 0 41] #[1 1 46 0 21 1 46 0 25 1 46 0 26 1 69] #[1 1 54 0 21 1 54 0 25 1 54 0 26 1 54 0 34] #[0 2 102 0 21 0 25 0 26 0 34 0 40 0 41 0 76]
#[0 2 50 0 21 0 25 0 26 0 76 0 79] #[1 1 13 0 76 2 85 0 124 1 21 0 125] #[1 2 89 0 17 2 30 0 21 2 30 0 82] #[1 2 93 0 21 2 97 0 82] )
![Page 44: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/44.jpg)
a..z a..z
0..9
ID ::= letter { letter | digit } ;
44
![Page 45: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/45.jpg)
letter
letter digit
sequence
choice
many
ID ::= letter { letter | digit } ;
45
![Page 46: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/46.jpg)
letter
letter digit
sequence
choice
many
46
Transformable
Composable
Extensible
Customizable
![Page 47: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/47.jpg)
letter
letter digit
sequence
choice
many
47
He vetiaContextual
Menus
NavigationSearch
CodeExpansion
ErrorCorrection
CustomInspector
Refactorings
CodeFolding
CodeHighlighting
Debuggers
Editors
![Page 48: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/48.jpg)
Demo
![Page 49: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/49.jpg)
‣ Grammar is the meta-model‣ Composable programming languages‣ Extensible programming languages‣ Tooling is built around the grammar
He vetia
![Page 50: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/50.jpg)
StructuralModel
BehavioralModel
Run-
time
Stat
icRu
n-tim
eAd
aptiv
e
He vetia
![Page 51: Practical Models in Practice](https://reader033.vdocuments.us/reader033/viewer/2022051412/549b3e86b4795901098b46e5/html5/thumbnails/51.jpg)
“Meta-models are the enablers ofpractical software development.”
www.lukas-renggli.ch
He vetia