Download presentation
Presentation is loading. Please wait.
Published byEzra Spencer Modified over 8 years ago
1
Improving Code Generation for Associations: Enforcing Multiplicity Constraints and Ensuring Referential Integrity SERA 2013SERA 2013 (August 7, 2013 in Prague, Czech Republic) Omar Badreddin, Andrew Forward, Timothy C. Lethbridge1 University of Ottawa obadr024@uottawa.caobadr024@uottawa.ca / oobahy@gmail.comoobahy@gmail.com aforward@site.uottawa.caaforward@site.uottawa.ca / aforward@gmail.comaforward@gmail.com tcl@site.uottawa.ca http://umple.org Improving Code Generation for Associations 1
2
Overview Umple Philosophy (Quick Review) Umple Association Syntax Umple in Academia and Industry Getting Involved Future Work 2 Improving Code Generation for Associations
3
Umple Philosophy 3 Umple features can be created and viewed diagrammatically or textually Umple extends a base language in a minimally invasive way Intermediate generated code should not be edited = Modeling is programming and vice versa No round-trip engineering required Improving Code Generation for Associations
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 4 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 5 Improving Code Generation for Associations Optional One / One Many / Star
6
Umple Association Syntax // Embed within the class class X { 0..1 -- * Y yonks; } class Y {} // Or Define explicitly class Z {} association m { * Z -> * Y; } 6 Improving Code Generation for Associations Supports all multiplicities, e.g. 1, m..n, 1..* To name an association (also optional) simply declare it explicitly as shown here. Optionally name the association end for clearer intention as well as to support multiple associations between two classes. 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 7 Improving Code Generation for Associations
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) 8 Improving Code Generation for Associations
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 9 Exploring a Model-Oriented and Executable Syntax for UML Attributes
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 10 Improving Code Generation for Associations
11
Multiplicity Rankings in Industrial Models 11 Improving Code Generation for Associations One To Many Most Used In All Sources Very few non one or many ends
12
Multiplicity Rankings in Example / Textbook Models 12 Improving Code Generation for Associations
13
Multiplicity Rankings in UML Repositories 13 Improving Code Generation for Associations UML Repository viewable at http://try.umple.orghttp://try.umple.org
14
Code Generation for Associations in Existing Tools 14 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 15 Improving Code Generation for Associations Bi-Directional Associations (between different classes) 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) A total 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
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 16 Improving Code Generation for Associations class X { 0..1 -- * Y; } class Y {}
17
One Association-End 17 Improving Code Generation for Associations
18
Many Association-End 18 Improving Code Generation for Associations
19
Try For Yourself 19 Improving Code Generation for Associations http://try.umple.org
20
Academic Use Of Umple 20 Improving Code Generation for Associations
21
Umple (metamodel.umple.org) 21 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 SCORE UCOSP (Undergraduate Capstone Open Source Project) UCOSP 22 Improving Code Generation for Associations
23
Industry Examples 23 Improving Code Generation for Associations
24
hatchmortgage.com 24 Improving Code Generation for Associations
25
alms.arrowmight.ca 25 Improving Code Generation for Associations
26
arm.arrowmight.ca 26 Improving Code Generation for Associations
27
http://cruise.eecs.uottawa.ca/umpleonline/iframeex ample.html Embed Models In HTML 27 Improving Code Generation for Associations
28
28 My Example No iframe support No iframe support 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 29 Improving Code Generation for Associations
30
Getting Involved Open source project: https://code.google.com/p/umple/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.catcl@site.uottawa.ca 30 Improving Code Generation for Associations
31
More information Publications on Umple: https://code.google.com/p/umple/wiki/Publications https://code.google.com/p/umple/wiki/Publications The User Manual: http://cruise.eecs.uottawa.ca/umple/GettingStarted.html http://cruise.eecs.uottawa.ca/umple/GettingStarted.html Umple Home page: http://cruise.eecs.uottawa.ca/umple/http://cruise.eecs.uottawa.ca/umple/ Download Umple: http://cruise.eecs.uottawa.ca/umpleonline/download_eclipse_umpl e_plugin.html http://cruise.eecs.uottawa.ca/umpleonline/download_eclipse_umpl e_plugin.html Report an issue: https://code.google.com/p/umple/issues/entryhttps://code.google.com/p/umple/issues/entry 31 Improving Code Generation for Associations
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 32 Improving Code Generation for Associations
33
33 Improving Code Generation for Associations
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.