A Novel Approach for Dynamically Recognizing Strategy Design Pattern in Java
Kurimilla Sridhar Dept. of Comp. Sci. Vaagdevi P.G. College, INDIA firstname.lastname@example.org Nuthi Sudhakar Research Scholar. Rayalaseema University, INDIA email@example.com Jayadev Gyani Dept. of Comp. Sci. Jayamukhi Institute of Technological Sciences INDIA firstname.lastname@example.org
Design patterns lead to production of high quality and easily maintainable software. Design pattern recognition is usually realized by static analysis based on source code, suited for recognition of structural aspects but limited and imprecise in analyzing behavior. Design patterns, however, usually comprise not only structural but also significant dynamic aspects. In this paper we present a novel approach for detecting strategy design pattern using both static and dynamic analysis.
specific sequences of actions and interactions of the objects of these classes (dynamic information). Design pattern recognition is usually realized by static analysis based on source code, suited for recognition of structural aspects but limited and imprecise in analyzing behavior .Design patterns, however, usually comprise not only structural but also significant behavioral aspects. An example can be found in . For precise design pattern recognition, such a static analysis is not sufficient. The behavioral aspects of a pattern are an important factor. Dynamic analyses can be used to analyze the runtime behavior of a system.
Dynamic aspects, static analysis,
Design patterns are generally defined as descriptions of communicating classes that form a common solution to a common design problem. They have widely and rapidly attracted the interest of the software engineering community. Their proponents argue that their use leads to the construction of well-structured, maintainable, and reusable software systems. Because most current software projects deal with evolving products consisting of a large number of components, their architecture can become complicated and quite messy. Design patterns can impose structure on the system due to the abstractions being used. Consequently, the identification of implemented design patterns could be useful for the comprehension of an existing design and provides the ground for further improvements. Extraction of design patterns further enables in applying behavior-preserving transformations to improve design , readability and maintainability of exiting code , . Design patterns usually have static and dynamic aspects. A pattern specifies structural Connections among the classes via call, delegation or inheritance relations (static information). Additionally, it requires some
2. Previous Work
Previously the structure and the behavior of the system with respect to the patterns indicating the instance of a certain design pattern .This is necessary, since there are situations, where neither static nor dynamic analyses alone are sufficient (or not with acceptable expenses). For example it is statically not computable, which method or attribute is actually called or accessed at run time and how often. Even data flow analyses cannot predict when the program to be analyzed requires user interactions. As objects are created at run time, relations among objects are dynamic by nature.
3. Present work
Recognition of Design Pattern using Dynamic Analysis: A tool-based recognition is defined for each design pattern. The process starts with static analysis which takes source code of the system (cf. Fig 3).and is passed for dynamic analysis to check for each design pattern candidate if the collaboration of its constituents at runtime
1. Execution of the class and displaying the results. 6. Dynamic building of client class for request invocation. The behavior can be changed without breaking the classes that use it. and make them interchangeable. This reduces the amount of gathered data significantly. This allows better decoupling between the behavior and the class that uses the behavior. Identify the interface class. The program is executed manually by the reverse engineering. The program is executed manually by the reverse engineering. encapsulate each one as an object. and the classes can switch between behaviors by changing the specific implementation used without requiring any significant code changes.
Fig. Fig.conforms to the behavioral description of the design pattern. The strategy pattern lets the algorithms vary independently from clients that use them. In the strategy pattern behaviors are defined as separate interfaces and specific classes that implement these interfaces.2 We propose to identify the design pattern (strategy)by analyzing the structure and the behavior of the system with respect to the patterns indicating the instance of a certain design pattern. Look for concrete classes that implement interface.
The Strategy pattern is useful for situations where it is necessary to dynamically swap the algorithms used in application.Probability that a selected class will be a candidate class for strategy pattern is that it is a context class. Behaviors can also be changed at runtime as well as at design-time. The design pattern candidates and behavioral pattern specifications are used to record method call traces during the program’s execution. Specific classes encapsulate these interfaces. 1)
. 5. 2. Only those classes and methods are monitored during dynamic analysis that have been identified by static analysis. 4.
UML Diagram (Fig. 3. This reduces the amount of gathered data significantly. Here we trace the pattern at run time by user interaction with acceptable values to identify which method is called with what attribute values. Analyze for interface handles. 3
Here we try to identify Strategy pattern by selecting a class . Load a class. The strategy pattern uses composition instead of inheritance. Only those classes and methods are monitored during dynamic analysis that has been identified by static analysis. The strategy pattern is intended to provide a means to define a family of algorithms.
Fig. 5) along with the names of the concrete classes that implement the interface. We proposed flexible design pattern detection process. 7) which method of the Context class called the interface handle execute method and which algorithm is executed with results displayed. Where there is an interface called Strategy with abstract method called execute with two integer parameters and return value of integer type. The Context constructor has Strategy interface as parameter while creating the object for Context class any of the subclass objects of the Strategy interface can be passed and that can be assigned to the Strategy interface handle declared within the class. Selecting the subclass type will
In this paper we reported a contribution to area of reverse engineering by using a novel detection technique. the test class is executed by selecting exec test class. Momentarily our tool supports only a limited no of design patterns. Implementation
For implementation purposes an instance of strategy pattern need to have the following 1. We are trying to improve this tool kit so that can detect many different design patterns. 5. 6. And also. 5) and with type of parameters to be passed to the execute method. Concrete Strategy interface implemented classes. Here we consider an example as shown in Fig. Event Queue class. Event Set Class. 6) and the test class is built.
Fig. The above classes are used in static analysis of the design pattern. Strategy Interface 3.4. 6 The results are displayed showing (Fig. For executing the method dynamically a class is built with the type of object that is to pass (Fig. 4 When a Context class is loaded the tool searches for the Strategy interface handle and the interface is displayed (Fig. 5 The parameters are drawn from the keyboard (fig. 4. we created a detection algorithm for each design pattern. Virtual Machine class. Are used for observing the dynamic behavior of the design pattern.
5.4. this method has different algorithmic implementation depending on the type of concrete class selected as the concrete classes implements the Strategy interface. Context class 2.
Fig. The Context class has a handle of Strategy interface (Composition) which can hold any of its subclass objects and invoking the Strategy method will result in the execution of the subclass algorithm.
decide what algorithm implementation we need to invoke at runtime.
University of Paderborn.
Fig. Shi. A possibility to extend the presented approach is to monitor object attributes. Darmstadt. 2006. The 21st! EEE/ACM International Conference on Automated Software Engineering. Elsner. In E. “Reverse Engineering of Design Patterns from Java Source Code”. Proc. Proc.K. Olsson.R. of the 6th Workshop Software Reengineering (WSR). pages 63–64. Value changes of attributes used in those constraints can be recorded and the constraints will be checked during pattern recognition. Murti. and A. “Tecdp: A Tool for Extracting Creational Design Patterns”. volumetr-ri-04-253 of Technical Reports.
. in Proceedings of ACM International Conference and Workshop on Emerging Trends in Technology.Hakjin Lee. Future Work
Both static and dynamic analyses produce fuzzy rated results. preconference proceedings of IEEE conference on Software Technology and Engineering Practice (STEP-2005). Sudhakar and J. The results from dynamic analysis can be used to automatically calibrate the credibility values of the static analysis rules. pages 7–10."Enhancing Software Evolution with Pattern Oriented Software Product Life Cycle". of the 2nd International Fujaba Days 2004. Specifying Patterns for Dynamic Pattern Instance Recognition with UML 2. Germany. Wendehals.
 . Eunseok Lee.
7.  L.-E. 735-736.  “A Design Pattern Detection Technique that Aids Reverse Engineering”. Z¨undorf. Constraints on the attribute values can be defined within states in the behavioral patterns. volume 24/2. May 2004. Gyani. References. editors. M.0 Sequence Diagrams. Meyer.Budapest.7
6.  Jayadev Gyani and P. Selective Tracing of Java Programs. Doberkat and U. of the ICSE 2003 Workshop on Dynamic Analysis. Kelter. Sch¨urr andA. editors. “Improving Design pattern Instance Recognition by Dynamic Analysis” . Bad Honnef. 2003. In A. L. pp.Proc.Wendehals. Hungary  N. Germany.N. September 2004. and R. Wendehals. 2010.Hyunsang Youn. Softwaretechnik-Trends.  L.