SlideShare a Scribd company logo
2009. 10. 9                       TOKYO INSTITUTE OF TECHNOLOGY
                                   DEPARTMENT OF COMPUTER SCIENCE
MODELS 2009


      Generating Assertion
        Code from OCL:
  A Transformational Approach Based on
 Similarities of Implementation Languages

 Rodion Moiseev Shinpei Hayashi Motoshi Saeki

               Department of Computer Science
                Tokyo Institute of Technology
                            Japan
Abstract
   Generation Assertion Code from OCL
    − Transformational Approach:
      Regarding OCL-to-code as model transformation
    − Similarities of Implementation Languages:
      Constructing a language hierarchy for effective
      developing of transformation rules
   Results
    − A translation framework has been developed
    − Showed ~50% of effort to construct translation
      rules saved
                                                        2
Background
 Model-centric approaches are becoming
  important in academia and industry
 OCL is often the language of choice for
  stipulating constraints on models
 Successful application depends on
  mature tool support:
    − Support for multiple programming languages
    − Customizable assertion code/test case
      generation
                                                   3
Motivating Example
   Application design: UML with OCL

           <<interface>>       OCL
        MyApplication


    doQuery(q : Query) : Integer


                                     context MyApplication::doQuery(
                                               q: Query): Integer
                                       pre: not q = null
                                       post: result >= 0

                                                                       4
Motivating Example
   A need to check OCL for multiple languages

         MyApplication                               Client 1
                 Perl                                   Java

    Server

             <<interface>>                           Client 2
         MyApplication
                                                      Haskell

     doQuery(q : Query) : Integer
                                    context MyApplication::doQuery(
                                              q: Query): Integer
                                      pre: not q = null
                                      post: result >= 0
                                                                      5
Pinpointing the Problem
   Interface
  (UML+OCL)
                 Generate         <<write code>>
                 Skeleton
           OCL

                        Code
                                       Code
     OCL
                       Skeleton


                                    Assertion
                                      Code
                   Generate
                 assertion code
                                                   6
Problems
   Troublesome to make individual OCL
    translators
    − Many languages exist
      • Most of existing tools are tailor-made for a
        specific language
    − Creating a translator requires efforts
      • Specifying OCL translation rules for each
        individual OCL concept, operator, etc.

   Our solution:
    Usage of language similarities
                                                       7
Language Similarities
 E.g.,    for-loop iterating over a collection
                For Each apple In apples Do:
                  If apple.color == “red” Then
                     …
                Next                           Imperative
                                            Pseudo-language

 for (Iterator it = apples.iterator(); it.hasNext(); ) {
   Apple apple = (Apple) it.next();
   if (apple.color == “red”) {          for apple in apples:
       …                                   if apple.color == “red”:
                           Java             …
                                                             Python
                                                                      8
The Approach
   Hierarchy of programming languages
    based on their structural similarities
                                   OCL


            Imperative             Functional                          DbC


Java, C# like            Python   Lisp          Haskell                JML

                           Step-by-step                   <<described in terms of>>
    Java        C#          Translation                   Pseudo-languages
                                                          Concrete languages
MultiJava
                                                                            High
                                                                    concreteness      9
Advantages
   Provide a single framework for creating
    OCL translators for any language
     − Reuse translator implementations
   Bridges semantic gap
     − Effort of understanding OCL is alleviated
     − Manual effort of creating OCL translators is
       reduced
                     OCL                      OCL

    Semantic gap                            Imperative

                    Python                   Python
                                                         10
Generation Process
                                                                               Environment
                                                                              containing type
                                                                                information

  Parser + type checker                             OCL AST             ENV

                             AST→Imperative DL        AST         ENV
             OCL

       OCL                                        Imperative DL

      Input                 Imper. DL→Python DL     Imper. DL     ENV
    UML + OCL
                        rewriting rules            Python DL              Python Code
                         Python DL→Python Code Python DL          ENV


                       printing rules
                                                         DL = Definition Language
                   (Structural representation of pseudo/implementation languages) 11
Comparison with MDE
                         DL Definition and                   MDE Terms
                         Rewriting System
                          Metalanguage


                         Rewriting Language
         written in   Transformation Language   written in

                               written in

 Imperative DL           Imper. DL→Python DL          Python DL
     PIM                   Transformation              PSM
                               Rules

                          Rewriting engine

                                                                         12
Transformation Example
 All employees in the company earn more than 10,000
 employees->forAll( e : Employee | e.salary > 10000)
 OCL AST:
 iteratorExp
   (assocEndCallExp simpleName("self") . simpleName("employees"))
   -> simpleName("forAll") ( varDecl(simpleName("e"), pathName("Employee")) |
       operCallExp(
           attrCallExp simpleName("e") . simpleName("salary"),
           simpleName(">"),
           intLitExp("10000")
                                     Company 1 .. * employees           Employee
       )
                                                                        salary : Int
   )

                                                                                   13
Rewriting Rules
iteratorExp OE -> simpleName(“forAll”) `( varDecl(SN, TYPE) | OE’’ `)


         impMethodExtract(
         {
               impForLoop( OE, impVarDecl(TYPE, SN),
               {
                    impIf( impNot(OE''),
                                                           OCL AST→Imperative DL
                    {
                         impReturn( boolLitFalse )
                    })
               })
               ; impReturn( boolLitTrue )
         }, pathName("Boolean")) .


                                                                                   14
Imperative DL
impMethodExtract(
  {emptyCtx |
     impForLoop(
         assocEndCallExp simpleName("self"). simpleName("employees"),
          impVarDecl(pathName("Employee"),simpleName("e")),
      { "ctx:iter" = simpleName("it_e") |
            impIf( impNot(operCallExp(
               attrCallExp simpleName("e"). simpleName("salary"),
               simpleName(">"),
               intLitExp(“10000"))),
            {emptyCtx |
               impReturn(boolLitFalse)
            })
       })
   };
   {emptyCtx |
       impReturn(boolLitTrue)
   },pathName("Boolean"))
                                                                        15
Generation Result
class Employee:                          From UML
     def __init__(self, name, salary):
      self.name = name
      self.salary = salary

class Company:
     def __init__(self, employees):
      self.employees = employees

    def callExtMethod_A(self):           From OCL
     for e in self.employees:
         if (not (e.salary > 10000)):
             return False
         return True
    def inv(self):
     return self.callExtMethod_A()
                                                    16
Approach Evaluation
   Implemented a tool in the Maude System (*)
   To show the ability to implement several OCL
    translators with significant effort savings
   Target languages
     − Imperative
         • Java
                                                      OCL      Predefined
         • Python
                                         Imperative         Functional
     − Functional
         • Haskell
                                  Java           Python      Haskell
         • O’Haskell
                                                            O’Haskell

    * http://maude.cs.uiuc.edu/
                                                                            17
Approach Evaluation
   Compare effort in our approach vs.
    direct approach:
    − # rewriting rules + # structures + # printing rules
                                                         OCL AST
                     OCL AST
                                                      Imperative DL
                                     Imper. DL→Java DL
                          Compare
     OCL AST →Java                                       Java DL
                                       Java DL→Java


       Java Code                        Java Code
     Direct Approach                Proposed Approach                 18
Evaluation Results
   Imperative languages                                      rewriting rules
                                                              structures
                                                              printing rules

                      Java                         Python
               85              58%                       99         40%
                              effort                               effort
                                                              59
                              saved                                saved
    Effort




                                       Effort
                         36




             Direct     Our                     Direct     Our
                      approach                           approach

                                                                                19
Evaluation Results
   Functional languages                                   rewriting rules
                                                           structures
                                                           printing rules

                    Haskell                       O’Haskell

                               32%                               99%
               76                                76
                              effort                            effort
                        52    saved                             saved
    Effort




                                       Effort

                                                            1

             Direct     Our                     Direct     Our
                      approach                           approach

                                                                             20
Evaluation Results
                    Direct     Proposed
                   Approach    Approach
     Java             85          36
    Python            99          59
    Haskell           76          52
   O’Haskell          76          1
     Total           316         148
  ~50% effort could be saved on average
                                          21
Conclusion
   Proposed a novel technique to generate
    assertion code from OCL constraints
   Used structural similarities of programming
    languages to enable reusing in OCL
    translators for multiple languages
    − Saving manual effort
   Run an experiment to show the claimed effort
    savings by using our approach



                                                  22
Future Work
   Uncovered functionalities of OCL
    − History expressions (@pre)
    − OCL messages
    − allInstances, etc.
   Hierarchy Limitations
    − Difficult to extend hierarchy from the middle
    − Does not allow multiple parent nodes
      (e.g. useful for implementing an
      imperative/functional hybrid)
   Real case study
                                                      23

More Related Content

What's hot

Detecting aspect-specific code smells using Ekeko for AspectJ
Detecting aspect-specific code smells using Ekeko for AspectJDetecting aspect-specific code smells using Ekeko for AspectJ
Detecting aspect-specific code smells using Ekeko for AspectJ
Coen De Roover
 
Boost.Dispatch
Boost.DispatchBoost.Dispatch
Boost.Dispatch
Joel Falcou
 
The Rise of Dynamic Languages
The Rise of Dynamic LanguagesThe Rise of Dynamic Languages
The Rise of Dynamic Languages
greenwop
 
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Coen De Roover
 
HDR Defence - Software Abstractions for Parallel Architectures
HDR Defence - Software Abstractions for Parallel ArchitecturesHDR Defence - Software Abstractions for Parallel Architectures
HDR Defence - Software Abstractions for Parallel Architectures
Joel Falcou
 
(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures
Joel Falcou
 
Guiding Identification of Missing Scenarios for Dynamic Feature Location
Guiding Identification of Missing Scenarios for Dynamic Feature LocationGuiding Identification of Missing Scenarios for Dynamic Feature Location
Guiding Identification of Missing Scenarios for Dynamic Feature Location
Shinpei Hayashi
 
Designing Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.ProtoDesigning Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.Proto
Joel Falcou
 
Toward Understanding How Developers Recognize Features in Source Code from De...
Toward Understanding How Developers Recognize Features in Source Code from De...Toward Understanding How Developers Recognize Features in Source Code from De...
Toward Understanding How Developers Recognize Features in Source Code from De...
Shinpei Hayashi
 
Refactoring Edit History of Source Code
Refactoring Edit History of Source CodeRefactoring Edit History of Source Code
Refactoring Edit History of Source Code
Shinpei Hayashi
 
Visualizing Stakeholder Concerns with Anchored Map
Visualizing Stakeholder Concerns with Anchored MapVisualizing Stakeholder Concerns with Anchored Map
Visualizing Stakeholder Concerns with Anchored Map
Takanori Ugai
 
SRAVANByCPP
SRAVANByCPPSRAVANByCPP
SRAVANByCPP
aptechsravan
 
GCC RTL and Machine Description
GCC RTL and Machine DescriptionGCC RTL and Machine Description
GCC RTL and Machine Description
Priyatham Bollimpalli
 
14.jun.2012
14.jun.201214.jun.2012
14.jun.2012Tech_MX
 
Introduction to new features in java 8
Introduction to new features in java 8Introduction to new features in java 8
Introduction to new features in java 8
Raffi Khatchadourian
 
2013 bookmatter learn_javaforandroiddevelopment
2013 bookmatter learn_javaforandroiddevelopment2013 bookmatter learn_javaforandroiddevelopment
2013 bookmatter learn_javaforandroiddevelopment
CarlosPineda729332
 

What's hot (19)

Detecting aspect-specific code smells using Ekeko for AspectJ
Detecting aspect-specific code smells using Ekeko for AspectJDetecting aspect-specific code smells using Ekeko for AspectJ
Detecting aspect-specific code smells using Ekeko for AspectJ
 
Boost.Dispatch
Boost.DispatchBoost.Dispatch
Boost.Dispatch
 
The Rise of Dynamic Languages
The Rise of Dynamic LanguagesThe Rise of Dynamic Languages
The Rise of Dynamic Languages
 
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
Multi-dimensional exploration of API usage - ICPC13 - 21-05-13
 
HDR Defence - Software Abstractions for Parallel Architectures
HDR Defence - Software Abstractions for Parallel ArchitecturesHDR Defence - Software Abstractions for Parallel Architectures
HDR Defence - Software Abstractions for Parallel Architectures
 
(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures
 
Guiding Identification of Missing Scenarios for Dynamic Feature Location
Guiding Identification of Missing Scenarios for Dynamic Feature LocationGuiding Identification of Missing Scenarios for Dynamic Feature Location
Guiding Identification of Missing Scenarios for Dynamic Feature Location
 
Designing Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.ProtoDesigning Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.Proto
 
Extending and scripting PDT
Extending and scripting PDTExtending and scripting PDT
Extending and scripting PDT
 
Toward Understanding How Developers Recognize Features in Source Code from De...
Toward Understanding How Developers Recognize Features in Source Code from De...Toward Understanding How Developers Recognize Features in Source Code from De...
Toward Understanding How Developers Recognize Features in Source Code from De...
 
Refactoring Edit History of Source Code
Refactoring Edit History of Source CodeRefactoring Edit History of Source Code
Refactoring Edit History of Source Code
 
Visualizing Stakeholder Concerns with Anchored Map
Visualizing Stakeholder Concerns with Anchored MapVisualizing Stakeholder Concerns with Anchored Map
Visualizing Stakeholder Concerns with Anchored Map
 
SRAVANByCPP
SRAVANByCPPSRAVANByCPP
SRAVANByCPP
 
GCC RTL and Machine Description
GCC RTL and Machine DescriptionGCC RTL and Machine Description
GCC RTL and Machine Description
 
Syntutic
SyntuticSyntutic
Syntutic
 
14.jun.2012
14.jun.201214.jun.2012
14.jun.2012
 
Introduction to new features in java 8
Introduction to new features in java 8Introduction to new features in java 8
Introduction to new features in java 8
 
2013 bookmatter learn_javaforandroiddevelopment
2013 bookmatter learn_javaforandroiddevelopment2013 bookmatter learn_javaforandroiddevelopment
2013 bookmatter learn_javaforandroiddevelopment
 
ICPC08b.ppt
ICPC08b.pptICPC08b.ppt
ICPC08b.ppt
 

Viewers also liked

Understanding Source Code Differences by Separating Refactoring Effects
Understanding Source Code Differences by Separating Refactoring EffectsUnderstanding Source Code Differences by Separating Refactoring Effects
Understanding Source Code Differences by Separating Refactoring Effects
Shinpei Hayashi
 
Class Responsibility Assignment as Fuzzy Constraint Satisfaction
Class Responsibility Assignment as Fuzzy Constraint SatisfactionClass Responsibility Assignment as Fuzzy Constraint Satisfaction
Class Responsibility Assignment as Fuzzy Constraint Satisfaction
Shinpei Hayashi
 
Modeling and Utilizing Security Knowledge for Eliciting Security Requirements
Modeling and Utilizing Security Knowledge for Eliciting Security RequirementsModeling and Utilizing Security Knowledge for Eliciting Security Requirements
Modeling and Utilizing Security Knowledge for Eliciting Security Requirements
Shinpei Hayashi
 
Feature Location for Multi-Layer System Based on Formal Concept Analysis
Feature Location for Multi-Layer System Based on Formal Concept AnalysisFeature Location for Multi-Layer System Based on Formal Concept Analysis
Feature Location for Multi-Layer System Based on Formal Concept Analysis
Hiroshi Kazato
 
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQMHow Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
Shinpei Hayashi
 
Terminology Matching of Requirements Specification Documents and Regulations ...
Terminology Matching of Requirements Specification Documents and Regulations ...Terminology Matching of Requirements Specification Documents and Regulations ...
Terminology Matching of Requirements Specification Documents and Regulations ...
Shinpei Hayashi
 
Incremental Feature Location and Identification in Source Code
Incremental Feature Location and Identification in Source CodeIncremental Feature Location and Identification in Source Code
Incremental Feature Location and Identification in Source Code
Hiroshi Kazato
 
Historef: A Tool for Edit History Refactoring
Historef: A Tool  for Edit History RefactoringHistoref: A Tool  for Edit History Refactoring
Historef: A Tool for Edit History Refactoring
Shinpei Hayashi
 
Establishing Regulatory Compliance in Goal-Oriented Requirements Analysis
Establishing Regulatory Compliance in Goal-Oriented Requirements AnalysisEstablishing Regulatory Compliance in Goal-Oriented Requirements Analysis
Establishing Regulatory Compliance in Goal-Oriented Requirements Analysis
Shinpei Hayashi
 
Toward Structured Location of Features
Toward Structured Location of FeaturesToward Structured Location of Features
Toward Structured Location of Features
Hiroshi Kazato
 
Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Supporting Design Model Refactoring for Improving Class Responsibility Assign...Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Shinpei Hayashi
 
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
Takashi Kobayashi
 

Viewers also liked (12)

Understanding Source Code Differences by Separating Refactoring Effects
Understanding Source Code Differences by Separating Refactoring EffectsUnderstanding Source Code Differences by Separating Refactoring Effects
Understanding Source Code Differences by Separating Refactoring Effects
 
Class Responsibility Assignment as Fuzzy Constraint Satisfaction
Class Responsibility Assignment as Fuzzy Constraint SatisfactionClass Responsibility Assignment as Fuzzy Constraint Satisfaction
Class Responsibility Assignment as Fuzzy Constraint Satisfaction
 
Modeling and Utilizing Security Knowledge for Eliciting Security Requirements
Modeling and Utilizing Security Knowledge for Eliciting Security RequirementsModeling and Utilizing Security Knowledge for Eliciting Security Requirements
Modeling and Utilizing Security Knowledge for Eliciting Security Requirements
 
Feature Location for Multi-Layer System Based on Formal Concept Analysis
Feature Location for Multi-Layer System Based on Formal Concept AnalysisFeature Location for Multi-Layer System Based on Formal Concept Analysis
Feature Location for Multi-Layer System Based on Formal Concept Analysis
 
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQMHow Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
How Can You Improve Your As-is Models? Requirements Analysis Methods Meet GQM
 
Terminology Matching of Requirements Specification Documents and Regulations ...
Terminology Matching of Requirements Specification Documents and Regulations ...Terminology Matching of Requirements Specification Documents and Regulations ...
Terminology Matching of Requirements Specification Documents and Regulations ...
 
Incremental Feature Location and Identification in Source Code
Incremental Feature Location and Identification in Source CodeIncremental Feature Location and Identification in Source Code
Incremental Feature Location and Identification in Source Code
 
Historef: A Tool for Edit History Refactoring
Historef: A Tool  for Edit History RefactoringHistoref: A Tool  for Edit History Refactoring
Historef: A Tool for Edit History Refactoring
 
Establishing Regulatory Compliance in Goal-Oriented Requirements Analysis
Establishing Regulatory Compliance in Goal-Oriented Requirements AnalysisEstablishing Regulatory Compliance in Goal-Oriented Requirements Analysis
Establishing Regulatory Compliance in Goal-Oriented Requirements Analysis
 
Toward Structured Location of Features
Toward Structured Location of FeaturesToward Structured Location of Features
Toward Structured Location of Features
 
Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Supporting Design Model Refactoring for Improving Class Responsibility Assign...Supporting Design Model Refactoring for Improving Class Responsibility Assign...
Supporting Design Model Refactoring for Improving Class Responsibility Assign...
 
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
FOSE2010 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
 

Similar to Generating Assertion Code from OCL: A Transformational Approach Based on Similarities of Implementation Languages

Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_future
Takayuki Muranushi
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
Skills Matter
 
LINQ/PLINQ
LINQ/PLINQLINQ/PLINQ
LINQ/PLINQ
melbournepatterns
 
IN4308 1
IN4308 1IN4308 1
IN4308 1
Eelco Visser
 
ModRef'09: Gecode support for MCP
ModRef'09: Gecode support for MCPModRef'09: Gecode support for MCP
ModRef'09: Gecode support for MCPpwuille
 
The Forces Driving Java
The Forces Driving JavaThe Forces Driving Java
The Forces Driving Java
Steve Elliott
 
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
Mickael Istria
 
Experiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRubyExperiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRuby
Matthew Gaudet
 
The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論
scalaconfjp
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to Clojure
Renzo Borgatti
 
EcoreTools-Next: Executable DSL made (more) accessible
EcoreTools-Next: Executable DSL made (more) accessibleEcoreTools-Next: Executable DSL made (more) accessible
EcoreTools-Next: Executable DSL made (more) accessible
Cédric Brun
 
OCL Integration and Code Generation
OCL Integration and Code GenerationOCL Integration and Code Generation
OCL Integration and Code Generation
Edward Willink
 
2004 Esug Prototalk
2004 Esug Prototalk2004 Esug Prototalk
2004 Esug Prototalk
bergel
 
Eclipse OCL Summary
Eclipse OCL SummaryEclipse OCL Summary
Eclipse OCL Summary
Edward Willink
 
Introduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKennaIntroduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKenna
openseesdays
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming languageVasavi College of Engg
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3
aminmesbahi
 
Basics-Of-Java
Basics-Of-JavaBasics-Of-Java
Basics-Of-Java
ssuser200038
 
PL Lecture 01 - preliminaries
PL Lecture 01 - preliminariesPL Lecture 01 - preliminaries
PL Lecture 01 - preliminaries
Schwannden Kuo
 

Similar to Generating Assertion Code from OCL: A Transformational Approach Based on Similarities of Implementation Languages (20)

Peyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_futurePeyton jones-2011-parallel haskell-the_future
Peyton jones-2011-parallel haskell-the_future
 
Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
LINQ/PLINQ
LINQ/PLINQLINQ/PLINQ
LINQ/PLINQ
 
IN4308 1
IN4308 1IN4308 1
IN4308 1
 
1 cc
1 cc1 cc
1 cc
 
ModRef'09: Gecode support for MCP
ModRef'09: Gecode support for MCPModRef'09: Gecode support for MCP
ModRef'09: Gecode support for MCP
 
The Forces Driving Java
The Forces Driving JavaThe Forces Driving Java
The Forces Driving Java
 
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
 
Experiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRubyExperiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRuby
 
The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to Clojure
 
EcoreTools-Next: Executable DSL made (more) accessible
EcoreTools-Next: Executable DSL made (more) accessibleEcoreTools-Next: Executable DSL made (more) accessible
EcoreTools-Next: Executable DSL made (more) accessible
 
OCL Integration and Code Generation
OCL Integration and Code GenerationOCL Integration and Code Generation
OCL Integration and Code Generation
 
2004 Esug Prototalk
2004 Esug Prototalk2004 Esug Prototalk
2004 Esug Prototalk
 
Eclipse OCL Summary
Eclipse OCL SummaryEclipse OCL Summary
Eclipse OCL Summary
 
Introduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKennaIntroduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKenna
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3.NET Core, ASP.NET Core Course, Session 3
.NET Core, ASP.NET Core Course, Session 3
 
Basics-Of-Java
Basics-Of-JavaBasics-Of-Java
Basics-Of-Java
 
PL Lecture 01 - preliminaries
PL Lecture 01 - preliminariesPL Lecture 01 - preliminaries
PL Lecture 01 - preliminaries
 

More from Shinpei Hayashi

Revisiting the Effect of Branch Handling Strategies on Change Recommendation
Revisiting the Effect of Branch Handling Strategies on Change RecommendationRevisiting the Effect of Branch Handling Strategies on Change Recommendation
Revisiting the Effect of Branch Handling Strategies on Change Recommendation
Shinpei Hayashi
 
An Extensive Study on Smell Aware Bug Localization
An Extensive Study on Smell Aware Bug LocalizationAn Extensive Study on Smell Aware Bug Localization
An Extensive Study on Smell Aware Bug Localization
Shinpei Hayashi
 
RefactorHub: A Commit Annotator for Refactoring
RefactorHub: A Commit Annotator for RefactoringRefactorHub: A Commit Annotator for Refactoring
RefactorHub: A Commit Annotator for Refactoring
Shinpei Hayashi
 
Can Automated Impact Analysis Technique Help Predicting Decaying Modules?
Can Automated Impact Analysis Technique Help Predicting Decaying Modules?Can Automated Impact Analysis Technique Help Predicting Decaying Modules?
Can Automated Impact Analysis Technique Help Predicting Decaying Modules?
Shinpei Hayashi
 
The Impact of Systematic Edits in History Slicing
The Impact of Systematic Edits in History SlicingThe Impact of Systematic Edits in History Slicing
The Impact of Systematic Edits in History Slicing
Shinpei Hayashi
 
ChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source Code
ChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source CodeChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source Code
ChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source Code
Shinpei Hayashi
 
Inference-Based Detection of Architectural Violations in MVC2
Inference-Based Detection of Architectural Violations in MVC2Inference-Based Detection of Architectural Violations in MVC2
Inference-Based Detection of Architectural Violations in MVC2
Shinpei Hayashi
 
Detecting Bad Smells of Refinement in Goal-Oriented Requirements Analysis
Detecting Bad Smells of Refinement in Goal-Oriented Requirements AnalysisDetecting Bad Smells of Refinement in Goal-Oriented Requirements Analysis
Detecting Bad Smells of Refinement in Goal-Oriented Requirements Analysis
Shinpei Hayashi
 
ソフトウェア工学勉強会への誘い
ソフトウェア工学勉強会への誘いソフトウェア工学勉強会への誘い
ソフトウェア工学勉強会への誘い
Shinpei Hayashi
 

More from Shinpei Hayashi (9)

Revisiting the Effect of Branch Handling Strategies on Change Recommendation
Revisiting the Effect of Branch Handling Strategies on Change RecommendationRevisiting the Effect of Branch Handling Strategies on Change Recommendation
Revisiting the Effect of Branch Handling Strategies on Change Recommendation
 
An Extensive Study on Smell Aware Bug Localization
An Extensive Study on Smell Aware Bug LocalizationAn Extensive Study on Smell Aware Bug Localization
An Extensive Study on Smell Aware Bug Localization
 
RefactorHub: A Commit Annotator for Refactoring
RefactorHub: A Commit Annotator for RefactoringRefactorHub: A Commit Annotator for Refactoring
RefactorHub: A Commit Annotator for Refactoring
 
Can Automated Impact Analysis Technique Help Predicting Decaying Modules?
Can Automated Impact Analysis Technique Help Predicting Decaying Modules?Can Automated Impact Analysis Technique Help Predicting Decaying Modules?
Can Automated Impact Analysis Technique Help Predicting Decaying Modules?
 
The Impact of Systematic Edits in History Slicing
The Impact of Systematic Edits in History SlicingThe Impact of Systematic Edits in History Slicing
The Impact of Systematic Edits in History Slicing
 
ChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source Code
ChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source CodeChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source Code
ChangeMacroRecorder: Recording Fine-Grained Textual Changes of Source Code
 
Inference-Based Detection of Architectural Violations in MVC2
Inference-Based Detection of Architectural Violations in MVC2Inference-Based Detection of Architectural Violations in MVC2
Inference-Based Detection of Architectural Violations in MVC2
 
Detecting Bad Smells of Refinement in Goal-Oriented Requirements Analysis
Detecting Bad Smells of Refinement in Goal-Oriented Requirements AnalysisDetecting Bad Smells of Refinement in Goal-Oriented Requirements Analysis
Detecting Bad Smells of Refinement in Goal-Oriented Requirements Analysis
 
ソフトウェア工学勉強会への誘い
ソフトウェア工学勉強会への誘いソフトウェア工学勉強会への誘い
ソフトウェア工学勉強会への誘い
 

Recently uploaded

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 

Generating Assertion Code from OCL: A Transformational Approach Based on Similarities of Implementation Languages

  • 1. 2009. 10. 9 TOKYO INSTITUTE OF TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE MODELS 2009 Generating Assertion Code from OCL: A Transformational Approach Based on Similarities of Implementation Languages Rodion Moiseev Shinpei Hayashi Motoshi Saeki Department of Computer Science Tokyo Institute of Technology Japan
  • 2. Abstract  Generation Assertion Code from OCL − Transformational Approach: Regarding OCL-to-code as model transformation − Similarities of Implementation Languages: Constructing a language hierarchy for effective developing of transformation rules  Results − A translation framework has been developed − Showed ~50% of effort to construct translation rules saved 2
  • 3. Background  Model-centric approaches are becoming important in academia and industry  OCL is often the language of choice for stipulating constraints on models  Successful application depends on mature tool support: − Support for multiple programming languages − Customizable assertion code/test case generation 3
  • 4. Motivating Example  Application design: UML with OCL <<interface>> OCL MyApplication doQuery(q : Query) : Integer context MyApplication::doQuery( q: Query): Integer pre: not q = null post: result >= 0 4
  • 5. Motivating Example  A need to check OCL for multiple languages MyApplication Client 1 Perl Java Server <<interface>> Client 2 MyApplication Haskell doQuery(q : Query) : Integer context MyApplication::doQuery( q: Query): Integer pre: not q = null post: result >= 0 5
  • 6. Pinpointing the Problem Interface (UML+OCL) Generate <<write code>> Skeleton OCL Code Code OCL Skeleton Assertion Code Generate assertion code 6
  • 7. Problems  Troublesome to make individual OCL translators − Many languages exist • Most of existing tools are tailor-made for a specific language − Creating a translator requires efforts • Specifying OCL translation rules for each individual OCL concept, operator, etc.  Our solution: Usage of language similarities 7
  • 8. Language Similarities  E.g., for-loop iterating over a collection For Each apple In apples Do: If apple.color == “red” Then … Next Imperative Pseudo-language for (Iterator it = apples.iterator(); it.hasNext(); ) { Apple apple = (Apple) it.next(); if (apple.color == “red”) { for apple in apples: … if apple.color == “red”: Java … Python 8
  • 9. The Approach  Hierarchy of programming languages based on their structural similarities OCL Imperative Functional DbC Java, C# like Python Lisp Haskell JML Step-by-step <<described in terms of>> Java C# Translation Pseudo-languages Concrete languages MultiJava High concreteness 9
  • 10. Advantages  Provide a single framework for creating OCL translators for any language − Reuse translator implementations  Bridges semantic gap − Effort of understanding OCL is alleviated − Manual effort of creating OCL translators is reduced OCL OCL Semantic gap Imperative Python Python 10
  • 11. Generation Process Environment containing type information Parser + type checker OCL AST ENV AST→Imperative DL AST ENV OCL OCL Imperative DL Input Imper. DL→Python DL Imper. DL ENV UML + OCL rewriting rules Python DL Python Code Python DL→Python Code Python DL ENV printing rules DL = Definition Language (Structural representation of pseudo/implementation languages) 11
  • 12. Comparison with MDE DL Definition and MDE Terms Rewriting System Metalanguage Rewriting Language written in Transformation Language written in written in Imperative DL Imper. DL→Python DL Python DL PIM Transformation PSM Rules Rewriting engine 12
  • 13. Transformation Example All employees in the company earn more than 10,000 employees->forAll( e : Employee | e.salary > 10000) OCL AST: iteratorExp (assocEndCallExp simpleName("self") . simpleName("employees")) -> simpleName("forAll") ( varDecl(simpleName("e"), pathName("Employee")) | operCallExp( attrCallExp simpleName("e") . simpleName("salary"), simpleName(">"), intLitExp("10000") Company 1 .. * employees Employee ) salary : Int ) 13
  • 14. Rewriting Rules iteratorExp OE -> simpleName(“forAll”) `( varDecl(SN, TYPE) | OE’’ `) impMethodExtract( { impForLoop( OE, impVarDecl(TYPE, SN), { impIf( impNot(OE''), OCL AST→Imperative DL { impReturn( boolLitFalse ) }) }) ; impReturn( boolLitTrue ) }, pathName("Boolean")) . 14
  • 15. Imperative DL impMethodExtract( {emptyCtx | impForLoop( assocEndCallExp simpleName("self"). simpleName("employees"), impVarDecl(pathName("Employee"),simpleName("e")), { "ctx:iter" = simpleName("it_e") | impIf( impNot(operCallExp( attrCallExp simpleName("e"). simpleName("salary"), simpleName(">"), intLitExp(“10000"))), {emptyCtx | impReturn(boolLitFalse) }) }) }; {emptyCtx | impReturn(boolLitTrue) },pathName("Boolean")) 15
  • 16. Generation Result class Employee: From UML def __init__(self, name, salary): self.name = name self.salary = salary class Company: def __init__(self, employees): self.employees = employees def callExtMethod_A(self): From OCL for e in self.employees: if (not (e.salary > 10000)): return False return True def inv(self): return self.callExtMethod_A() 16
  • 17. Approach Evaluation  Implemented a tool in the Maude System (*)  To show the ability to implement several OCL translators with significant effort savings  Target languages − Imperative • Java OCL Predefined • Python Imperative Functional − Functional • Haskell Java Python Haskell • O’Haskell O’Haskell * http://maude.cs.uiuc.edu/ 17
  • 18. Approach Evaluation  Compare effort in our approach vs. direct approach: − # rewriting rules + # structures + # printing rules OCL AST OCL AST Imperative DL Imper. DL→Java DL Compare OCL AST →Java Java DL Java DL→Java Java Code Java Code Direct Approach Proposed Approach 18
  • 19. Evaluation Results  Imperative languages rewriting rules structures printing rules Java Python 85 58% 99 40% effort effort 59 saved saved Effort Effort 36 Direct Our Direct Our approach approach 19
  • 20. Evaluation Results  Functional languages rewriting rules structures printing rules Haskell O’Haskell 32% 99% 76 76 effort effort 52 saved saved Effort Effort 1 Direct Our Direct Our approach approach 20
  • 21. Evaluation Results Direct Proposed Approach Approach Java 85 36 Python 99 59 Haskell 76 52 O’Haskell 76 1 Total 316 148 ~50% effort could be saved on average 21
  • 22. Conclusion  Proposed a novel technique to generate assertion code from OCL constraints  Used structural similarities of programming languages to enable reusing in OCL translators for multiple languages − Saving manual effort  Run an experiment to show the claimed effort savings by using our approach 22
  • 23. Future Work  Uncovered functionalities of OCL − History expressions (@pre) − OCL messages − allInstances, etc.  Hierarchy Limitations − Difficult to extend hierarchy from the middle − Does not allow multiple parent nodes (e.g. useful for implementing an imperative/functional hybrid)  Real case study 23