Share This Article:

Transforming Model Oriented Program into Android Source Code Based on Drools Rule Engine

Abstract Full-Text HTML XML Download Download as PDF (Size:1104KB) PP. 49-59
DOI: 10.4236/jcc.2017.53006    926 Downloads   1,258 Views  
Author(s)    Leave a comment

ABSTRACT

Model transformation is one of the prominent features and the rising research area of Model Driven Engineering (MDE). MDE promotes models to primary artifacts that drive the whole development process. This paper presents the model transformation approach for textual model oriented programs Umple (UML Programming Language) to generate android applications (apps). The proposed approach improved the generation of android source code by using Drools transformation rules and introducing new concern in model driven mobile engineering. The major objective of proposed transformation approach intends to address consistency between source and target model and also intends to handle productivity issues in model driven software development. The main results of model transformation approach are Java class for model layer, XML file for view layer and android activity class for controller layer. Results show that proposed approach achieves high consistency between source and target model and also improves model transformation productivity.

1. Introduction

The mobile application development industry is increasingly growing up due to the intensive use of applications in mobile devices. Most of these devices run on Android operating system. Due to increasingly intensive use of mobile apps, the development of mobile apps demands additional worries about the short time- to-market and to improve the productivity [1]. Software engineering process aims to help leading an IT project from the perspective of transforming design model to code implementation in a specific platform. Indeed, the model driven architecture (MDA) is a new discipline of software engineering that has emerged to ensure the development of productive model [2].

In this paper, we propose a model transformation framework based on drools rule engine. In our approach, UMPLE’ class diagram considered as a primary model artifact that used to generate android source code. UMPLE blurs the distinction between code and modeling, enabling modelers and coders to collaborate on models in a way similar to code-based collaboration. The result of the transformation considered as model layer, view layer, controller layer and persistency layer. Model layer consists of plain old java object (POJO) class, view layer includes XML for android user interfaces, controller layer comprises with android activity classes and persistency layer considered as apps data management. In summary, the proposed approach transforms Umple class diagram to android mobile apps which contain create-retrieve-update-delete (CRUD) operations based on model-view-controller (MVC) architecture.

2. Related Work

Model Driven Mobile Apps Development

The authors [5] proposed a MDD approach for generating android applications from UML class diagram using Acceleo transformation languages. But their approach generates only two screens for the given class diagram. Their code generation approach is in progress and still need to complete for other mobile platforms. In literature [6], the authors proposed a model transformation approach based code generator for state machine diagram. Their approach generates Enterprise Java Bean (EJB) from model using ATLAS transformation language. Although the authors argued that their approach improves the quality and productivity of MDA concepts, they did not described the any measurements for proposed transformation approach. In literature [7], they proposed code generation method from UML message sequence diagram based on Meta Object Facility (MOF). They proposed meta-model for message sequence diagram and six model transformation rules written by Acceleo. They also described that MDE absolutely needs automatic tools and methods to transform platform-indepen- dent model into platform-specific model.

The researchers [8] described the model oriented programming as a new paradigm to reduce the ever-present tension between model-centric and code- centric development styles. UMPLE is a model-oriented programming language that supports modeling using a textual notation just like other high-level programming languages. Therefore, Umple is a multi-faceted technology allowing users to integrate modeling into software development straightforwardly.

From the perspective of evaluation, the authors [10] proposed the approach for empirical evaluation of model driven engineering in multiple dimensions. Their empirical studies included qualitative (expert judgments) and quantitative data (metrics) evaluations. They supposed that the productivity and defect detection rate are the effective metrics for measuring automation degree of model driven development process. A cost estimation approach is therefore needed that can incorporate characteristics of MDE that affect economies of scale and effort in application development with the size computation of various artifacts in MDE [11]. Therefore we measure our proposed model driven approach’s automation degree from productivity quality criteria. In order to estimate the code generator effort, we use COCOMOII tool [12].

3. Model Transformation Approach Based on Drools Rule Engine

3.1. Architecture

Figure 1. Model transformation framework architecture.

code written in a programming language. The transformer transforms the resulted source model syntax tokens into target model object pattern using Drools mapping rules. And then the code generator generates the android source code according to the MVC architecture.

3.2. Parser and Syntax Tree Model Constructor

3.3. Transformer

The transformer is composed with Drools inference engine that is able to scale to a large number of rules and facts. The inference component matches facts and data (syntax tree model). Facts may be modified, removed or added by executing rules or from external sources. The transformer receives the partial pieces of source code (package declaration, type declaration, field declaration and variable declaration) with syntax tree model. This model is transformed using predefined set of mapping rules in Drools Rule engine. The rule engine interprets and executes the mapping rules on the source model and produce target model. The relationships between transformer and Drools rule engine can be seen in Figure 3.

3.4. Code Generator

Code generation can be defined as the technique in which we write program that create another programs. After the object pattern matching process, the transformer fires the rules and generates corresponding model for code generator. The code generator receives the POJO model for model layer, XML model for view layer and android model for controller layer. The generator use the java development tool (JDT-core) to generate POJO class and android class source code. It also uses the JDOM to generate XML user interface file. Figure 4 shows

Figure 2. Parser component.

Figure 3. Transformer component.

Figure 4. Code generator structure.

the internal operation design of code generator. In order to generate java class and android from AST fragment, the proposed generator creates new compilation unit and construct the target language sentence structure by using Java Language Specification (JLS8) application programming interface (API). That API allows generator to create language statements such as Method Declaration, Variable Declaration, Expression Statement declaration, Method Invocation, Super Method Invocation, Field Access, Cast Expression, Class Instance Creation, etc.

3.5. Drools Transformation Rules

A transformation rule is a description of how one or more constructs in the source language can be transformed into one or more constructs in the target language. A transformation rule is the smallest entity within a model transformation. A rule contains a source pattern and a target pattern. For each occurrence of the source pattern in the source model, a target pattern is created in the target model.

Table 1. Drools transformation rule sample.

4. Evaluation and Analysis

4.1. Parser Analysis

To illustrate the ability of proposed parser, we have conducted the parser statistics with time efficiency and compare with Umple code analyzer [14]. As a case study of transformation process, we choose a Library Management System as Umple input source file. It contains number of 6 classes with 19 attributes. Figure 5 shows the implemented screen of proposed parser.

In order to measure the proposed parser performance, we extract the source file metrics from the input Umple file. The measurable metrics include number of classes, number of lines of code, number of variables and its data type. And then, we also conducted the proposed parser precision and recall using the following equations. Figure 6 depicts the parser analysis for Library Management System case study.

(1)

(2)

At this stage, we measured the proposed parser performance because of the parser accuracy can improve the later transformation and code generation processes. And also, this measurement can validate that whether the target model’ attributes are consistent with source model’ attributes or not. Maintaining consistency between documentation and the corresponding code is challenging task. Table 2 shows the proposed parser gets the average 100% of preci-

Figure 5. Umple to AST parser.

Figure 6. Parser analysis.

Table 2. Parser analysis result.

sion and 95.33% of recall rate. Therefore, we have the high consistent between source documents and target code.

4.2. Code Generator Analysis

For practical use in model-driven engineering, the quality of model transformations is a key issue. In this paper, we also conducted the quantitative measurement from the perspective of productivity criteria. Because of the productivity criteria is the effective metrics to ensure the automation degree of model transformation. The generated source code result for case study is show in Table 3. Figure 7 shows the implemented screen of code generator.

In order to calculate the estimated value in time and effort, we use the COCOMOII tool [12]. For this measurement, we set 616 SLOC and set the product cost parameters settings with the default nominal value. The tool showed a needed effort of 2 Person-months, a required 4months’ time frame for 616 SLOC. The proposed transformation approach can generate 616 SLOC within 2 seconds. Therefore, by using our transformation approach we could reduce time and effort in development process by 4 months and effort of 2 Person-months.

Figure 7. Code generator.

Table 3. Generated source code result.

4.3. Results and Discussion

In order to ensure the quality of proposed model driven transformation approach, we have conducted relevant measurement with step by step. The proposed transformation approach is developed and successfully tested over 20 UMPLE model projects. Firstly, we have measured the proposed parser efficiency with precision and recall. The results show that the parser precision rate from 99% to 100% and also the recall rate from 90% to 100%. Therefore, our proposed parser achieves high consistency between source file and parsed syntax. Table 4 shows the results analysis for parser efficiency, code generation efficiency and cost estimation value for each project. Secondly, we have conducted the statistical analysis for code generation process with number of lines of code metrics, number of files and code generation time for each phase. The main purpose of our proposed approach is to achieve high productivity quality. According to the cost estimation tool results, our approach can significantly reduce the time and developer effort. Therefore the proposed approach also reaches the satisfactory in productivity measurement.

Table 4. Results analysis.

5. Conclusions

Model transformation can be used for different tasks throughout the development process for manipulating models. The field of model transformation is an active research field and it is necessary to exploit the model transformation approach for the development of mobile applications. In this paper, an approach capable of generating MVC-based android source code from Umple class diagram is developed. This approach involves Drools model transformation rules that can address the technical space of MDE. Drools transformation rules make the proposed approach efficient, simple and faster in implementation. The parser analysis results show that the parsed source code is consistent with input Umple file. The evaluation results with COCOMOII estimator show that the transformation approach significantly reduces the effort and improves the productivity. Therefore, the proposed transformation approach is suitable for short time- to-market software development environment.

In this paper, we address the proposed parser consistency and productivity issues in model driven transformation process. As a future work, we plan to address the internal transformation rule quality measurement. The measurement of internal transformation rule quality is still challenging task in model driven engineering process.

Conflicts of Interest

The authors declare no conflicts of interest.

Cite this paper

Thu, E. and Nwe, N. (2017) Transforming Model Oriented Program into Android Source Code Based on Drools Rule Engine. Journal of Computer and Communications, 5, 49-59. doi: 10.4236/jcc.2017.53006.

References

[1] [1] Vaupel, S. and Taentzer, G. (2014) Model-Driven Development of Mobile Applica-tions Allowing Role-Driven Variants, MODELS’2014, Philipps-University at Mar-burg, Gernany.
[2] Poole, J.D. (2001) Model-Driven Architecture: Vision, Stan-dards and Emerging Technologies, ECOOP’ Workshop on Meta-modeling and Adap-tive Object Models, Hyperion Solutions Corporation.
[3] Browne, P. (2009) JBoss Drools Business Rules. Packt Publishing, 1847196063.
[4] Kriouile, A., Addamssiri, N. and Gadi, T. (2015) An MDA Method for Automatic Transformation of Models from CIM to PIM. American Journal of Software Engineering and Appli-cations, 4, 1-14. https://doi.org/10.11648/j.ajsea.20150401.11
[5] Benouda, H., Essbai, R., Azizi, M. and Moussaoui, M. (2016) Modeling and Code Generation of Android Applications Using Acceleo. International Journal of Software Engineering and Its Applications, 10, 83-94. https://doi.org/10.14257/ijseia.2016.10.3.08
[6] Bousetta, B., Beggar, O.E. and Gadi T. (2014) A Model Transformation Approach for Code Generation From State Machine Diagram. IADIS International Journal on Computer Science and Information Systems' 2014, 9, 1-15.
[7] Son, H., Kim, W. and Chul, R. (2013) MOF Based Code Generation Method for Android Platform. International Journal of Software Engineering and Its Application, 7, Hongik University, Sehong Campus, Ko-rea.
[8] Omar, B. and Lethbridge, T. (2013) Model Oriented Programming: Bridging the Code-Model Divide, ICSE Workshop on Modeling in Software Engi-neering, Modeling in Software Engineering (MiSE), University of Ottawa, Canada, 69-75.
[9] Parada, A. and Marques, M. (2015) Automating Mobile Application Development: UML-Based Code Generation for Android and Windows Phone. Journal of Theoretical and Applied Informatics (RITA), 22, Pelotas, Bra-zil.
[10] Mohaghegh, P. (2010) An Approach for Empirical Evaluation of Model Driven Engineering in Multiple Dimensions, MODELPLEX, Oslo, Nor-way.
[11] Sunkle, S. and Kullkarni, V. (2012) Cost Estimation for Model-Driven Engineering. Proceedings of the 15th international conference on Model Driven En-gineering Languages and Systems. https://doi.org/10.1007/978-3-642-33666-9_42
[12] Abran, A., Deshnarnais, J. and Mohammand, Z. (2015) Productivity-Based Software Estimation Models and Process Improvement: An Empirical Study. International Journal on Advances in Software, 8.
[13] Eithu, E. and Nwe, N. (2017). Model Driven Engineering: Automatic Code Generation of Android from UMPLE, 15th International Conference on Computer Application (in Press), Yangon, Myanmar.
[14] https://github.com/umple/umple

  
comments powered by Disqus

Copyright © 2018 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.