1 / 33

SERA 2013 (August 7, 2013 in Prague, Czech Republic)

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.

skyler
Download Presentation

SERA 2013 (August 7, 2013 in Prague, Czech Republic)

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 Improving Code Generation for Associations: Enforcing Multiplicity Constraints and Ensuring Referential Integrity

  2. Overview Umple Philosophy (Quick Review) Umple Association Syntax Umplein Academia and Industry Getting Involved Future Work

  3. Umple Philosophy Improving Code Generation for Associations 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

  4. Defining Association • Specification describing the links between objects that can exist at run time • Each end of the association has a multiplicity • Specifies upper and lower bound on the number of links Improving Code Generation for Associations class X { 0..1 -- * Y; } class Y {} X can have many Y’s, and Y can optionally have one X.

  5. Available Multiplicities Optional One / One Many / Star Improving Code Generation for Associations

  6. Umple Association Syntax // Embed within the class class X { 0..1 -- *Y yonks; } class Y {} // Or Define explicitly class Z {} associationm { * Z -> * Y; } Supports all multiplicities, e.g. 1, m..n, 1..* Optionally name the association end for clearer intention as well as to support multiple associations between two classes. To name an association (also optional) simply declare it explicitly as shown here. Directed associations

  7. Referential Integrity Either side of the relationship can be set, and the other will automatically be maintained, so x.addY(y) equivalent to y.setX(x) If either side removes a relationship, then the other side will automatically be removed as well, so y.setX(x1); // x1 associated with y y.setX(x2); // x1 unassociated with y

  8. Multiplicity Constraint Set / Add / Remove might fail (returns a false) if the multiplicity is not supported Multiplicities also affect relationship (e.g. setting Y to a new X, removes the old relationship because of the 0..1 multiplicity)

  9. Associations In Practice Too difficult to identify associations with any degree of certainty by looking only at the source code Difficulty with which we had trying to identify the use of association in code served as a motivation in itself

  10. Analyzed Models Instead • 1400 Industry examples by looking at UML specs and UML profiles • UML v1.5 • UML v2.1.2 • MARTE, Flow Composition, ECA, Java, Patterns, rCOS • 98 Example models from a course textbook of one of the authors • 250 Repository models from the collection of models codified in Umple

  11. Multiplicity Rankings inIndustrial Models Improving Code Generation for Associations One To Many Most Used In All Sources Very few non one or many ends

  12. Multiplicity Rankings inExample / Textbook Models Improving Code Generation for Associations

  13. Multiplicity Rankings inUML Repositories Improving Code Generation for Associations UML Repository viewable at http://try.umple.org

  14. Code Generation for Associations in Existing Tools Improving Code Generation for Associations • All similar implementations, member variables for One multiplicities and List variables for Many • Little to no referential integrity • Little to no multiplicity constraints

  15. Association Combinations Bi-Directional Associations (between different classes) • Atotal of 42 different possible association types have been identified • 28 for bidirectional associations • 7 for unidirectional associations • 7 for symmetric associations • Each case explicitly handled, with code re-use where possible Improving Code Generation for Associations • Directed Associations * -> 0..1; -> 1; -> *; -> m..n; -> n; -> m..*; -> 0..n Symmetric Associations (between the same class) • Reads the same in both directions (e.g. spouse)

  16. Association Code Generation • Member variables for One • List variables for Many • Referential Integrity maintained • E.g. a student switches mentors • Multiplicity Constraints enforced • E.g. cannot overload a mentor class X { 0..1 -- * Y; } class Y {}

  17. One Association-End

  18. Many Association-End

  19. Try For Yourself http://try.umple.org

  20. Improving Code Generation for Associations Academic Use Of Umple

  21. Umple(metamodel.umple.org) Improving Code Generation for Associations

  22. Teaching Umple • University of Ottawa, Canada • Second year Introduction to Software Engineering • Fourth year Advanced Design • Other professors, including at graduate level • SCORE finalists at ICSE 2011 • UCOSP (Undergraduate Capstone Open Source Project) Improving Code Generation for Associations

  23. Improving Code Generation for Associations Industry Examples

  24. hatchmortgage.com Improving Code Generation for Associations

  25. alms.arrowmight.ca Improving Code Generation for Associations

  26. arm.arrowmight.ca Improving Code Generation for Associations

  27. Improving Code Generation for Associations Embed Models In HTML http://cruise.eecs.uottawa.ca/umpleonline/iframeexample.html

  28. <html> <head><title>My Example</title></head> <body> <p> <iframe height=550 width=100% frameborder="0" scrolling="auto" src="http://try.umple.org/umple.php?example=2DShapes&readOnly&notext&nomenu&nochrome"><p>No iframe support</p></iframe> </p> <p> <iframe height=550 width=100% frameborder="0" scrolling="auto" src="http://try.umple.org/umple.php?example=2DShapes&readOnly&nodiagram&nomenu&nochrome"><p>No iframe support</p></iframe> </p> </body> </html> Improving Code Generation for Associations

  29. Current and Future Work • Umplification • Starting with OO code, incrementally add modeling abstractions • Maintain system functionality throughout the process • Using existing code repositories • Reduce code size • Model Based Tracing • Define tracing directive at the model level • Aspect Orientation • Additional Refactoring on Umple itself Improving Code Generation for Associations

  30. 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 • Rapid system prototyping Comments and feedback: tcl@site.uottawa.ca Improving Code Generation for Associations

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

  32. Summary • 42 unique ways to define an association between one or two • In practice, mostly One or Many, but mostly does not mean always • Implemented referential integrity and multiplicity constraints for each unique combination • Test-Driven approach to reduce regressions • Important as new features are added to the languagethe help reduce code clones • Many additional features available in Umple including tracing, state machines, code injections, mixin • More coming including better support for aspect orientation

More Related