1 / 57

Models 2015 M. Garzón, A. Forward, and T. Lethbridge

Learn how to use Umple, an open source code generator for UML, that allows for textual modeling and seamless integration with other programming languages. Explore code generation, modeling tools, and the umplification process.

mijares
Download Presentation

Models 2015 M. Garzón, A. Forward, and T. Lethbridge

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Textual Modeling and Model-Oriented Programming using Umple • Tutorial Slides • www.umple.org 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

  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, PhPand other languages Umple Tutorial

  4. Exercise: Compiling and Changing a Model • Go to http://helloworld.umple.org • 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

  5. Hello World Example in the User Manual Umple Tutorial

  6. Hello World Example in UmpleOnline Umple Tutorial

  7. State machine example in UmpleOnline Umple Tutorial

  8. State machine detail in the user manual • http://statemachines.umple.org Umple Tutorial

  9. Demo of the command line Umple compiler • Follows conventions of gcc • Used by ant scripts for building Umple Tutorial

  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

  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

  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

  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

  14. Umplification Process Umple Tutorial

  15. Umplificator Architecture Umple Tutorial

  16. Systems umplified • JhotDraw 7.5.1 Umple Tutorial

  17. Systems umplified • JhotDraw 7.5.1 Umple Tutorial

  18. Systems umplified • Weka – Associations umplified • Args4J- Modernization • OriginalArgs4j 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

  19. Attributes in Umple • More than just variables • http://attributes.umple.org Umple Tutorial

  20. Attributes http://attributes.umple.org

  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

  24. Associations http://associations.umple.org/

  25. Associations Exercise #1

  26. Associations Exercise #2

  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

  29. Code Generation (Sematics) http://api.umple.org

  30. Umple Examples... http://try.umple.org https://github.com/umple/umple/wiki/examples

  31. Umple Example Database http://try.umple.org http://umpr.a4word.com/

  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 https://github.com/umple-ucsop/umple.sublime.git ./umple

  34. Command Line Compiler Demo

  35. Build Scripts Ant based scripts One master build.xml, with several project specific build.<proj>.xml Chains commands together instead of dependency heirarchies https://github.com/umple/Umple/wiki/CheatSheet

  36. Docker Container (experimental) https://hub.docker.com/u/umple/dashboard/ mkdir ~/src && cd ~/src && git clone git@github.com:umple/umple.git docker run -i -t -v `pwd`:/src umple/umple:0.4.0 bash

  37. Umple Architecture http://metamodel.umple.org http://grammar.umple.org/

  38. Umple written in Umple http://code.umple.org http://metamodel.umple.org

  39. Original (Pre-Umple) Meta-Model Umple was not available, so issues arose between the developer transcribing the model and the model itself

  40. State Machines (native Umple) Original Design

  41. State Machines Current Design

  42. Umple Data Flow Each hand-off is tested individually, as well as within each individual output

  43. TDD Philosophy http://cc.umple.org

  44. Continuous Integration and Deployment http://qa.umple.org http://cc.umple.org

  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 Generation Templates Concurrency Constraints Patterns Aspect Orientation Tracing http://manual.umple.org

  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

  49. Umple Architecture 2 • Umple’s own class diagram generated by itself from itself: • http://metamodel.umple.org • Colours represent key subsystems • Click on classes to see Javadoc, and then Umple Code Umple Tutorial

  50. Testing:TDD with100% pass always required • Multiple levels: • Parsing tests: basic constructs • Metamodel tests: ensure it is populated properly • E.g. http://code.google.com/p/umple/source/browse/trunk/cruise.umple/test/cruise/umple/compiler/AssociationTest.java • 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

More Related