SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

14.jun.2012
14.jun.201214.jun.2012
14.jun.2012
Tech_MX
 
2013 bookmatter learn_javaforandroiddevelopment
2013 bookmatter learn_javaforandroiddevelopment2013 bookmatter learn_javaforandroiddevelopment
2013 bookmatter learn_javaforandroiddevelopment
CarlosPineda729332
 

Was ist angesagt? (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
 

Andere mochten auch

Andere mochten auch (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 ミニチュートリアル 「データマイニング技術を応用したソフトウェア構築・保守支援」
 

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

ModRef'09: Gecode support for MCP
ModRef'09: Gecode support for MCPModRef'09: Gecode support for MCP
ModRef'09: Gecode support for MCP
pwuille
 
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
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
Vasavi College of Engg
 

Ähnlich wie 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
 

Mehr von Shinpei Hayashi

Mehr von 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
 
ソフトウェア工学勉強会への誘い
ソフトウェア工学勉強会への誘いソフトウェア工学勉強会への誘い
ソフトウェア工学勉強会への誘い
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

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