Formal Concept Analysis applied on Software Understanding - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

Formal Concept Analysis applied on Software Understanding

Description:

Formal Concept Analysis applied on Software Understanding. Gabriela Ar valo ... Inheritance Patterns: Analysing behavioral dependencies in a class hierarchy ' ... – PowerPoint PPT presentation

Number of Views:251
Avg rating:3.0/5.0
Slides: 30
Provided by: gabriela46
Category:

less

Transcript and Presenter's Notes

Title: Formal Concept Analysis applied on Software Understanding


1
Formal Concept Analysis applied on Software
Understanding
  • Gabriela Arévalo
  • Software Composition Group
  • University of Berne (Switzerland)
  • arevalo_at_iam.unibe.ch
  • http//www.iam.unibe.ch/arevalo

2
Roadmap
  • Problems in Object Oriented Applications
  • Concept Analysis
  • CA on Classes X-Ray Views
  • CA on Class Hierarchies Inheritance Patterns
  • CA on Applications Software Patterns
  • Lessons Learned and Conclusions

3
Software Maintenance
  • Maintenance of software systems 50 to 75 of
    the total cost
  • Reading and Analysis of Software ½ time of
    maintenance phase
  • Dependencies in the OO Applications
  • Explicit inheritance, references to classes
  • Implicit behavior reuse, collaborations among
    classes
  • Understanding source code is a key activity

4
Problems in Object Oriented Applications
  • Class Hierarchies
  • Behavior reuse between a class and its
    superclasses and subclasses
  • Classes
  • Definition and Use of state and behavior
  • Application
  • Structural and behavioral relationships between
    classes

5
Application of Concept Analysis
  • Identifying groups of software artifacts with
    similarities
  • Use of Concept Analysis
  • Different Levels of Granularity of the system
  • Approaches
  • X-Ray Views Understanding the internals of a
    class
  • Inheritance Patterns Analysing behavioral
    dependencies in a class hierarchy
  • Software Patterns Detecting structural
    relationships in an object oriented systems

6
Concept Analysis Definitions
Top
  • Specification of Elements and Properties
  • Concept Maximal groups of elements based on
    their common properties
  • Lattice partial order over the concepts

Bottom
7
Why do we use Concept Analysis ?
  • Simple Properties based on Elements
  • Generation of concepts automatically
  • Unanticipated combination of properties
  • Order between the generated concepts

8
ConAn Tool Architecture
X-Rays Views Software Patterns Inheritance
Patterns
Abstraction of the lattice
Identify groups
Concept Analysis
CA Pre-Filters
Keep one access to an attribute in a method
Element ltaddgt Property access firstIndex
CA Mapping
attribute
Class Ordered Collection
firstIndex
Code Representation
add
defines
Source Code
9
X-Ray Views Concept Analysis on Classes
instance variables
Top
methods
Bottom
  • Analysis of Accesses to State
  • Elements (methods) Properties (accesses to
    instances variables)
  • Analysis of Behavior
  • Elements (methods) Properties (invocations to
    other methods)

10
X-Ray Views on Classes
  • Collaborations Relationships of a set of methods
    and a set of attributes

Class A
w
x
t
s
X-Ray View is a set of collaborations to show
patterns based on the state and behavior
z
y
m
n
a
b
d
c
11
Class Understanding with X-Ray Views
  • Mapping of each concept as a collaboration
  • X-Ray View is a set of collaborations
  • State Usage
  • External / Internal Calls
  • Behavioral Skeleton
  • Validation 3 Classes in Smalltalk
  • Ordered Collection 2 attributes and 56 methods
  • UIBuilder 18 attributes and 122 methods
  • Scanner 10 attributes and 24 methods

12
Case Study Class CAContext
conceptsForElements conceptsForProperties
CAContext has 8 attributes and 63 methods
Behavior of Class
sigmaOf tauOf
setupWithContext
calculateLattice
createContext
deleteConcepts calculateConcepts
deleteLattice
addProperty
addElement
IR
concepts
lattice
lattice
lattice
lattice
properties
elements
conceptBuilt
latticeBuilt
conceptBuilt
conceptBuilt
conceptBuilt
conceptBuilt
latticeBuilt
conceptBuilt
conceptBuilt
latticeBuilt
latticeBuilt
State of Class
13
Inheritance Patterns Example
  • B define m2 and C defines m4 (abstract in A)
  • B and C calls m3 defined in A via a super call
  • B and C have a similar structure

14
Inheritance Patterns Concept Analysis applied on
Hierarchies
A
Type of calls Definer Class
s1 ... m6 self s2
invocations
B
  • Elements Invocations
  • Properties type of calls and hierarchical
    relationships with definer class

s2 ... s3 ... m5 super s1 m7 self
s3
15
Pattern 1 Template methods and hook methods
ArithmeticValue squared self self -
- ltabstractgt ltabstractgt
  • Abstract interface
  • Concrete implementation in subclasses
  • Framework add new concrete class, list of
    methods to implement
  • Hot spots template methods and hook methods

Integer ltconcretegt - ltconcretegt
LargeInteger ltconcretegt - ltconcretegt
16
Pattern 2 Self sends defined in ancestor
  • Subclass interface
  • Changes impact in all subclasses
  • Refactoring identify common code in
    sibling classes and define a new method in
    superclass (ex compressed)

17
Pattern 3 Local self send with super delegation
  • Magnitude
  • gt ltconcretegt
  • ltconcretegt
  • Delegation between methods
  • Behavior defined in the superclass
  • Change behavior in the superclasses
    causes effects in subclasses
  • SmallInteger
  • gt super gt
  • super
  • digitLength self gt
  • highBitAux self

18
Software Patterns
Abstract X
P
Z
Y
Abstract A
T
C
B
Software Patterns Common structural aspects
between classes
D
19
Software Patterns Concept Analysis on OO Apps
2
A
C
P
Tuples of classes
1
3
A B C P X Y Z all classes in a system
  • Elements Tuples of classes gt Number of
    classes order
  • Properties Set of indexes to show relationships
    in the tuples. (i,j)relation and (i)feature

20
Simplify Results with Filters
2
A
C
P
Tuples of classes
1
3
(1,2)Subclass (3,2)Subclass (2)Abstract (3,2)Acces
ses
21
Simplify Results with Filters
  • Merging Equivalent Patterns

S
(T,U,S) (1,3)Sub (2,1)Acc
D
3
(D,E,F) (2,1)Sub (3,2)Acc
1
E
F
T
U
2
1
3
2
Permutation of indexes ? 1 -gt2, 2-gt1,
3-gt2 ?((1,3)Sub (2,1)Acc)) ((2,1)Sub
(3,2)Acc)) gt (T,U,S) is transformed in (S,T,U)
22
Found Software Patterns
Subclass Star
Attribute Star
Order 3
Order 4
Order 3
Order 4
Composite
Bridge
Order 3
Order 4
Order 3
Order 4
23
Pattern Neighbourhood (1/2)
Almost Pattern
A
X
B
C
Y
Z
A
O3
B
C
A
B
C
Overloaded Pattern
24
Pattern Neighbourhood (2/2)
Cover Pattern
A
D
O4
B
C
A
O3
B
C
O2
A
A
B
C
Sub Pattern
25
Example CodeCrawler
  • CodeCrawler has 81 classes and 1077 methods
  • Statistics 6 patterns in order 2 and 24
    patterns in order 3

26
Lessons Learned
  • Inference of implicit relationships
  • Combination of simple properties (ex template
    and hook methods)
  • Recognition of Patterns
  • Classification of the results using abstractions
  • Quality of Properties
  • Iterative Process to identify meaningful
    properties

27
Conclusions (1/2)
  • Use of Concept Analysis
  • Promising Technique automatic generation of
    groups
  • Properties must be simple
  • Elements have few similarities
  • Explosion in number of concepts
  • Lattice is used partially
  • Some concepts have no meaningful information

28
Conclusions (2/2)
  • Collaborations about different aspects of a
    class/hierarchies/applications
  • Scalable approach small and large applications
  • Complementary patterns in different granularity
    levels
  • Interpretation is hard iterative application of
    views and opportunistic code reading

29
The End
x
w
t
s
z
y
n
m
a
c
b
d
Concept Analysis
w
x
t
s
z
y
m
n
a
b
d
c
Write a Comment
User Comments (0)
About PowerShow.com