Download presentation
Presentation is loading. Please wait.
1
Models 2015 M. Garzón, A. Forward, and T. Lethbridge
Textual Modeling and Model-Oriented Programming using Umple Tutorial Slides Models 2015 M. Garzón, A. Forward, and T. Lethbridge
2
Motivation From our studies of practitioners
Code generation is weak in widely-deployed tools Tools are awkward, do not interoperate Modellers mostly do it for documentation make important errors From our teaching of modeling Students learned syntax, but failed to learn Semantics Pragmatics To create implementable models due to lack of feedback Umple Tutorial M. Garzon and A. Forward
3
Umple: Simple, Ample, UML Programming Language
1. Open source code generator for UML The only one that has Infinitely nested state machines, with concurrency Proper referential integrity and multiplicity constraints on associations 2. Textual modelling tool set Command line compiler Web-based tool (UmpleOnline) for demos and education Eclipse plugin 3. Pre-processor to add UML, patterns and other features on top of Java, PhP and other languages Umple Tutorial M. Garzon and A. Forward
4
Exercise: Compiling and Changing a Model
Go to Look at the example at the bottom Observe: attribute, association, class hierarchy, mixin Click on Load the above code into UmpleOnline Observe and modify the diagram Add an attribute Make a multiplicity error, then undo Generate code and take a look Download, compile and run if you want Umple Tutorial M. Garzon and A. Forward
5
Hello World Example in the User Manual
Umple Tutorial M. Garzon and A. Forward
6
Hello World Example in UmpleOnline
Umple Tutorial M. Garzon and A. Forward
7
State machine example in UmpleOnline
Umple Tutorial M. Garzon and A. Forward
8
State machine detail in the user manual
Umple Tutorial M. Garzon and A. Forward
9
Demo of the command line Umple compiler
Follows conventions of gcc Used by ant scripts for building Umple Tutorial M. Garzon and A. Forward
10
Umple Philosophy 1-4 P1. Modeling is programming and vice versa
P2. An Umple programmer should never need to edit generated code to accomplish any task. P3. The Umple compiler can accept and generate code that uses nothing but UML abstractions. The above is the inverse of the following P4. A program without Umple features can be compiled by an Umple compiler. e.g. input Java results in the same as output Umple Tutorial M. Garzon and A. Forward
11
Umple Philosophy 5-8 P5. A programmer can incrementally add Umple features to an existing program Umplification P6. Umple extends the base language in a minimally invasive and safe way. P7. Umple features can be created and viewed diagrammatically or textually P8. Umple goes beyond UML Umple Tutorial M. Garzon and A. Forward
12
Umplification Umplification: ‘amplication’ + converting into Umple.
Produces a program with behavior identical to the original one, but written in Umple. Eliminates the distinction between code and model. Proceeds incrementally until the desired level of abstraction is achieved. Umple Tutorial M. Garzon and A. Forward
13
Umplification: The Transformation Steps
Transformation 0: Initial transformation Transformation 1: Transformation of generalization, dependency, and namespace declarations. Transformation 2: Analysis and conversion of many instance variables, along with the methods that use the variables. Transformation 2a: Transformation of variables to UML/Umple attributes. Transformation 2b: Transformation of variables in one or more classes to UML/Umple associations. Transformation 2c: Transformation of variables to UML/Umple state machines. Umple Tutorial M. Garzon and A. Forward
14
Umplification Process
Umple Tutorial M. Garzon and A. Forward
15
Umplificator Architecture
Umple Tutorial M. Garzon and A. Forward
16
Systems umplified JhotDraw 7.5.1 Umple Tutorial
M. Garzon and A. Forward
17
Systems umplified JhotDraw 7.5.1 Umple Tutorial
M. Garzon and A. Forward
18
Systems umplified Weka – Associations umplified Args4J- Modernization
Original Args4j source code is composed of 61 classes and 2223 LOC. Umplified Args4j source code is composed of 122 (2 per input class) umple files and 1980 LOC. # LOC in files containing modeling constructs (X.ump) is 312. # LOC in files with algorithmic/logic code (X code.ump) is 1668. The developer must then translate 1518 lines of code rather than 2223 lines of code. Umple Tutorial M. Garzon and A. Forward
19
Attributes in Umple More than just variables
Umple Tutorial M. Garzon and A. Forward
20
Attributes http://attributes.umple.org
Attributes are a familiar occurrence, they are very similar to instance variables, but not identical.
21
Attributes Exercise #1
22
Code Generation (JavaDocs)
23
Associations in Umple Associations http://associations.umple.org
Notice the inline and independent state machines Umple Tutorial M. Garzon and A. Forward
24
Associations Associations are a first class entities in Umple. We support 42 unique combinations of directional, bidirectional and reflexive associations. Each implemented with their own unique semantics. Textually, you can inline associations directly within one side of the relationship.
25
Associations Exercise #1
Answer: class Shape2D { } class EllipticalShape { isA Shape2D; semiMajorAxis; } class Polygon {
26
Associations Exercise #2
Answer: class Shape2D { center; } class EllipticalShape { isA Shape2D; semiMajorAxis; class Polygon { class Circle { isA EllipticalShape; class Ellipse{ class SimplePolygon { orientation; isA Polygon; class ArbitraryPolygon { points; class Rectangle { isA SimplePolygon; height; width; class RegularPolygon { numPoints; radius;
27
Association Relationships
Directional Associations * -> 0..1, * -> 1, * -> *, * -> m..n, * - >n, *->m..* and*->0..n. Symmetric Reflexive 0..1, 0..n, *, 1, n, m..n,m..*
28
Code Generation Patterns
Attributes Set/Get (UB = 1) Add/Remove/NumberOf/IndexOf/Get (UB > 1) Lazy immutability Default values Constants Before / After cod Associations Set/Get (UB = 1) Add/Remove/NumberOf/IndexOf/Get (UB > 1) Referential Integrity Multiplicity Constraints 42 different cases UB = upper bound UB = upper bound
29
Code Generation (Sematics)
30
Umple Examples... https://github.com/umple/umple/wiki/examples
31
Umple Example Database
32
More example databases?
Contact us through github.com/umple
33
Umple Plugin For Sublime 3
To Install cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/User git clone ./umple
34
Command Line Compiler Demo
35
Build Scripts https://github.com/umple/Umple/wiki/CheatSheet
Ant based scripts One master build.xml, with several project specific build.<proj>.xml Chains commands together instead of dependency heirarchies
36
Docker Container (experimental)
mkdir ~/src && cd ~/src && git clone docker run -i -t -v `pwd`:/src umple/umple:0.4.0 bash
37
Umple Architecture We migrated from Antlr to better handle embedded code blocks and gain flexibility, we have tried Xtext and Xtend, but kept with the internal design as the others did not support our needs of supporting several output languages. The colours represent key subsystems, and click on the classes to see Javadoc and then UmpleCode
38
Umple written in Umple http://code.umple.org
Umple is written in itself. We use much of the available modelling constructs, and compile down to Java for the action semantics. The meta-model, is live, and represent exactly the design. Please note the original versions were written in
39
Original (Pre-Umple) Meta-Model
Umple was not available, so issues arose between the developer transcribing the model and the model itself Before Umple was available, we used a modeling tool to help design the first version. Unfortunately the transcription into Java introduced discrepancies and if you look closely at the current meta model, there are actually undesirable additional classes.
40
State Machines (native Umple) Original Design
State machines were written designed purely in Umple. Here is the original design from Note that this was generated directly from Umple and represents 100% accurately the model that was implemented.
41
State Machines Current Design
Here is a slice of the State Machine design from the current source (also available from metamodels.umple.org). I have trimmed out the mixins, but overall following 5+ years of development, the purety of the design has remained relatively intact despite many additional features such as Model Tracing, Model Trails, Concurrency and Deep History on state machines.
42
Umple Data Flow Each hand-off is tested individually, as well as within each individual output
43
TDD Philosophy
44
Continuous Integration and Deployment
45
Benefits of Umple Used in production systems
Umple developed in itself (60+ developers) Empirical Studies Umple code is easier to understand than Java Helps students learn to model: CSEE&T
46
Production Examples (PHP)
Model your PHP applications Moddel layer written in Umple (app/mode) and generates php (app/classes) Integration with existing PHP frameworks like Zend, Slim, CodeIgniter Integration with testing frameworks Works for websites, web applications and restful APIs java -jar ./vendor/umple/umple.jar \ --generate Php \ --path ../classes \ ./app/models/app.ump
47
Additional Features http://manual.umple.org Generation Templates
Concurrency Constraints Patterns Aspect Orientation Tracing Generation Templates Concurrency Constraints Patterns Aspect Orientation Tracing
48
Umple Architecture 1 Grammar DSL: Online http://grammar.umple.org
(we migrated from Antlr to better handle embedded code blocks and gain flexibility) Umple is written in itself Key to testing and reliability Github file umple.ump Umple Tutorial M. Garzon and A. Forward
49
Umple Architecture 2 Umple’s own class diagram generated by itself from itself: Colours represent key subsystems Click on classes to see Javadoc, and then Umple Code Umple Tutorial M. Garzon and A. Forward
50
Testing: TDD with100% pass always required
Multiple levels: Parsing tests: basic constructs Metamodel tests: ensure it is populated properly E.g. Implementation template tests: to ensure constructs generate code that looks as expected Testbed semantic tests: Generate code and make sure it behaves the way it should Umple Tutorial M. Garzon and A. Forward
51
Continuous integration
Small increments compiled frequently Single trunk, no branches for now Online QA report: Umple Tutorial M. Garzon and A. Forward
52
Evidence of benefit Umple in use an a couple of small companies
Umple development in itself 60+ developers Empirical studies show Umple code is easier to understand than Java Helps students learn to model: CSEE&T Umple Tutorial M. Garzon and A. Forward
53
Results of survey Umple in the lab helped me understand concepts
Prof. Lethbridge should use it in future courses I will get better grades because of Umple Other tools would have been just as effective I would use Umple in the future, assuming bugs fixed helped me understand concepts Umple in the classroom As of Dec 2010, Umple is too incomplete or buggy Umple Tutorial M. Garzon and A. Forward
54
Ability to generate code to represent the model
Availability of a textual form for models and diagrams Ability to edit diagram or text & have the other reflect changes Umple Tutorial M. Garzon and A. Forward
55
Comparison of Grades Comparison of 4 offerings of the same course before introducing Umple, and 2 offerings afterwards Midterm examination grades on UML modeling question rose from 75.8% to 82.3% 8.6% improvement Final exam grades on UML modeling questions rose from 76.4% to 83.6% 9.4% improvement Highly statistically significant p< on T Test n=332 prior to Umple; n=137 afterwards Similar results in 4th year course SEG4110 No difference in non-UML questions Umple Tutorial M. Garzon and A. Forward
56
Development effort Umple Tutorial M. Garzon and A. Forward
57
Additional Umple features in the manual:
Generation Templates Concurrency Constraints Patterns Aspect Orientation Tracing Umple Tutorial M. Garzon and A. Forward
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.