
A Refactoring Architecture for Measuring and Identifying Spots of Design Patterns Insertion in Source Code Luan Bukowitz Beluzzo, Simone Nasser Matos and Thyago Henrique Pacher UTFPR, Ponta Grossa, Parana, Brazil Keywords: Software Architecture, Refactoring, Design Patterns. Abstract: This work presents an architecture for detecting insertion spots of design patterns in an object-oriented source code. The proposed architecture contains a Service that implements Detection Methods (DMS) present in the literature such as identification of precursors, prolog rules and facts, among others. The DMS notifies the Metrics Service (MS) which patterns can be used. The evaluation of the application of the patterns undertaken by the MS is performed by means of quality metrics such as maintainability, flexibility, and so forth. The MS notifies the Client App (CA) of the advantages and disadvantages of using the eligible patterns. The CA interacts with the user to retrieve decisions about which changes to perform in source code according to the design pattern real benefit and notifies the Applier Service (AS), that applies the patterns in the source code. The difference between the proposed architecture and the literature is that it allows a thorough interaction with the user and it creates an extendable environment to cover several pattern detection/insertion methods. The architecture allows automated support to users engaged in the refactoring process based on design patterns. 1 INTRODUCTION This work proposes an architecture aimed to pro- vide a structure that covers methods in the literature Refactoring processes correct bad smells or code that that identify spots to insert design patterns in source is poorly written. These processes are aimed to pro- code, also, some other methods that apply these pat- vide a good internal structure for a software project, terns in a given project. Besides detecting and inser- to remove duplicated code, find meaningful names for ting patterns in source code, this architecture will also methods and classes, restructure class hierarchies and be responsible for the evaluations of the possible re- others (Fowler and Beck, 1999). Some quality requi- factorings and to promote interactions with the user, rements such as performance, maintainability, loose providing feedbacks and relying on his/her decisions coupling, high cohesion and reusability can be impro- to actually execute the proposed procedures. ved in a software project through refactoring (Fowler and Beck, 1999; Mens and Tourwe,´ 2004). Design patterns may be attached to refactoring 2 BACKGROUND WORKS processes improving code flexibility, these patterns are highly recommended during software natural evo- In order to extend the reader’s perception concerning lution (Cinneide, 2000). The benefits of applying methods that to introduce design patterns in source these patterns are widely known, being present in code, the following descriptions present a deeper un- works that detect them, like the ones of Chatzigeor- derstanding of some methods of the literature. giou et. al (Chatzigeorgiou et al., 2006) and Li et. Some works were analyzed during the develop- al (Li et al., 2007), as well as in works that used them ment of the architecture, these were gathered consi- within refactoring processes such as Christopoulou et. dering the past twenty years. Cinneide´ and Nixon al (Christopoulou et al., 2012), Zafeiris et. al (Zafeiris (Cinneide´ and Nixon, 1999) for example, created a et al., 2017) and Zanoni et. al (Zanoni et al., 2015). method to insert a given design pattern based on mi- It has been a more common approach to deal nipatterns and minitransformations. with refactorings to patterns in an automated man- Jeon, Lee and Bae (Jeon et al., 2002) only pro- ner (Christopoulou et al., 2012; Fontana and Zanoni, pose a method to identify spots to insert design pat- 2011; Zafeiris et al., 2017). terns in code through prolog rules and facts; Gaitani 632 Beluzzo, L., Matos, S. and Pacher, T. A Refactoring Architecture for Measuring and Identifying Spots of Design Patterns Insertion in Source Code. DOI: 10.5220/0006868006320639 In Proceedings of the 13th International Conference on Software Technologies (ICSOFT 2018), pages 632-639 ISBN: 978-989-758-320-9 Copyright © 2018 by SCITEPRESS – Science and Technology Publications, Lda. All rights reserved A Refactoring Architecture for Measuring and Identifying Spots of Design Patterns Insertion in Source Code et al. (Gaitani et al., 2015) propose refatorings to- IS in order to request operations from the core. wards a NULL Object design pattern; Christopoulou It is quite noticeable that Figure 1 displays a dupli- et al. (Christopoulou et al., 2012) identify the spots to cated structure in the architecture, the only difference insert a Strategy design pattern, these are spots con- being the identifier of the so called Regions (A and B). taining conditional statements with two or more bran- These regions were built considering the possibility to ches. have absent modules in each region, it also provides Analyzing the works Cinneide´ and Nixon means to distribute the requests from the CAs to the (Cinneide´ and Nixon, 1999), Jeon, Lee and Bae alive members in the core. (Jeon et al., 2002), Gaitani et al. (Gaitani et al., The main idea is that each member of the Region 2015) and Christopoulou et al. (Christopoulou et al., must send messages directly to the IS, this confirms its 2012), it is noticed that features could be added to alive state within the architecture. After that, once the their process, for example, measuring whether the IS receives a request from a given CA, it can redirect insertion brings actual benefits to the project and the call to a specific member for processing. improving interactions with the user. Once the overview of the architecture is well sta- Considering the above mentioned and the other blished, the following sections are in charge of having works of the literature that were studied, this ar- a detailed description of the basic requirements of the chitecture focuses on having more interactions with architecture and afterwards, the internal procedures of the user. It also evaluates the refactoring possibility each module. through software metrics. As last, it provides an en- vironment that covers several refactoring methods of 3.1 Architecture Inputs the literature, which enables the user to use an unique process (having no need to search for other refacto- The input corresponds to a project with a set of ring tools). subsystems, at the lowest level of each subsystem is a set of source files. Within the project, a Project Description file is 3 PROPOSED ARCHITECTURE provided so that the project may be registered. The Project Description has the project id (empty at first The proposed architecture (Figure 1), called Ar- and filled by a procedure of the architecture), pro- chProMe, is composed of tree core modules: Applier ject name (significant name given by the project ow- Service (AS), Metrics Service (MS) and Detection ner) and a source code folder path (src). Methods Service (DMS); an intermediary one called A .prop extension is placed with the project file Intermediary Service (IS) and a Client App (CA). name as a markup extension to be read by the CA, The modules that present this name Service are the which identifies the text file as a Project Description. ones that contain the pattern Service Layer, this pat- The first requirement of the ArchProMe is to know tern presents some functionalities that are made avai- in depth the methods of the literature focused on lable to external users, like a boundary that encapsu- the insertion and detection of patterns insertion spots lates business rules and control the responses to be (Section 2). In case of the creation of a new method, given in each functionality (Fowler, 2002). the architecture must be prepared to be extended. The second requirement for the ArchProMe are a set of metrics, which are used to evaluate the qua- lity of the source code. These metrics provide means to precisely measure a source code through quantita- tive values. They also contribute to measure quality requirements such as: reliability, maintainability and others. After having the base for the refactoring (require- ments) and receiving the input value (project), the ar- chitecture is ready to detect what design patterns can be inserted within the source code. Figure 1: Architecture Overview. 3.2 Client App The CA in turn, promotes the interaction between the users of the architecture (probably software deve- This module presents two main responsibilities: to in- lopers) and is responsible for communicating with the teract with the user and to communicate with the IS. 633 ICSOFT 2018 - 13th International Conference on Software Technologies Among the interactions with the user, it is expected to ceived and to distinguish what architecture member extract data inputs from the user and present some in- should be executed, the IS searches in its queues by formation from the architecture core (patterns eligible type, the Service to be called. for insertion and metrics analysis result). For every kind of request received by the IS, the There are two main interactions available for the due Service is retrieved from its own queue and called user: start process and apply patterns: through an HTTP request for processing.The functio- Start Process: This interaction is triggered by the nalities of this module, as well as the Services called user and it causes the CA to request two operations in the requests are presented as follows: provided by the IS. First the CA is responsible for col- Register Project Request: It inserts the source code lecting project data from the Project Description, after (along with the other data provided) in the database. that, the CA requests the IS to register the project at The project will have its unique id once it is inserted, hand. The source code is compressed and sent with after that, the id is sent as a response.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages8 Page
-
File Size-