1 / 30

Exploring a Model-Oriented and Executable Syntax for UML Attributes

This paper discusses the philosophy of Model-Oriented Programming and explores Umple, a MOP technology and language family that supports modeling abstractions and integrates with various programming languages and tools.

ttipler
Download Presentation

Exploring a Model-Oriented and Executable Syntax for UML Attributes

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. SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew Forward, Timothy C. Lethbridge1 University of Ottawa obadr024@uottawa.ca / oobahy@gmail.com aforward@site.uottawa.ca / aforward@gmail.com tcl@site.uottawa.ca http://umple.org Exploring a Model-Oriented and Executable Syntax for UML Attributes

  2. Overview • Model Oriented Programming • Umple Overview • Attributes in Practice • Umple Attribute Syntax • Attribute Code Generation

  3. MOP The philosophy of Model-Oriented Programming (MOP)

  4. Embed Models In Code

  5. Unify programs and models

  6. Supports Modellerand Programmer workflows Model-First Incremental Re-Engineering

  7. Text Diagram Duality

  8. Reduce Need to Round-Trip

  9. Easily Integrate with Text-Based Tooling

  10. Umple A MOP technology and language family

  11. Why call it Umple? UML Programming Language Ample Simple

  12. 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

  13. Attributes In Practice Google Code: • fizzbuzz • ExcelLibrary • Ndependencyinjection • Java Bug Reporting SourceForge: • jEdit • Freemaker Freecode: • Java Financial Library • 1831 variables • 620 static • 1211 instance • 469 classes

  14. Variable Distribution Static (Class) Variables E.g. avoiding magic numbers and state symbols (i.e. LEFT_NODE, RIGHT_NODE) Member (Object) Variables Mostly counts, names and booleans(51%) A lot of other object types

  15. Attribute Identification About 33% had attribute-like methods implementations Surprising that 35% had no external access at all

  16. Attribute Code Generation Over half were simple boiler-plate implementations

  17. Observations • Many simple set and get methods • Drastic reduction in boiler-plate code • Few trulyimmutable 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

  18. Umple Attributes class Student { // defaults to String studentNumber; String grade; IntegerentryAverage; }

  19. Umple Data Types Umple treats the following attribute types as special String (always the default if unspecified) Integer Double Boolean Date, 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

  20. Initializing Attributes class 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; }

  21. Immutable Attributes class Student { // Cannot be changed after set in constructor immutableidNumber; // 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; }

  22. Derived Attributes class Rectangle { Integer l; Integer w; // Derived Attributes Integer perimeter = { 2*getL() + 2*getW() } Integer area = { getL() * getW() } }

  23. Additional Attribute Options class Student { // Umple assigns the next // available number autouniqueid; // Creates a constant value constInteger MAX_NUM_COURSES = 8; } class Address { // An address has many lines String[] lines; }

  24. Attribute Code Generation (1) class Rectangle { name = "Rectangle"; Integerlength; Integerwidth; Integerarea = {getLenth() * getWidth()} }

  25. 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(intaLength, intaWidth) { name = "Rectangle"; length = aLength; width = aWidth; } //------------------------ // INTERFACE //------------------------ public booleansetName(String aName) { booleanwasSet = false; name = aName; wasSet = true; return wasSet; } public booleansetLength(intaLength) { booleanwasSet = false; length = aLength; wasSet = true; return wasSet; } public booleansetWidth(intaWidth) { booleanwasSet = false; width = aWidth; wasSet = true; return wasSet; } public String getName() { return name; } public intgetLength() { return length; } public intgetWidth() { return width; } @umplesourcefile(line={7},file={"model.ump"},javaline={79},length={2}) public intgetArea() { return getLenth() * getWidth(); } public void delete() {} public String toString() { String outputString = ""; return super.toString() + "["+ "name" + ":" + getName()+ "," + "length" + ":" + getLength()+ "," + "width" + ":" + getWidth()+ "," + "area" + ":" + getArea()+ "]" + outputString; } } Simple get method Constructor based on attributes missing an initial value Set method returns a boolean (was it “set” or not) Derived methods do not have internal members

  26. Try It Yourself http://try.umple.org

  27. Summary Umple extends a base language in a minimally invasive way Umple features can be created and viewed diagrammatically or textually = Modeling is programming and vice versa Intermediate generated code should not be edited No round-trip engineering required

  28. 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: tcl@site.uottawa.ca

  29. 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

More Related