Presentation is loading. Please wait.

Presentation is loading. Please wait.

Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.

Similar presentations


Presentation on theme: "Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks."— Presentation transcript:

1 Banaras Hindu University

2 A Course on Software Reuse by Design Patterns and Frameworks

3 by Dr. Manjari Gupta Department of Computer Science Banaras Hindu University

4 Lecture 7 Issues and Challenges in Design Pattern Detection

5  not only beneficial to the forward engineering process  patterns can also indicate the design rationale behind the system’s implementation  can aid in code comprehension Design Pattern Detection

6  no support for documenting the presence and usage of patterns in code  reflect the designers’ intents  ongoing research into correlations between the use of Design Patterns and defect frequency  Design document is often missing in many legacy systems  helps on program comprehension and design visualization  Code maintenance would be made easier Importance of Design Pattern Detection

7  should automatic  should detect nonstandard implementations of design patterns along with their standard implementations  should fast  should not specific to few particular design patterns.  should be customizable  should detect as less number of false positive and false negative patterns as possible. Important features of a method for detecting Design Patterns

8  executable code- static and dynamic analyses,  documentation of source codes,  design model (UML designs) and  other specifications. Product used for DPD

9  must accurately reflect the traits of each pattern  Must differentiate one pattern from other patterns  strictness of definition  more redundancy in a pattern’s definition, the more false positives  formal design patterns definition is required Design Pattern Definition

10  based on the decomposition approach.  getting idea about EDPs or meta patterns  Design patterns are expressed exclusively through EDPs  Hayashi et al [Hayashi08] used Pree’s meta patterns to represent these common properties  checked if the pre-defined conditions of the design pattern, including the combination conditions of the meta patterns, hold or not.  If it fails in this stage, they moved to other patterns that have the same meta patterns.  reduce any redundant repetition of checking meta patterns Design pattern detection based on their common properties

11  pattern detection tools includes three parts  a parser, a detector, and a database.  challenges in pattern detection  the size of the exploration space for large software systems. Approaches to detect design patterns

12  similarity score algorithm to detect design patterns.  structural relations between classes are encoded in multiple graphs and matrices.  similarly the design patterns are also encoded in matrices.  similarity score between the matrices of system source and those of patterns. Tsantalis et al. approach

13  SPQR  System for Pattern Query and Recognition  developed at the University of Carolina  uses Elemental Design Patterns, a theorem prover and ρ-calculus to detect DPs. Tools for DPD

14  Fujaba [Niere02]  forward and reverse engineering tool  developed at the University of Paderborn  uses graph matching on abstract syntax graphs representing source code, combined with fuzzy logic.  treat design and implementation variants of patterns separately. Tools for DPDCont…

15  Ptidej [Gueheneuc05]  visual tool for design recovery and DP recognition.  Detection is performed through constraints satisfaction with explanation Tools for DPDCont…

16  system and patterns, they can be represented in the form of matrices. DPD based on only structural and static analysis [Pande10]

17 Calculation of matrices for system design Client AbstractFactory +CreateProduct() AbstractProduct ConcreteFactoryConcreteProduct

18 Calculation of matrices for system design Client AbstractFactory +CreateProduct() AbstractProduct ConcreteFactoryConcreteProduct Direct Association matrix of Fig. 1 (root = 3)

19 Calculation of matrices for system design Client AbstractFactory +CreateProduct() AbstractProduct ConcreteFactoryConcreteProduct Direct Association matrix of Fig. 1 (root = 3) Dependency matrix Fig. 1 (root = 2)

20 Calculation of matrices for system design Client AbstractFactory +CreateProduct() AbstractProduct ConcreteFactoryConcreteProduct Direct Association matrix Dependency matrix Generalization matrix of Fig. 1 (root = 3) of Fig. 1 (root = 2) of Fig. 1 (root = 5)

21 Calculation of matrices for system design Client AbstractFactory +CreateProduct() AbstractProduct ConcreteFactoryConcreteProduct Direct Association matrix Dependency matrix Generalization matrix of Fig. 1 (root = 3) of Fig. 1 (root = 2) of Fig. 1 (root = 5) Overall Matrix

22 Calculation of matrices for Façade design pattern Façade Design Pattern

23 Calculation of matrices for Façade design pattern Façade Design Pattern Direct Association matrix of fig 5 (root = 2)

24 Calculation of matrices for Façade design pattern Façade Design Pattern Direct Association matrix of fig 5 (root = 2) Overall Matrix

25 Calculation of matrices for Façtory Method design pattern Factory Method Design Pattern

26 Calculation of matrices for Façtory Method design pattern Factory Method Design Pattern Dependency matrix of fig 2 (root = 3)

27 Calculation of matrices for Façtory Method design pattern Factory Method Design Pattern Dependency matrix of fig 2 Generalization matrix of fig 2 (root = 3) (root = 5)

28 Calculation of matrices for Façtory Method design pattern Factory Method Design Pattern Dependency matrix of fig 2 Generalization matrix of fig 2 (root = 3) (root = 5) Overall Matrix

29 Calculation of matrices for singleton design pattern Singleton Design Pattern

30 Calculation of matrices for singleton design pattern Singleton Design Pattern [ 1 ] Direct Association matrix of fig 5 (root = 2)

31 Calculation of matrices for singleton design pattern Singleton Design Pattern [ 1 ] Direct Association matrix of fig 5 (root = 2) [2 1 ]

32 Calculation of matrices for singleton design pattern Singleton Design Pattern [ 1 ] Direct Association matrix of fig 5 (root = 2) [2 1 ] [2] Overall Matrix

33  determine whether a graph is isomorphic to a subgraph of another graph.  is NP-complete.  G1 (V1, E1) and G2 (V2, E2) be two graphs  M1 and M2 be the adjacency matrices  A permutation matrix is a square (0, 1)-matrix  G1 (M1, L v, L e ) and G2 (M2, L v, L e ) are said to be isomorphic if there exist a permutation matrix P such that M2 = P M1 P T Sub-graph isomorphism detection

34  Given an n x n matrix M = (m ij ), let S k,m (M) denote the k x m matrix that is obtained from M by deleting rows k + 1,..., n and columns m + 1,..., n, where k, m < n.  Let G1 and G2 be graphs with adjacency matrices M1 and M2 of dimensions m x m and n x n respectively, where m < =n. There is a subgraph isomorphism from G1 to G2 if there exists an n x n permutation matrix P such that M ­­ ­ ­ 1 = S m, m (P M2 P T ) M2 -system design matrix and M1 -design pattern matrix Sub-graph isomorphism detection

35 Design Pattern Detection as Façade Design Pattern

36 P =

37 Design Pattern Detection as Façade Design Pattern P = P T =

38 Design Pattern Detection as Façade Design Pattern P = P T = PSP T =

39 Design Pattern Detection as Façade Design Pattern P = P T = PSP T = After eliminating entries from 3 rd row and 3 rd column we have reduced matrix as (because Façade Design Pattern is of 2 x 2 order)

40 Design Pattern Detection as Factory Method Design Pattern

41

42

43

44

45 After eliminating 5 th row and 5 th column (since factory method has order 4 x 4),

46  For singleton there will be no permutation matrix for which we can find out (after row and column elimination) a matrix which is equivalent to design pattern matrix. Particular Design Pattern may or may not exist

47


Download ppt "Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks."

Similar presentations


Ads by Google