SlideShare a Scribd company logo
1 of 28
Download to read offline
Identifying Traits with
Formal Concept Analysis
Adrian Lienhard, Stéphane Ducasse and Gabriela Arévalo
                             Software Composition Group
                           University of Berne, Switzerland
Overview
        “too high”...
   ...cancelled




                          duplicated
                          methods




ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   2 / 16
Overview
        “too high”...
   ...cancelled




                          duplicated
                          methods




ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   2 / 16
Overview
        “too high”...
   ...cancelled




                          duplicated
                          methods                                   traits




ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   2 / 16
Overview
        “too high”...
   ...cancelled
                                          FCA



                          duplicated
                          methods                                   traits




ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   2 / 16
Background: Traits in a Nutshell
                                                             Generic properties
         GraphicalObject
                                                           Colored        Bordered
   Circle                Polygon




ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   3 / 16
Background: Traits in a Nutshell
                                                              Generic properties
          GraphicalObject
                                                            Colored        Bordered
    Circle                Polygon

ColoredCircle        BorderedColoredPol.

  Colored                Bordered
                          Colored




 ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   3 / 16
Background: Traits in a Nutshell
                                                              Generic properties
          GraphicalObject
                                                            Colored        Bordered
    Circle                Polygon

ColoredCircle        BorderedColoredPol.               Single inheritance: limited
                                                       expressiveness
  Colored                Bordered
                                                       Multiple inheritance:
                          Colored
                                                       complexity
                                                       Mixin inheritance: fragility
Goal of traits: reuse mechanism                        due to linearization
avoiding complexity
 ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   3 / 16
Background: Traits in a Nutshell
Reuse mechanism                                Trait = “interface with implementation”
complementary to                                               TColored
inheritance [ECOOP’03]


                                                     {                       }
                                                             red      rgb
                                               provided      green    rgb:         required
Today in Perl 6, Squeak,                                     =
Scala, Fortress, ...                           methods                             methods
                                                             hash
                                                             ...
               ...                       ...

       ColoredCircle         BorderedColoredPol.
                                                            trait composition
                     TColored           TBordered



 ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   4 / 16
Roadmap

   ‣ FCA in a nutshell
   ‣ Approach overview
   ‣ Illustration of our approach on case study
   ‣ Evaluation of case study
   ‣ Conclusion


ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   5 / 16
FCA in a Nutshell
                         properties
                   small    far moon
           Mercur x
elements




              y
            Mars    x               x
           Jupiter           x      x
            Pluto   x        x      x


Concept: maximal group of elements
based on their common properties




      ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   6 / 16
FCA in a Nutshell
                         properties
                   small    far moon
           Mercur x
elements




              y
            Mars    x               x
           Jupiter           x      x
            Pluto   x        x      x


Concept: maximal group of elements
based on their common properties


 {Mars, Pluto, Jupiter},{moon}



      ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   6 / 16
FCA in a Nutshell
                         properties
                   small    far moon
           Mercur x
elements




              y
            Mars    x               x
           Jupiter           x      x
            Pluto   x        x      x


Concept: maximal group of elements
based on their common properties


 {Mars, Pluto, Jupiter},{moon}
     {Pluto, Jupiter},{moon, far}

      ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   6 / 16
FCA in a Nutshell
                         properties                                     Me, Ma, Ju, Pl
                   small    far moon
           Mercur x
elements




              y
            Mars    x               x                           Me, Ma, Pl         Ma, Ju, Pl
           Jupiter           x      x                            small              moon
            Pluto   x        x      x
                                                                 Ma, Pl             Ju, Pl
                                                               small, moon         moon, far
Concept: maximal group of elements
                                                                             Pl
based on their common properties
                                                                      small, moon, far

                                                                 Concept Lattice
 {Mars, Pluto, Jupiter},{moon}
     {Pluto, Jupiter},{moon, far}

      ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch     6 / 16
FCA in a Nutshell
                         properties                                     Me, Ma, Ju, Pl
                   small    far moon
           Mercur x
elements




              y
            Mars    x               x                           Me, Ma, Pl         Ma, Ju, Pl
           Jupiter           x      x                            small              moon
            Pluto   x        x      x
                                                                 Ma, Pl             Ju, Pl
                                                               small, moon         moon, far
Concept: maximal group of elements
                                                                             Pl
based on their common properties
                                                                      small, moon, far

                                                                 Concept Lattice
 {Mars, Pluto, Jupiter},{moon}               less elements
     {Pluto, Jupiter},{moon, far}            more properties

      ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch     6 / 16
Approach Overview
  Stage 1

           input generation FCA application              filtering      manual selection




                    {
  Stage 2
   for each class
        and trait
                             input generation       FCA application manual selection


ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   7 / 16
Case Study

   ‣ ST-80 Stream and Collection libraries
   ‣ Comparison with purely manual refactoring
       [OOPSLA’03]
   ‣ Illustration of our approach on example of
       Stream hierarchy...



ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch   8 / 16
Generating Input for FCA
            Detecting cancellations and duplications                                            Stage 1


Identify real interface of a class taking into account...

              ...
                     Stream
                                                      Idiom “too high”
              next
              boolean                                   ‣ implement methods “too
                                 sends message next
              int32
              ...
                                                          high” in common superclass
                                                        ‣ (implicitly) cancel methods
       WriteStream             ReadStream
                                                          in inappropriate subclasses
 ...                     ...

   next                  next
 ...                     ....

 ReadWriteStream
 ...
 next                                                 Fact ST-80 Collection library:
 ...                                                  131 methods too high (~10%), and
                                                      of those, 106 implicitly cancelled

       ASE‘05 - Identifying Traits with FCA      Adrian Lienhard - lienhard@iam.unibe.ch   9 / 16
Generating Input for FCA
              Detecting cancellations and duplications                                            Stage 1


  Identify real interface of a class taking into account...

invokes         ...
                       Stream
                                                        Idiom “too high”
cancelled       next
                                                          ‣ implement methods “too
                boolean
method          int32              sends message next
                                                            high” in common superclass
                ...
                                                          ‣ (implicitly) cancel methods
         WriteStream             ReadStream
                                                            in inappropriate subclasses
   ...                     ...

     next                  next
   ...                     ....

   ReadWriteStream
   ...
   next                                                 Fact ST-80 Collection library:
   ...                                                  131 methods too high (~10%), and
                                                        of those, 106 implicitly cancelled

         ASE‘05 - Identifying Traits with FCA      Adrian Lienhard - lienhard@iam.unibe.ch   9 / 16
Applying FCA                                                          Stage 1
Elements: all concrete classes
Properties: all concrete methods (identifying duplications)
Mapping: method in the real interface of the class
                                       WS, RWS, RS
                                          atEnd

                            WS, RWS                    RWS, RS
                         atEnd, nextPut:,             atEnd, next,
                            next:put:                   boolean

                  WS                         RWS                         RS
            atEnd, nextPut:,           atEnd, nextPut:,              atEnd, next,
               next:put:,               next:put:, next,               boolean,
               contents1              boolean, contents2              contents3


                                      atEnd, nextPut:,
                                       next:put: next,
                                    boolean, contents1,2,3


ASE‘05 - Identifying Traits with FCA        Adrian Lienhard - lienhard@iam.unibe.ch 10 / 16
Filtering                                                Stage 1


   ‣ reduce properties-sets to delta between
     sub-/superconcept
   ‣ remove concepts with no classes
                                       WS, RWS, RS
                                           atEnd

                             WS, RWS                  RWS, RS
                             nextPut:,
                                                   next, boolean
                             next:put:

                    WS                      RWS                    RS
                 contents1                contents2             contents3




ASE‘05 - Identifying Traits with FCA     Adrian Lienhard - lienhard@iam.unibe.ch 11 / 16
Selecting Traits and Hierarchy
       Reconstruction                                                                Stage 1



     Partly manual task: deciding whether a
     concept becomes a class or a trait

                                        Stream


               WriteStream         ReadWriteStream         ReadStream


                      TWriteableStream            TReadableStream




ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch 12 / 16
Invocation Analysis                                                       Stage 2




 Generating input: analyzing transitive method
 invocations of the class/trait
 Applying FCA
  ‣ elements: all methods of the class/trait

  ‣ properties: (transitive) method invocations

  ‣ mapping: identifying invocations with methods




ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch 13 / 16
Selecting Traits                                                    Stage 2

     Manual task of selecting traits.
     Lattice provides interesting alternatives:
      ‣ Additional methods in super-concepts
      ‣ Fewer methods in sub-concepts
                                        Stream


                 ReadStream       ReadWriteStream       WriteStream


                      TReadableStream            TWriteableStream

                        TReadableMultiple           TWriteablePutData

                         TReadableFileIn         TWriteablePutCharacter

                                                    TWriteableMultiple


ASE‘05 - Identifying Traits with FCA    Adrian Lienhard - lienhard@iam.unibe.ch 14 / 16
Comparison with
          Manual Refactoring
  Stream library
   ‣ almost identical result: inheritance reshaping + two
     main traits
   ‣ difference: conceptual vs. functional sub-traits

  Collection library
   ‣ Manual refactoring has identified more traits
   ‣ Different layers of traits with overriding behavior
   ‣ Our approach curative, manual approach speculative


ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch 15 / 16
Conclusion
   ‣ Succeeded in curing problems by
       restructuring hierarchy with traits (stage 1)
   ‣ Successful identification of fine-grained traits
       also when code is not shared (stage 2).
   ‣ Limitations:
       • Detection based on conceptual meaning of
         methods alone not possible
       • Missing methods can cause too small traits



ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch 16 / 16
Conclusion
   ‣ Succeeded in curing problems by
       restructuring hierarchy with traits (stage 1)
   ‣ Successful identification of fine-grained traits
       also when code is not shared (stage 2).
   ‣ Limitations:
       • Detection based on conceptual meaning of
         methods alone not possible
       • Missing methods can cause too small traits

                                Questions?
ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch 16 / 16
Refactored Collection
          Hierarchy
                                                           Legend:

                        Collection                                     inherits from
                                                                       composed from

        Set                             SequenceableCollection



                  SortedCollection         OrderedCollection             Array


   TRemoving-               TOrderedSorted-             TSequenced-
    Elements                   Common                  ElementAccess




ASE‘05 - Identifying Traits with FCA   Adrian Lienhard - lienhard@iam.unibe.ch 17 / 16

More Related Content

Viewers also liked

Viewers also liked (19)

Master Teset Specification SRCP
Master Teset Specification SRCPMaster Teset Specification SRCP
Master Teset Specification SRCP
 
Week9
Week9Week9
Week9
 
Phenomenal Oct 1, 2009
Phenomenal Oct 1, 2009Phenomenal Oct 1, 2009
Phenomenal Oct 1, 2009
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Biopython at BOSC 2010
Biopython at BOSC 2010Biopython at BOSC 2010
Biopython at BOSC 2010
 
Mpv2010
Mpv2010Mpv2010
Mpv2010
 
Itf ipp ch08_2012_final
Itf ipp ch08_2012_finalItf ipp ch08_2012_final
Itf ipp ch08_2012_final
 
Phenomenal Oct 8, 2009
Phenomenal Oct 8, 2009Phenomenal Oct 8, 2009
Phenomenal Oct 8, 2009
 
Gr trav f. risk cv s.metabolique
Gr trav f. risk cv s.metaboliqueGr trav f. risk cv s.metabolique
Gr trav f. risk cv s.metabolique
 
Uzbekistan caving 2011
Uzbekistan caving 2011Uzbekistan caving 2011
Uzbekistan caving 2011
 
Farma
FarmaFarma
Farma
 
Contention
ContentionContention
Contention
 
201505 CSE340 Lecture 02
201505 CSE340 Lecture 02201505 CSE340 Lecture 02
201505 CSE340 Lecture 02
 
Final programme 27 06
Final programme 27 06Final programme 27 06
Final programme 27 06
 
201506 CSE340 Lecture 23
201506 CSE340 Lecture 23201506 CSE340 Lecture 23
201506 CSE340 Lecture 23
 
201505 CSE340 Lecture 03
201505 CSE340 Lecture 03201505 CSE340 Lecture 03
201505 CSE340 Lecture 03
 
201003 Alice (part 1/15)
201003 Alice (part 1/15)201003 Alice (part 1/15)
201003 Alice (part 1/15)
 
A73A CQWW 2012 Contest operation from the Desert of Qatar
A73A CQWW 2012 Contest operation from the Desert of QatarA73A CQWW 2012 Contest operation from the Desert of Qatar
A73A CQWW 2012 Contest operation from the Desert of Qatar
 
Eddie Slide Show
Eddie Slide ShowEddie Slide Show
Eddie Slide Show
 

More from lienhard

Virtual Machines Lecture
Virtual Machines LectureVirtual Machines Lecture
Virtual Machines Lecturelienhard
 
Flow-Centric, Back-In-Time Debugging
Flow-Centric, Back-In-Time DebuggingFlow-Centric, Back-In-Time Debugging
Flow-Centric, Back-In-Time Debugginglienhard
 
OORPT Dynamic Analysis
OORPT Dynamic AnalysisOORPT Dynamic Analysis
OORPT Dynamic Analysislienhard
 
Dynamic Object Flow Analysis (PhD Defense)
Dynamic Object Flow Analysis (PhD Defense)Dynamic Object Flow Analysis (PhD Defense)
Dynamic Object Flow Analysis (PhD Defense)lienhard
 
Rapid Prototyping Of Visualizations Using Mondrian
Rapid Prototyping Of Visualizations Using MondrianRapid Prototyping Of Visualizations Using Mondrian
Rapid Prototyping Of Visualizations Using Mondrianlienhard
 
Tracking Objects To Detect Feature Dependencies
Tracking Objects To Detect Feature DependenciesTracking Objects To Detect Feature Dependencies
Tracking Objects To Detect Feature Dependencieslienhard
 
Practical Object-Oriented Back-in-Time Debugging
Practical Object-Oriented Back-in-Time DebuggingPractical Object-Oriented Back-in-Time Debugging
Practical Object-Oriented Back-in-Time Debugginglienhard
 
Test Blueprints
Test BlueprintsTest Blueprints
Test Blueprintslienhard
 
Object Flow Analysis
Object Flow AnalysisObject Flow Analysis
Object Flow Analysislienhard
 

More from lienhard (10)

Chicken
ChickenChicken
Chicken
 
Virtual Machines Lecture
Virtual Machines LectureVirtual Machines Lecture
Virtual Machines Lecture
 
Flow-Centric, Back-In-Time Debugging
Flow-Centric, Back-In-Time DebuggingFlow-Centric, Back-In-Time Debugging
Flow-Centric, Back-In-Time Debugging
 
OORPT Dynamic Analysis
OORPT Dynamic AnalysisOORPT Dynamic Analysis
OORPT Dynamic Analysis
 
Dynamic Object Flow Analysis (PhD Defense)
Dynamic Object Flow Analysis (PhD Defense)Dynamic Object Flow Analysis (PhD Defense)
Dynamic Object Flow Analysis (PhD Defense)
 
Rapid Prototyping Of Visualizations Using Mondrian
Rapid Prototyping Of Visualizations Using MondrianRapid Prototyping Of Visualizations Using Mondrian
Rapid Prototyping Of Visualizations Using Mondrian
 
Tracking Objects To Detect Feature Dependencies
Tracking Objects To Detect Feature DependenciesTracking Objects To Detect Feature Dependencies
Tracking Objects To Detect Feature Dependencies
 
Practical Object-Oriented Back-in-Time Debugging
Practical Object-Oriented Back-in-Time DebuggingPractical Object-Oriented Back-in-Time Debugging
Practical Object-Oriented Back-in-Time Debugging
 
Test Blueprints
Test BlueprintsTest Blueprints
Test Blueprints
 
Object Flow Analysis
Object Flow AnalysisObject Flow Analysis
Object Flow Analysis
 

Recently uploaded

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 

Recently uploaded (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 

Identifying Traits with Formal Concept Analysis

  • 1. Identifying Traits with Formal Concept Analysis Adrian Lienhard, Stéphane Ducasse and Gabriela Arévalo Software Composition Group University of Berne, Switzerland
  • 2. Overview “too high”... ...cancelled duplicated methods ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 2 / 16
  • 3. Overview “too high”... ...cancelled duplicated methods ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 2 / 16
  • 4. Overview “too high”... ...cancelled duplicated methods traits ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 2 / 16
  • 5. Overview “too high”... ...cancelled FCA duplicated methods traits ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 2 / 16
  • 6. Background: Traits in a Nutshell Generic properties GraphicalObject Colored Bordered Circle Polygon ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 3 / 16
  • 7. Background: Traits in a Nutshell Generic properties GraphicalObject Colored Bordered Circle Polygon ColoredCircle BorderedColoredPol. Colored Bordered Colored ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 3 / 16
  • 8. Background: Traits in a Nutshell Generic properties GraphicalObject Colored Bordered Circle Polygon ColoredCircle BorderedColoredPol. Single inheritance: limited expressiveness Colored Bordered Multiple inheritance: Colored complexity Mixin inheritance: fragility Goal of traits: reuse mechanism due to linearization avoiding complexity ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 3 / 16
  • 9. Background: Traits in a Nutshell Reuse mechanism Trait = “interface with implementation” complementary to TColored inheritance [ECOOP’03] { } red rgb provided green rgb: required Today in Perl 6, Squeak, = Scala, Fortress, ... methods methods hash ... ... ... ColoredCircle BorderedColoredPol. trait composition TColored TBordered ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 4 / 16
  • 10. Roadmap ‣ FCA in a nutshell ‣ Approach overview ‣ Illustration of our approach on case study ‣ Evaluation of case study ‣ Conclusion ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 5 / 16
  • 11. FCA in a Nutshell properties small far moon Mercur x elements y Mars x x Jupiter x x Pluto x x x Concept: maximal group of elements based on their common properties ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 6 / 16
  • 12. FCA in a Nutshell properties small far moon Mercur x elements y Mars x x Jupiter x x Pluto x x x Concept: maximal group of elements based on their common properties {Mars, Pluto, Jupiter},{moon} ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 6 / 16
  • 13. FCA in a Nutshell properties small far moon Mercur x elements y Mars x x Jupiter x x Pluto x x x Concept: maximal group of elements based on their common properties {Mars, Pluto, Jupiter},{moon} {Pluto, Jupiter},{moon, far} ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 6 / 16
  • 14. FCA in a Nutshell properties Me, Ma, Ju, Pl small far moon Mercur x elements y Mars x x Me, Ma, Pl Ma, Ju, Pl Jupiter x x small moon Pluto x x x Ma, Pl Ju, Pl small, moon moon, far Concept: maximal group of elements Pl based on their common properties small, moon, far Concept Lattice {Mars, Pluto, Jupiter},{moon} {Pluto, Jupiter},{moon, far} ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 6 / 16
  • 15. FCA in a Nutshell properties Me, Ma, Ju, Pl small far moon Mercur x elements y Mars x x Me, Ma, Pl Ma, Ju, Pl Jupiter x x small moon Pluto x x x Ma, Pl Ju, Pl small, moon moon, far Concept: maximal group of elements Pl based on their common properties small, moon, far Concept Lattice {Mars, Pluto, Jupiter},{moon} less elements {Pluto, Jupiter},{moon, far} more properties ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 6 / 16
  • 16. Approach Overview Stage 1 input generation FCA application filtering manual selection { Stage 2 for each class and trait input generation FCA application manual selection ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 7 / 16
  • 17. Case Study ‣ ST-80 Stream and Collection libraries ‣ Comparison with purely manual refactoring [OOPSLA’03] ‣ Illustration of our approach on example of Stream hierarchy... ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 8 / 16
  • 18. Generating Input for FCA Detecting cancellations and duplications Stage 1 Identify real interface of a class taking into account... ... Stream Idiom “too high” next boolean ‣ implement methods “too sends message next int32 ... high” in common superclass ‣ (implicitly) cancel methods WriteStream ReadStream in inappropriate subclasses ... ... next next ... .... ReadWriteStream ... next Fact ST-80 Collection library: ... 131 methods too high (~10%), and of those, 106 implicitly cancelled ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 9 / 16
  • 19. Generating Input for FCA Detecting cancellations and duplications Stage 1 Identify real interface of a class taking into account... invokes ... Stream Idiom “too high” cancelled next ‣ implement methods “too boolean method int32 sends message next high” in common superclass ... ‣ (implicitly) cancel methods WriteStream ReadStream in inappropriate subclasses ... ... next next ... .... ReadWriteStream ... next Fact ST-80 Collection library: ... 131 methods too high (~10%), and of those, 106 implicitly cancelled ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 9 / 16
  • 20. Applying FCA Stage 1 Elements: all concrete classes Properties: all concrete methods (identifying duplications) Mapping: method in the real interface of the class WS, RWS, RS atEnd WS, RWS RWS, RS atEnd, nextPut:, atEnd, next, next:put: boolean WS RWS RS atEnd, nextPut:, atEnd, nextPut:, atEnd, next, next:put:, next:put:, next, boolean, contents1 boolean, contents2 contents3 atEnd, nextPut:, next:put: next, boolean, contents1,2,3 ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 10 / 16
  • 21. Filtering Stage 1 ‣ reduce properties-sets to delta between sub-/superconcept ‣ remove concepts with no classes WS, RWS, RS atEnd WS, RWS RWS, RS nextPut:, next, boolean next:put: WS RWS RS contents1 contents2 contents3 ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 11 / 16
  • 22. Selecting Traits and Hierarchy Reconstruction Stage 1 Partly manual task: deciding whether a concept becomes a class or a trait Stream WriteStream ReadWriteStream ReadStream TWriteableStream TReadableStream ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 12 / 16
  • 23. Invocation Analysis Stage 2 Generating input: analyzing transitive method invocations of the class/trait Applying FCA ‣ elements: all methods of the class/trait ‣ properties: (transitive) method invocations ‣ mapping: identifying invocations with methods ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 13 / 16
  • 24. Selecting Traits Stage 2 Manual task of selecting traits. Lattice provides interesting alternatives: ‣ Additional methods in super-concepts ‣ Fewer methods in sub-concepts Stream ReadStream ReadWriteStream WriteStream TReadableStream TWriteableStream TReadableMultiple TWriteablePutData TReadableFileIn TWriteablePutCharacter TWriteableMultiple ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 14 / 16
  • 25. Comparison with Manual Refactoring Stream library ‣ almost identical result: inheritance reshaping + two main traits ‣ difference: conceptual vs. functional sub-traits Collection library ‣ Manual refactoring has identified more traits ‣ Different layers of traits with overriding behavior ‣ Our approach curative, manual approach speculative ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 15 / 16
  • 26. Conclusion ‣ Succeeded in curing problems by restructuring hierarchy with traits (stage 1) ‣ Successful identification of fine-grained traits also when code is not shared (stage 2). ‣ Limitations: • Detection based on conceptual meaning of methods alone not possible • Missing methods can cause too small traits ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 16 / 16
  • 27. Conclusion ‣ Succeeded in curing problems by restructuring hierarchy with traits (stage 1) ‣ Successful identification of fine-grained traits also when code is not shared (stage 2). ‣ Limitations: • Detection based on conceptual meaning of methods alone not possible • Missing methods can cause too small traits Questions? ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 16 / 16
  • 28. Refactored Collection Hierarchy Legend: Collection inherits from composed from Set SequenceableCollection SortedCollection OrderedCollection Array TRemoving- TOrderedSorted- TSequenced- Elements Common ElementAccess ASE‘05 - Identifying Traits with FCA Adrian Lienhard - lienhard@iam.unibe.ch 17 / 16