Recovery of Design Pattern from source code

Similar documents
Detection a Design Pattern through Merge Static and Dynamic Analysis Using Altova and Lambdes Tools

Dynamic Analysis and Design Pattern Detection in Java Programs

A Novel Approach to Automated Design Pattern Detection

DESIGN patterns [16] have emerged to be an important

A Technique for Design Patterns Detection

IDEA: A Design Assistant Based on Automatic Design Pattern Detection

Graph similarity. Laura Zager and George Verghese EECS, MIT. March 2005

Design Patterns and Documentation Recovery based on Attributes

Flexible Design Pattern Detection Based on Feature Types

Design Pattern Detection in Eiffel Systems

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

Mining Design Patterns from Existing Projects Using Static and Run-Time Analysis

Encyclopedia of Information Science and Technology

Presenter: Dong hyun Park

Tool Based Support of the Pattern Instance Creation

Detection and Evolution of Design Patterns: Two Decades Later?

Using Metrics to Identify Design Patterns in Object-Oriented Software EPM

A Metric for Measuring the Abstraction Level of Design Patterns

Object-Oriented Design

Design Patterns. An introduction

As a programmer, you know how easy it can be to get lost in the details

Evaluating OO-CASE tools: OO research meets practice

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

An Efficient Semantic Web Through Semantic Mapping

A Review of Design Pattern Mining Techniques

UML Specification and Correction of Object-Oriented Anti-patterns

Automation of Semantic Web based Digital Library using Unified Modeling Language Minal Bhise 1 1

Pattern-Oriented Development with Rational Rose

SCENTOR: Scenario-Based Testing of E-Business Applications

Crash course on design patterns

APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS

Configuration Management for Component-based Systems

DETECTION OF DESIGN PATTERNS USING DESIGN PATTERN NEARNESS MARKING (DPNM) ALGORITHM

Modeling Systems Using Design Patterns

CS560: Formal Modelling and Implementation of Systems (Term II) Lecture: CASE A. O Riordan, 2009.

An Expert System for Design Patterns Recognition

Idioms for Building Software Frameworks in AspectJ

A System of Patterns for Web Navigation

International Journal for Management Science And Technology (IJMST)

The onprom Toolchain for Extracting Business Process Logs using Ontology-based Data Access

Design Pattern Detection and Software Architecture Reconstruction: an Integrated Approach based on Software Micro-structures

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

Detecting code re-use potential

INCORPORATING ADVANCED PROGRAMMING TECHNIQUES IN THE COMPUTER INFORMATION SYSTEMS CURRICULUM

A Metric of the Relative Abstraction Level of Software Patterns

Motivation. ! Stop reinventing the wheel, try to reuse code! ! How do you organize code reuse? History: " Copy & Paste. " Collect useful files

Domain-specific Concept-based Information Retrieval System

Architecture and Design Pattern Discovery Techniques A Review

Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming

An approach for reverse engineering of design patterns

Java Code Cleanup using ExtendJ

Design Pattern Detection

Expert Systems with Applications

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Design Patterns. Hausi A. Müller University of Victoria. Software Architecture Course Spring 2000

Access Control in Rich Domain Model Web Applications

IOSR Journal of Computer Engineering (IOSRJCE) ISSN: Volume 3, Issue 3 (July-Aug. 2012), PP

Tool Support for Complex Refactoring to Design Patterns

DEVELOPERS find it difficult to analyse and understand

X-S Framework Leveraging XML on Servlet Technology

JOURNAL OF OBJECT TECHNOLOGY Online at Published by ETH Zurich, Chair of Software Engineering. JOT, 2002

Design Pattern Recovery in Object-Oriented Software

Object-Oriented Design

Components Based Design and Development. Unit 3: Software Design Quick Overview

Collaborative Framework for Testing Web Application Vulnerabilities Using STOWS

Unified Modeling Language (UML)

Developing Software Applications Using Middleware Infrastructure: Role Based and Coordination Component Framework Approach

Facade and Adapter. Comp-303 : Programming Techniques Lecture 19. Alexandre Denault Computer Science McGill University Winter 2004

An Empirical Analysis of Defect Prone Design Pattern

Design Patterns V Structural Design Patterns, 2

Architecture-Centric Evolution in Software Product Lines:

Design Pattern Detection

Object-Oriented Design

3 Product Management Anti-Patterns by Thomas Schranz

Using Design Patterns in Education and Tutoring for the Software Systems Projects in Economic

Lecture 13: Design Patterns

CHAPTER 6: CREATIONAL DESIGN PATTERNS

Computation Independent Model (CIM): Platform Independent Model (PIM): Platform Specific Model (PSM): Implementation Specific Model (ISM):

A SELF-ADAPTIVE ARCHITECTURE FOR AUTONOMIC SYSTEMS DEVELOPED WITH ASSL

MDA and Integration of Legacy Systems: An Industrial Case Study

Pattern Resources. Lecture 25: Design Patterns. What are Patterns? Design Patterns. Pattern Languages of Programming. The Portland Pattern Repository

Product Line Evolution Using Source Packages

CSE 401/M501 Compilers

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

On Aspect-Oriented Technology and Object-Oriented Design Patterns

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

INTERACTIVE LEARNING OBJECTS: A FRAMEWORK BASED APPROACH

On Supporting HCOME-3O Ontology Argumentation Using Semantic Wiki Technology

ProM 6: The Process Mining Toolkit

EXTRACTION AND ALIGNMENT OF DATA FROM WEB PAGES

Advanced Object Oriented PHP

Applying Model View View-Model and Layered Architecture for Mobile Applications

Design Patterns. Gunnar Gotshalks A4-1

TECHNIQUES FOR COMPONENT REUSABLE APPROACH

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

DESIGN PATTERN - INTERVIEW QUESTIONS

An Empirical Verification of Software Artifacts Using Software Metrics

A ProM Operational Support Provider for Predictive Monitoring of Business Processes

ADT: Eclipse development tools for ATL

Object Oriented Methods with UML. Introduction to Design Patterns- Lecture 8

Transcription:

Recovery of Design Pattern from source code Amit Kumar Gautam and T.Gayen Software Engineering, IIIT Allahabad tgayen@iiita.ac.in, Ise2008004@iiita.ac.in Abstract. The approach for detecting design pattern from source code. In this approach present the four step process to find the design pattern from the source code. Generate the UML class diagram by applying reverse engineering process. Using the JAVEX tool which can take the class file as a input and give the information about properties of the attributes like inheritance, interface and obtained the relation between the classes. After that, get the information about runtime objects by which we obtained the behavior of the object created at run time. Combine result of all the three steps and analyze the structure of the software and fetch the design pattern using. 1 Introduction The design pattern describes a problem which occurs over and over again in our environment and describe core of the solution of that problem. It is basically description of communicating object and classes that are customized to solve a general design problem in a particular context. A design pattern are basically Smart: a novice would not think of it quickly Generic: a pattern is meant for a problem and does not depend on a domain or technology Well proven: identified from real systems that have been applied several times Simple: usually quite small with just a few classes Reusable: design patterns are well documented so that they can be used in different contexts Object oriented: Usually Reusable solutions to common problems Names of abstractions above the class level Handling both functional and non-functional requirements The motivation behind this work is the role played by Design pattern in source code is important. A design pattern provides knowledge about the role of each class within the pattern, the reasons of certain relationships among pattern constituents and/or the remaining parts of a system, localizing instances of the design patterns in existing software, can improve maintainability of software with other benefits like code comprehension, analysis of effects of using design patterns in software development. Some approaches have been proposed to detect design patterns from 24

source code or a design model, such as the UML diagrams. This work is a step in this direction. 2 Related Work There are many existing methods for discovering design patterns from design and source code. Rudolf et. al.[7] give a pattern matching-based method which use the Columbus framework with which they find out the pattern instances from the source code by considering the patterns structural descriptions, but with this method they could not detect the same type of design patterns such as State and Strategy.Graph theory [has also been applied in detection of design patterns by ascertaining similarity between the classes (vertices) in different systems (graphs) using the similarity score and iterative algorithm. Kleinberg proposed link analysis function to get the main hub and source nodes for web pages. Blondel et.al. [3]generalized this idea to an iterative algorithm for computing the similarity score for any two vertice s. This similarity score algorithm for design pattern detection has been applied in by encoding the source code and design patterns into different feature matrices. Kramer and Prechelt [4]have give a tool called Pat, to localize instances of structural design patterns, extracting design information from a CASE tool repository and using Prolog facts to how the pattern is express. Bergenti et.al [5]give us a tool called IDEA (Iteractive Design Assistant). This tool is very effective to find the realization and finding the design pattern. IDEA automatically (a) getect pattern from the UML diagram. (b) generating critiques about these pattern. Basically IDEA idea is automatically detect the design pattern from the architect of the modules. Stencel et al. proposed the function to detect various implementation of design pattern. They presented its proofof-concept implementation and also compared its efficiency to other state-of-the-art detection tools. The presented method is customizable. Dong et. al.[6] presented a novel approach to discovering design patterns by defining the structural characteristics of each design pattern in terms of weight and matrix. Their discovery process includes several analysis phases. Their approach is based on the XMI standard so that it is compatible with other techniques following such standard. They also develop a toolkit to support their approach. Francesca et. al. described an approach to design pattern detection using supervised classification and data mining techniques based on sub-components, and summarized the results they obtained on behavioral Design Patterns. Their Experiments with neural networks showed some encouraging results, but their instability led them to decision of employment of different techniques. [6]Jing et. al. presented some experiments on design pattern discovery from open-source systems using the tool they developed for design patterns detection: DP-Miner. In particular, their experiments discover the Adapter, Bridge, Strategy, and Composite patterns from the Java.AWT, JUnit, JEdit, and JHotDraw systems and experimental results show that design patterns have been widely applied in these systems and can also be recovered. In addition, they compared their experimental results with those of others and found several discrepancies. They analyzed this issue and discussed possible reasons for the discrepancies. More importantly, they argue for benchmarks for design pattern discovery. Damir presented 25

ontology-based architecture for pattern recognition in the context of static source code analysis. The proposed system has three subsystems: parser, OWL ontologism and analyzer. The parser subsystem translates the input code to AST that is constructed as an XML tree. The OWL ontologism define code patterns and general programming concepts. The analyzer subsystem constructs instances of the input code as ontology individuals and asks the reasoned to classify them. The recognition system is envisioned as a framework that can be used as a stand-alone utility, or as a subsystem for various larger systems, such as a compiler front end or IDE plug-ins. There are many other techniques that have been proposed earlier. The main problems encountered in using the above mentioned techniques are related to scalability, to many false positive results, and to the impossibility to find several design patterns; hence we decided to explore the problem and trying to overcome some of the mentioned or encountered difficulties. 3 Proposed Approach In this approach the method by which obtained the information about the properties of object at compile time and runtime. Basically there are four stages to finding the design pattern from the source code of the java software. Fig 1 Flow diagram of Approach Here divided this approach into four stages. First stage apply the reverse engineering process on our java source code. Apply the tool of reverse engineering process like Rational rose tool, StarUML tool which 26

has free available on internet. By using these tool, create the UML class diagram from the source code which is given in figure 2.And get the basic structure of the software. The UML Diagram of code given in figure 3 After getting the UML diagram of software, match the existing basic diagram of the Design pattern. In UML Class diagram, classes are represented as boxes with the class name as a title and the association and dependency relationships shown by arrows going from one class to another. By applying the detection process obtained the following information to detect the design pattern. The results include class names, relationships between classes and attributes of the classes. Fig 2. Sample code There are some disadvantages in the reverse engineering process like that the UML diagram does not give the runtime information about the objects. Sometimes its does not give the accurate structure of the software its may be miss the some relationship between the classes. So by recovering the accurate result followed the following steps. 27

Fig 3 UML Class Diagram of sample code In the Second stage using class file of the software to get the information about the classes and their relationship. For getting these relationships we use the JAVEX tool which take the class file as input and give the information about all the classes and their relationship. JAVEX tool are freely available on net. JAVEX is a fact extractor that extracts facts about all candidates or classes from the Java class files. These candidates are directories, source files, classes, interfaces, methods, variables, arrays, fields, constants, local variables and parameter variables. For each candidate JAVEX records all relations that occur in the source code, i.e. implements interface, extends class, instantiates, method invocations, containment (class contains classes, variables methods, etc.) and many more. By combining the both result approximately guess that which design pattern is present in our software source code. So we can find out the following static information is - uses for the relations. class extends class class implements interface class overrides method class references class class contains method class contains attribute Third stage extracts the run-time information of the software source code that want to analyze. These dynamic facts represent the function calls that were executed during run-time. Explain how these dynamic facts are useful during the design pattern detection. Design patterns are not just explain as their UML class diagram, Their 28

dynamic behaviors are also very important and differentiate patterns that have an same or identical static structure, like the State and Strategy pattern. the dynamic behavior of objects get in terms of specific sequences of messages between objects with UML Sequence and collaboration diagrams. These diagrams consist of vertical lines which represent the objects during run-time and arrows that represent the messages from one object to another. example of the Adapter design pattern UML sequence diagram given in figure 4. Looking at the diagram it is easy to deduce the order in which messages are passed. First, the Client calls the Adapter object, and that one calls the Adaptee directly and passes the return value back to the Client. Fig 4. Sample sequence diagram of adapter pattern We use UML sequence diagrams to create our runtime definitions of design patterns. The UML specification for sequence diagrams allows very precise definitions of the sequential interaction of objects. So in the final step combine the result of the first, second and third stage and finally detect the used design pattern is use in the software. 4 Illustration Here illustrate the some example code of bridge design pattern. 1 st use the StarUML tool an apply reverse engineering process and create the UML diagram of code which is given in figure. The UML diagram is shown in figure. After that we use the JAVEX tool. here pass the class file as a input. If we have the source code of the software then we need to compile the source first with javac. After that we find all class files and pass them as parameters to Javex. collect information about fields in classes as well as local variables with methods and arguments passed to these methods. 29

Fig 5 UML class diagram of the sample code Fig 6 Generate fact attribute from JAVEX tool After that create the sequence diagram of that code and get the dynamic information of the object. 30

Fig 7 Sequence diagram of sample code By this sequence diagram generate the runtime information of the source code. after that compare with the existing design pattern of the source code. And finally get the design pattern uses in the software. 5 Conclusion and Future Work Proposing a approach to find a design pattern from the java application source code by applying reverse engineering process and getting the information about the candidates with the help of JAVEX tool and runtime information of the objects. Many methods have been proposed and implemented but still lack in flexibility and effectiveness. For future work definitely see potential to improve the dynamic definitions. More detailed analysis of the GoF design patterns should allow better static and runtime information. Exploit all possibilities for the runtime information of the GoF design patterns. Believe that it will be useful to have multiple definitions of design patterns that do not have one common implementation. 31

References 1. E. Gamma, R. Helm, R. Johnson, and J. Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software, Addison Wesley, 1994 2. G. Antoniol, R. Fiutem and L. Cristoforetti, "Design Pattern Recovery in Object-Oriented Software", In 6 th International Workshop on Program Comprehension, 1998 3. V.D. Blondel, A. Gajardo, M. Heymans, P. Senellart, and P. Van Dooren, A Measure of Similarity between Graph Vertices: Applications to Synonym Extraction and Web Searching, SIAM Rev., vol. 46, no. 4, pp. 647-666, 2004. 4. Christian Kramer and Lutz Prechelt, Design Recovery by Automated Search for Structural Design Patterns in Object-Oriented Software, Proc. Working Conf. on Reverse Engineering IEEE CS press, Monterey, November 1996 5. Federico Bergenti and Agostino Poggi, Improving UML Designs Using Automatic Design Pattern Detection, In Proc. 12th. International Conference on Software Engineering and Knowledge Engineering, 2000. 6. Jing Dong, Dushyant S. Lad, Yajing Zhao, DP-Miner: Design Pattern Discovery Using Matrix, Proceedings of the 14th Annual IEEE International Conference and Workshops on the Engineering of Computer-Based Systems, IEEE Computer Society, 2007. 7. Nija Shi and Ronald A. Olsson, Reverse Engineering of Design Patterns from Java Source Code, 21st IEEE International Conference on Automated Software Engineering (ASE'06), IEEE Computer Society, 2006. 8. Zsolt Balanyi and Rudolf Ferenc, Mining Design Patterns from C++ Source Code, Proceedings of the International Conference on Software Maintenance, Page: 305, 2003. 9. Francesca Arcelli, Luca Cristina, Enhancing Software Evolution through Design Pattern Detection, Third IEEE Workshop on Software Evolvability, IEEE Computer Society, 2007. 32