using metrics to identify design using metrics to
play

Using Metrics to Identify Design Using Metrics to Identify Design - PowerPoint PPT Presentation

Using Metrics to Identify Design Using Metrics to Identify Design Patterns in Object-Oriented Software Patterns in Object-Oriented Software Patterns in Object-Oriented Software Patterns in Object-Oriented Software G. G. Antoniol Antoniol


  1. Using Metrics to Identify Design Using Metrics to Identify Design Patterns in Object-Oriented Software Patterns in Object-Oriented Software Patterns in Object-Oriented Software Patterns in Object-Oriented Software G. G. Antoniol Antoniol EPM

  2. Outline � Motivations; Motivations; � Design patterns concepts; Design patterns concepts; � Design patterns recovery approach; Design patterns recovery approach; � Experimental results; Experimental results; � Conclusions. Conclusions. EPM

  3. Motivations � Program comprehension; Program comprehension; � Aid in maintenance; Aid in maintenance; � Design � Design Design-implementation compliance check; Design-implementation compliance check; implementation compliance check; implementation compliance check; � Design quality evaluation. Design quality evaluation. EPM

  4. Design Patterns � Reusable, well Reusable, well-known known Proxy Pattern solutions to common solutions to common Subject Proxy design problems; design problems; op() op() � Categories: Categories: RealSub -> op() � structural structural ; RealSub � creational creational op() Refers � behavioral. behavioral. EPM

  5. Pattern/Motif/Architecture � Motif is just an instance Motif is just an instance in a code of a trait, act, in a code of a trait, act, � Pattern also means Pattern also means feature something we feature something we intent, consequences, … intent, consequences, … observe similar in nature observe similar in nature to a DP to a DP to a DP to a DP � The pattern encompasses The pattern encompasses � Actually we observe the Actually we observe the a lot more then structure a lot more then structure micro micro-architecture and architecture and or behaviour or behaviour related motifs pointing related motifs pointing to DP to DP � Motif intent may never Motif intent may never be known be known EPM

  6. Approach � Metrics based multi Metrics based multi-stage recovery process for stage recovery process for structural design patterns; structural design patterns; � Conservative recovery process; � Conservative recovery process; Conservative recovery process; Conservative recovery process; � Uniform representation of design and code Uniform representation of design and code using a design description language; using a design description language; � Experimented on industrial and public Experimented on industrial and public-domain domain C++ applications. C++ applications. EPM

  7. Old Metric Based Recovery Process EPM

  8. A META-Level Design/Code AOL Representation CLASS Subject � AOL: a design AOL: a design OPERATIONS description language; description language; PUBLIC op(); CLASS RealSub OPERATIONS � Captures OO design Captures OO design PUBLIC op(); PUBLIC op(); concepts from design concepts from design CLASS Proxy OPERATIONS and/or code; and/or code; PUBLIC op(); GENERALIZATION Subject � UML UML-based; based; SUBCLASSES Realsub, Proxy; � StP/OMT StP/OMT - AOL AOL RELATION Refers ROLES translator; translator; CLASS Proxy MULT one, CLASS RealSub MULT one � C++ C++ - AOL translator. AOL translator. EPM

  9. Computed Metrics � Private, public, protected methods and Private, public, protected methods and attributes attributes � Relation number: Relation number: Relation number: Relation number: � association association � aggregation aggregation � inheritance inheritance � Depth of the inheritance tree, number of Depth of the inheritance tree, number of children ... children ... EPM

  10. Multi-Stage Pattern Recovery R � Given a design pattern Given a design pattern p = ( < e ,..., e > , ) 1 k � Pattern Recovery: check constraints on all Pattern Recovery: check constraints on all dispositions of n classes k by k. dispositions of n classes k by k. dispositions of n classes k by k. dispositions of n classes k by k. Complexity: O n k ( ) � Complexity: EPM

  11. Metrics-based stage � Software metrics allows to effectively prune the search Software metrics allows to effectively prune the search space by means of class metrics and class pairs space by means of class metrics and class pairs shortest path; shortest path; � First kind of constraints: First kind of constraints: � single class level metrics; single class level metrics; � Output: Output: � a set of class candidate sets for each pattern searched. a set of class candidate sets for each pattern searched. EPM

  12. Metrics-based Stage: continued M m m =< ,..., > R p = ( < e ,..., e > , ) p 1 k 1 k [ ] C = { x | x ∈ D , m ∈ M : ∀ m ∈ m , m x ≥ m } i p i , j i i , j i ij Example: Proxy . <Sub,RealSub,Proxy>, k=3. Suppose collected metrics are: kids nbr, father nbr, association nbr [ ] [ ] [ ] > M =< 2,0,0 , 0 , 1 , 0 , 0 , 1 , 1 Proxy < c c , , c >∈ Proxy ( D ) only 1 2 3 if # kids ( c ) 2 # inh ( c ) 1 # inh ( c ) 1 #assoc(c ) 1 ≥ ≥ ≥ ≥ 1 2 3 3 EPM

  13. Metrics-based Stage: Shortest Path � Second kind of constraint: topology based; Second kind of constraint: topology based; � Class pairs shortest path; Class pairs shortest path; � Given a class: the remaining pattern � Given a class: the remaining pattern Given a class: the remaining pattern Given a class: the remaining pattern constituents must be reachable in a number of constituents must be reachable in a number of steps constrained by the pattern structure; steps constrained by the pattern structure; R � Output: reduced candidate sets Output: reduced candidate sets j EPM

  14. Topology Constraint EPM

  15. Shortest Path Equations y ∈ C Let be the smallest set given build C min min ( ) R y | x C : ∀ ∈ i i i ( , ) ShPath x y = ShPath ( e , e ) i min R = { < r ( y ),.., y ,.., r ( y ) > ∧ y ∈ C ∧ r ( y ) ∈ R ( y )} 1 n min i i EPM

  16. Exact Structural Constraints Exact design pattern relations are verified on reduced candidate sets. Let R ⊆ R s be the pattern subset of structural relations: R S = { x | x =< x ,..., x >∈ R ∧ ∀ r ∈ : 1 n s ⇒ ( ,..., ) ( ,..., )} r e e r x x p t p t EPM

  17. Delegation Stage � A class may implement an operation by calling A class may implement an operation by calling a methods of another class (to which it is a methods of another class (to which it is associated) thus it delegates the responsibility associated) thus it delegates the responsibility associated) thus it delegates the responsibility associated) thus it delegates the responsibility to it to it � Method calls of candidate classes are analyzed Method calls of candidate classes are analyzed to verify delegation; to verify delegation; � Often not applicable to design since method Often not applicable to design since method calls is always not documented. calls is always not documented. EPM

  18. Limitations of the approach � Code to AOL translation is affected by inherent Code to AOL translation is affected by inherent ambiguities in language implementation of ambiguities in language implementation of associations and aggregations see C++ ; associations and aggregations see C++ ; � Heuristics example: Heuristics example: � associations: object pointer/reference data member or associations: object pointer/reference data member or method formal parameter; method formal parameter; � aggregations: object instance or array data member, class aggregations: object instance or array data member, class template argument; template argument; � Solution: search also Solution: search also soft soft patterns, where aggregations patterns, where aggregations are substituted by associations. are substituted by associations. EPM

  19. Experiment: Public-Domain Sw � Design pattern recovery from code; Design pattern recovery from code; � 6 C++ applications, ranging from 5 to 127KLOC for a 6 C++ applications, ranging from 5 to 127KLOC for a total size of 328KLOC; total size of 328KLOC; � Not explicitly designed using patterns; Not explicitly designed using patterns; � Reduction effectiveness of the three stages: Reduction effectiveness of the three stages: � metrics metrics-based: 3 based: 3-4 orders of magnitude; 4 orders of magnitude; � structural: 1 structural: 1-2 orders of magnitude; 2 orders of magnitude; � delegation: 2 delegation: 2-3 times. 3 times. EPM

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend