SlideShare a Scribd company logo
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

PDF
Prototype-based Programming with JavaScript
PDF
Interval Pattern Structures: An introdution
PPT
Recommendation and Information Retrieval: Two Sides of the Same Coin?
PDF
Formal Concept Analysis
PDF
(In)Formal Concept Analysis
PDF
Context-Aware Recommender System Based on Boolean Matrix Factorisation
PPTX
Concept-Based Information Retrieval using Explicit Semantic Analysis
PPTX
Multimedia content based retrieval slideshare.ppt
Prototype-based Programming with JavaScript
Interval Pattern Structures: An introdution
Recommendation and Information Retrieval: Two Sides of the Same Coin?
Formal Concept Analysis
(In)Formal Concept Analysis
Context-Aware Recommender System Based on Boolean Matrix Factorisation
Concept-Based Information Retrieval using Explicit Semantic Analysis
Multimedia content based retrieval slideshare.ppt

Viewers also liked (19)

PDF
Master Teset Specification SRCP
PDF
Week9
PDF
Phenomenal Oct 1, 2009
PPT
Chapter 3
PDF
Biopython at BOSC 2010
PDF
PPT
Itf ipp ch08_2012_final
PDF
Phenomenal Oct 8, 2009
PPTX
Gr trav f. risk cv s.metabolique
PPT
Uzbekistan caving 2011
PPT
Contention
PDF
201505 CSE340 Lecture 02
PDF
Final programme 27 06
PDF
201506 CSE340 Lecture 23
PDF
201505 CSE340 Lecture 03
PDF
201003 Alice (part 1/15)
PPTX
A73A CQWW 2012 Contest operation from the Desert of Qatar
PPT
Eddie Slide Show
Master Teset Specification SRCP
Week9
Phenomenal Oct 1, 2009
Chapter 3
Biopython at BOSC 2010
Itf ipp ch08_2012_final
Phenomenal Oct 8, 2009
Gr trav f. risk cv s.metabolique
Uzbekistan caving 2011
Contention
201505 CSE340 Lecture 02
Final programme 27 06
201506 CSE340 Lecture 23
201505 CSE340 Lecture 03
201003 Alice (part 1/15)
A73A CQWW 2012 Contest operation from the Desert of Qatar
Eddie Slide Show
Ad

More from lienhard (10)

PDF
Chicken
PDF
Virtual Machines Lecture
PDF
Flow-Centric, Back-In-Time Debugging
PDF
OORPT Dynamic Analysis
PDF
Dynamic Object Flow Analysis (PhD Defense)
PDF
Rapid Prototyping Of Visualizations Using Mondrian
PDF
Tracking Objects To Detect Feature Dependencies
PDF
Practical Object-Oriented Back-in-Time Debugging
PDF
Test Blueprints
PDF
Object Flow Analysis
Chicken
Virtual Machines Lecture
Flow-Centric, Back-In-Time Debugging
OORPT Dynamic Analysis
Dynamic Object Flow Analysis (PhD Defense)
Rapid Prototyping Of Visualizations Using Mondrian
Tracking Objects To Detect Feature Dependencies
Practical Object-Oriented Back-in-Time Debugging
Test Blueprints
Object Flow Analysis
Ad

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PPT
Teaching material agriculture food technology
PDF
Electronic commerce courselecture one. Pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Cloud computing and distributed systems.
PDF
Network Security Unit 5.pdf for BCA BBA.
Building Integrated photovoltaic BIPV_UPV.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Teaching material agriculture food technology
Electronic commerce courselecture one. Pdf
Big Data Technologies - Introduction.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation_ Review paper, used for researhc scholars
Chapter 3 Spatial Domain Image Processing.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Understanding_Digital_Forensics_Presentation.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Weekly Chronicles - August'25 Week I
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Encapsulation theory and applications.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Advanced methodologies resolving dimensionality complications for autism neur...
Cloud computing and distributed systems.
Network Security Unit 5.pdf for BCA BBA.

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