Reverse And Round Trip Engineering

Print   

02 Nov 2017

Disclaimer:
This essay has been written and submitted by students and is not an example of our work. Please click this link to view samples of our professional work witten by our professional essay writers. Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of EssayCompany.

Triangulation of a polygon is a fundamental algorithm in computational geometry. Triangulation allows us that from a set of point’s get a display of three-dimensional objects and provides a mechanism for so-called glazing of three-dimensional figures [1]. This procedure is very important for speed, quality and resolution of the 3D objects. Polygon triangulation has many applications in computer graphics and is used in the pre-trial phase of non-trivial operations of simple polygons [2]. Triangulation of convex polygons is a topical problem which appears also in a two-dimensional computational geometry [3,4]. A triangulation technique in computational geometry is the most common method of panelization. The easiest method of segmentation and smoothing of double curved surface is through a network of triangles. The advantage of the triangle as a geometric object is that the area between the three points is always straight.

A triangulation of a simple polygon assumes the decomposition of the polygon interior into triangles, where mutually internal diagonals do not intersect. The number of all triangulations of a convex polygon with n vertices is closely related with the concept of Catalan numbers [5]. More precisely, the number of triangulations is equal to:

where n is number of vertices of the polygon and denotes the (n-2)th Catalan number.

Table 1.  The number of triangulations for n=3 up to n=20

n

Number of

triangulations

n

Number of

triangulations

n

Number of

triangulations

3

1

9

429

15

742,900

4

2

10

1,430

16

2,674,440

5

5

11

4,862

17

9,694,845

6

14

12

16,796

18

35,357,670

7

42

13

58,786

19

129,644,790

8

132

14

 208,012

20

 477,638,700

Polygon triangulation problem is a complex problem that requires a complex class for the concrete implementation. In order that this class would be comprehensible, it is necessary to do their analysis. This paper presents an object-oriented analysis and design based on Hurtado-Noy algorithm for triangulation of polygon, that is presented in the paper [12]. OOAD provide a comprehensive insight into the implementation of a this problem. Dealing with the complexity of the same, in this paper we provide alternative views and engineered for the field of OOAD.

We present the analysis and design for mentioned algorithm through three aspects, and respectively we present three types of engineering on the example of solving the problem of triangulation:

Direct development (forward engineering) approach is related to the generation from the UML model (Unified Modeling Language) into the source code of the programming language, in this case in Java. With this approach we present visual planning through UML diagrams.

Feedback analysis (reverse engineering) refers to the interpretation of the source code from the programming language based on UML models.

Synchronization of feedback analysis and direct development (round-trip engineering) refers to the synchronization of source code changes and UML models and vice versa.

The Hurtado-Noy algorithm (Algorithm 1) for triangulation of a convex polygon is described in [12] while implementation in the Java programming language for this algorithm is presented in our paper [6].

Algorithm 1. Hurtado-Noy algorithm

Require: Positive integer n (number of vertices of the polygon)

1: Check the structure containing 2n–5 vertex pairs looking for pairs (ik , n–1), ik ϵ {1, 2, ..., n–2}, 2 ≤ k ≤ n–2,

i.e. diagonals incident to vertex n–1. The positions of these indices ik within the structure describing a triangulation should be stored in the array.

2: For every ik perform the transformation (il , n–1) → (il , n); il < ik , 0 ≤ l ≤ n–3.

3: Insert new pairs (ik , n) and (n – 1, n) into the structure.

4: Take next ik , if any, and go to Step (2).

5: Continue the above procedure with next (n–1)-gon triangulation (i.e. structure with 2n – 5 vertex pairs) if any. Otherwise halt.

Details: Let T(n) be the set of triangulations of an n-gon. Every triangulation t that belong to T(n) has a "father" in T(n-1) and one or more "sons" in the set of triangulations T(n+1). For given set T(n), we can actually generate triangulations of the (n+1)-gon arising from arbitrary triangulation t ϵ T(n). The number of sons of t is dependent on the out degree of the vertex Vn. What we are basically doing is opening the parent polygon and adding in the (n+1)th vertex. We keep all the edges of the parent that did not involve Vn as they were. Next we remove all the edges of the form E (p,n) from the parent and add in E (p, n+1) instead. Thereafter we add in all edges E (p,n) of the parent, where p is a vertex numbered higher than i (remember we are constructing the i-th son).

Figure 1. The way of forming the new triangulation for (n + 1)-gon, according to Hurtado-Noy algorithm

Indeed, we even need the triangulations of the (n–1)th polygon ready. And then we generate d sons for each of those, where d is the degree of Vn of each triangulation. However the hierarchy is nevertheless important because of its inherent simplicity and also owing to the fact that it has a number of really exciting properties which we shall state below (Figure 2).

Figure 2. Levels three to six of the tree of triangulations - Hurtado Noy Hierarchy

This paper is organized as the following. Section 2 contains the UML modeling process for the problem of triangulation of polygons, and gives Java experimental results for the developed software solution. In section 3 method of improving an already existing software solutions is given using advanced techniques for reverse engineering and synchronization of the UML model and Java source code. Also in this section are listed advantages and disadvantages of all three approaches in the implementation process of software solutions for polygon triangulation algorithm.

Forward engineering for polygon triangulation algorithm

The process of modeling project could generally be divided into three phases: identifying problems (a series of tasks that need to be done), theoretical method of finding solution of the problems and solving the problem with the most acceptable method. UML is a language that creates an abstract model of the system through graphical symbols (set of diagrams). UML used to specify, visualize, design and documentation of systems development. General classification of standard UML views (models) can be divided into: static, dynamic and physical model (view). UML modeling has found various applications [7,8,9,10] that cover a wide spectrum of different application domains.

With UML we monitor implementation of the problem of polygon triangulation from abstract ideas through concrete classes, activities, states and behavior of the system, to the physical distribution. UML is based on experiential recognition of objects and their characteristics as well as the distinction of the whole object of its parts. In addition there is a possibility of identifying classes of objects and detecting differences between them. By using certain tools it can be translated into some of the programming languages [15]. In this part of the paper we present the procedure of direct development (forward engineering) on the polygon triangulation algorithm. The very procedure is based on the UML models of the system, starting from the static (class and object Diagrams), over dynamic (use-case, state-chart, activity, sequence and collaboration diagrams) and at the end, of a physical model (components and deployment diagram).

UML diagrams for polygon triangulation algorithm

Class diagram describes the static structure of the system. Classes are modeled and mutually connected using these diagrams, while the objects are described by their attributes and relationships with other objects. Each objects has a number of operations that can be performed, which is modeled by his behavior. In our project, classes that are responsible for generating the triangulations are described (Fig. 3, UML class diagram): GenerateTriangulations, Triangulation, Node, LeafNode, Point and PostScriptWriter.

Mentioned classes are described with the name, attributes and operations. The attributes in this case represent all variables that are declared within a certain class and operations correspond to methods in Java. Relationships provide communication between classes.

The class Triangulation is responsible for displaying a convex polygon triangulation. This class provides the verification of all the vertices of the polygon. Method Draw is located in the class Triangulation. This method is responsible for making an individual triangulation. The method drawLine is used to obtain the appropriate number of vertices to form the regular convex polygon. One combination of internal diagonals forms a triangulation of the convex polygon. The implementation takes respectively those triangulations of internal diagonal which form the triangles inside the polygon provided that they do not intersect. Method DrawAll also belongs to the class Triangulation and it provides iteration where the method Draw is called as many times as it is necessary for a given value n (based on Catalan numbers, see Table 1) in the class GenerateTriangulations. And for drawing regular convex polygons it calls the class Node. The Hurtado method, creates string of objects of the class Node. These are vertices of polygons used to create instances of the class Triangulation with the argument n (number of vertices of the polygon for which is carried out by displaying the triangulation). The main executive method in Java is located in the class GenerateTriangulations and is responsible for the basic input of n parameter.

C:\Users\muzafer\Desktop\class\Class Diagram1.jpg

Figure 3. Class diagram

In the Class Diagram are defined three types of connections: dependency, generalization and association. For a concrete example of the generalization connection we have a Node class in relation to the LeafNode class and this relationship allows the creation of the super-class which combines the structure and behavior that is common to several classes. One of the examples of the depending connection is the relation between Triangulation class and the main class GenerateTriangulations. Dependence is most commonly used when one class uses another one as an argument in the label operation. These operations are further described with behavior and interaction diagrams that together form a dynamic model of the system.

The dynamic model of the system includes two types of diagrams, as follows: behavior diagrams (activities and state chart) and interaction diagrams (sequences and communications). Behavior diagrams emphasize what must happen in the system that is being modeled. Since behavior diagrams illustrate the behavior of a system, they are used extensively to describe the functionality of software systems. Interaction diagrams, a subset of behavior diagrams, emphasize the flow of control and data among the things in the system. All diagrams have a common task, and that is to show the functionality of the system in terms of data flow.

Use Case Diagram is used to represent the functional requirements which the system must satisfy. It is made up of actors and use cases of the system. Within the problem of triangulation of polygons, we can see the following use cases (Fig. 4): generating triangulation, storage (recording) and drawing triangulation.

Use Case Diagram1.jpg

Figure 4. Use case diagram

Figure 4 illustrates the general division of all activities of classes to those that generate triangulation (with drawing and storaging in output file), then those who are responsible for the assignment of appropriate notation or those that store the triangulation in different formats through the JDBC API. In addition to these activities, the last stage is drawing triangulation supported by corresponding Java package for the geometry [19].

Our project for the modeling of Hurtado-Noy algorithm has a total of 47 diagrams, where 36 diagrams are related to the dynamic model (Table 2). Activity diagrams realize methods: createTrinagulation, Hurtado, DisplayTriangulations, Draw, DrawAll, etc. State-Chart diagrams are used to give an abstract description of the behavior for polygon triangulation algorithm. An example of the transition from one state to another is a process of generating a triangulation using appropriate methods for moving into their recording and drawing states. Each of these transition states has three optional parts: alerted event (starting methods for generating triangulation), security criteria (to generate exact number of triangulation which is equal to the Catalan number) and activity (drawing triangulation with their notations). There is a possibility of synchronizing the dynamic diagrams (ie state diagrams with sequence diagrams). A sequence diagram shows object (class) interactions arranged in time sequence and gives a clear display of cooperation between Triangulation class and the main class GenerateTriangulations. Diagram of collaboration or communication refers to the interaction of objects, which serves to show the complex interactions between objects and their interconnections.

Table 2 presents all listed diagrams of our project for analysis and design of polygon triangulation algorithm. All models of the system which are obtained from the developed environment (Visual Paradigm for UML and NetBeansUML), can be downloaded from: http://muzafers.uninp.edu.rs/triangulation/UMLTriang.rar

Table 2.  UML project for polygon triangulation algorithm

Type

UML diagrams

Number of diagrams

Static models

Class diagrams

1

Object diagrams

8

Dynamic models

Use case diagrams

8

Activity diagrams

7

State-Chart diagrams

7

Sequence diagrams

6

Collaboration diagrams

4

Interaction overview diagram

4

Physics models

Deployment diagram

1

Component diagram

1

The physical model is realized through the component diagrams and development diagrams. The component diagram (Fig. 5) represents the structure of the system and describe the dependence of the components of the system. The components of the diagram are the source codes, library, dynamic components and executable programs.

C:\Users\muzafer\Desktop\Component Diagram1.jpg

Figure 5. Component diagram

Deployment diagram (Fig. 6) display the hardware structure of the system, i.e. emphasis is on the communication between hardware and software components (dependency connection <<supports>>). On the software side are implementations to work with methods to triangulate polygons. On the hardware side is Java JDK platform with its components to support implementation of methods.

Figure 6. Implementation diagram

The process of generating source code based on the created model leads to the general structure of a software solution for algorithm (in this case, we chose the Java programming language). NetBeansUML is an addition to the main environment that is used for modeling and code generation based on UML models. In this way we can provide a fast and efficient transfer model in a customizable Java source code.

2.2 Јаva Experimental results

Programming phase is the next step following the procedure of direct development. For implementation we used NetBeans IDE environment for Java. This programming language it gave the best results presented in our paper [6], where we performed a comparative analysis of three programming languages (Java, Python and C++). The Java application contains the central panel, which is the place for the graphical representation of the convex polygon triangulations. All triangulations are drawn on the central panel, based on the selected number of vertices for a polygon.

Table 3 contains CPU times required for generating all possible triangulations of convex polygon. The number n in the table denotes the number of the polygon vertices. PC performance for testing results: CPU - Intel(R) Core2Duo, T7700, 2.40GHz, L2 Cache 4 MB (On-Die,ATC,Full-Speed), RAM Memory - 2 Gb, Graphic card - NVIDIA GeForce 8600M GS.

Table 3.  Execution time for the Java application

Num. of vertices

Number of triangulations

Execution time (sec.)

File output size (Kb)

5

5

0.3

2

6

14

0.5

3

7

42

0.7

11

8

132

0.9

39

9

429

1.2

156

10

1430

2.9

624

11

4,862

4.1

2463

12

16,796

5.8

9879

13

58,786

15.2

38844

14

 208,012

46.34

156916

Therefore, it can be observed that increasing values of n the Java application increases the number of generated triangulations per second (Graph 1). The vertical axis of the graphical representation contains the number of displayed triangulations per second while the horizontal axis contains values for n.

Graph 1. Number of generated triangulation per second for n={5,6,...,14}

Java application can be downloaded from the address: http://muzafers.uninp.edu.rs/triangulation/Hurtado.rar

Reverse and Round-trip engineering: Maintenance and Evolution of software solution

In the process of maintenance and evolution of software solutions, reverse engineering has a key role. This section provides a procedure for the feedback analysis and the ability to synchronize the implementation of algorithm for triangulation, which turned out to be the best solution. Reverse engineering and visualization of source code lead to improved program comprehension. The main advantages are: learning unfamiliar code, code reuse, software maintenance, change impact analysis, integrating open source code, etc.

The practice of reverse engineering in software system, contributes to a better understanding of the system implementation and the maintenance. The feedback analysis process refers to activity that improves the understanding of the problem, prepares and improves the implementation and enables the reuse or evolution. The main goal of reverse engineering is to create a more abstract view of the system. The reverse engineering starts with classifying the complete source code in the formal units (class). The paper [13] presents code reverse engineering problem for identification codes. The authors of the paper [11] describe some of the most advanced techniques that can be employed to reverse engineer several design views from the source code (inputs: source or executable code, outputs: design and specifications as an aid in the maintenance or creation of a new version of the program). Paper [14] proposes reverse engineering sequence diagrams from enterprise Java Beans with interceptors.

Process of reverse engineering is applied for the implementation of a polygon triangulation problem through two phases: (1) Based on the source code we get a static model (general and class view); (2) On the basis of modeled attributes and operations their descriptions are further decomposed into activity, state or sequence diagrams.

Synchronization of direct development and feedback analysis (round-trip engineering) is a good practice in the analysis and maintenance of the implementation [16,17,18]. Its benefits are directly related to the change of the source code from UML model, or vice versa. This procedure is useful for the implementation that has common classes for generating triangulation of polygon, where the only change is some of the methods. The goal of presented project is to build a set of tools that makes it possible to move between a UML model and Java source code during development without having to update duplicated information by hand.

Example 1: For synchronizing UML project and Java project for triangulation polygon, NetBeansUML module will log various lines of text to the Output Window as follows: "Initial reverse engineering into a new project: Begin processing Reverse Engineering, Parsing 56 elements, Analyzing attributes & operations for 72 symbols, Resolving 54 attribute types, Integrating 72 elements, Building the query cache...". The resultant output describes the operations that took place: 72 model elements were used to generate 56 Java source code files or vice versa.

C:\Users\Muzafer\Downloads\Sheme (1).jpg

Figure 7. Synchronization of direct development and feedback analysis

Table 4 presents the fulfillment requirements in the process of synchronizing UML project and Java project for triangulation of polygon.

Table 4. Requirements in the round-trip engineering

 

REQUIREMENTS

Triangulation

(Main Class)

Generate

Triangulation

Note

Triangulation

Draw

Triangulation

1

Navigate to Source









2

Generate Dependency diagram









3

Generate Code









4

Generating report









5

Element Navigation









6

Refactoring in synchronizing





 

7

Find and Replace in UML model





 

 

8

Apply design pattern



 

 

 

9

Manipulation with A, O, I and R*









10

Filter in Model



 





*A - Attributes, O - Operations, I - Implementation, R – Relationships

In the NetBeansUML module there is the possibility of automatic detecting source code if it is properly set up the synchronization between the UML design and Java NetBeans project (requirements 1,2,3,5 and 9 from Table 4). In this way it reduces the complexity of the triangulation problem and programming and adding new functionality of the system is facilitated. For the reverse and round-trip engineering process it is important to mention the procedure for generating a report of the model which describes all the classes and the use of packages, interfaces and data types in the problem implementation (requirement 4).

The main categories of reengineering are automatic restructuring and automatic transformation. The first category refers to the application of standards and coding, which is applicable in order to obtain the source code readability. The second category refers to refactoring and re-modularization that is applied with the aim of obtaining a better source code (requirement 6). Refactoring changes the internal structure of the software in order to be easier to understand and simpler to modify, without visible changes of his behavior. Before the code refactoring it may notice that a source code is in a messy, where is necessary to eliminate duplicate code and after code refactoring, code becomes clearer, with greater simplicity, flexibility and clarity. Actions that we implemented in our project in the procedure of code refactoring are: extract and move method, class and super-class, extract interface, use super-type where possible, creating a template method and encapsulate fields.

4.1 Improving of software solution

Some of the advantages of reverse engineering and synchronization of direct development and feedback analysis to solve the problem of triangulation can be observed from:

The complexity of the problem, better understanding of the classes and their methods, identifying interdependencies, ways of communication and data flow. Hence, given technique offers the possibility of generating alternative views of the problem.

Source code analysis obtained through several models (primarily static and dynamic) allows you to see the problem from the aspect of expandability of the source code (adding new methods), possibilities of simplification of methods, redefining the methods and synthesis and analysis methods. In this way they can link certain implementation on the basis of their dynamic and static models. This allows the detection of secondary occurrences and repeated cases.

After reducing the complexity of the problem and simplifying the source code we achieved better results concerning the speed of generating a triangulation per second.

An important step before implementing the new feature is to refactor the relevant parts of the application in order to make the change easier to implement (and more understandable). To make the refactoring process easier and more effective, it's probably a good idea to locate and remove code or modules that not used anymore. In process of code review for Hurtado-Noy algorithm, module "Unnecessary Code Detector" in NetBeans recognizes following:

Unused imports (4.09%)

Unread local variable (6.02%)

Unread parameter (6.18%)

Unnecessary method or constructor (6.23%)

Unread private method/constructor, type (7.87%)

Unread local or private members (7.57%)

Table 5 presents the results of improving software solutions for the Hurtado-Noy algorithm. Data are presented (before and after) for three criteria: the number of lines of source code, the size of java file (in bytes) and measuring time (speed) in seconds (individually for each java file), for n={5,..,14}, cumulative.

Table 5.  Improvement of source code for Hurtado-Noy algorithm

Java file

#line (before)

#line (after)

#bytes (before)

#bytes (after)

#speed (before)

#speed (after)

Action performed

Triangulation.java

79

67

2275

1715

29.12

26.14

1,2,3,4,5,6

GenerateTriangulation.java

222

195

8544

7194

37.56

34.33

1,2,3,4,5,6

Node.java

45

41

745

578

4.51

4.01

2,3,4,5

LeafNode.java

27

19

342

216

3.21

2.85

2,3,4,5

Point.java

10

9

134

112

1.52

1.51

2,3,4

PostScriptWriter.java

56

55

1830

1791

2.74

2.62

2,3

TOTAL

439

386

13870

11606

78.66

71.46

 

Improvement (%)

13.73

19.51

10.08

Graph 2 shows the percentage improving of the source code for three criteria individually for each segment of implementation.

Graph 2. Improving (%) of software solution for Hurtado-Noy algorithm

Summary of the three approaches and Conclusion

This paper outlines the key advantages of object-oriented analysis and design in solving of polygon triangulations who is a fundamental algorithm in computational geometry. Table 6 shows the identified advantages and disadvantages of all three approaches in the implementation process of software solutions for polygon triangulation algorithm.

Table 6.  Advantages and disadvantages of three approaches

ENGINEERING

Advantages

Disadvantages

FORWARD

Multi-dimensionality of the system and the high level of abstraction

Efficient transparency of the system structure

Spotting the functional wholes

Generating the source code

A large number of steps (small transformation)

REVERSE

Analysis and interpretation of the implementation problems

Logical design and better visibility of source code

Disassemble of Java code

More effective maintenance of a software solution

There is insufficient support for a higher level of abstraction

ROUND-TRIP

Synchronized changes from model to source code or vice versa

Generate reports that describe class (graphic and program description)

Combining the advantages of the first two approaches

Deviation and changes of the source code in relation to models or vice versa

As a best practice proved to be the synchronization technique that combines Java programming and UML modeling. Presented synchronization procedure combines the advantages of two approaches: reverse and forward engineering. First approaches has the advantage of generating the source code in some of the object-oriented programming languages, while reanalysis technique aims to describe the implementation of the problem through various aspects. The suggested process is suitable for the implementation of some other algorithms from the field of computational geometry. Techniques of OOAD may be a new approach for solving and analyzing related problems.



rev

Our Service Portfolio

jb

Want To Place An Order Quickly?

Then shoot us a message on Whatsapp, WeChat or Gmail. We are available 24/7 to assist you.

whatsapp

Do not panic, you are at the right place

jb

Visit Our essay writting help page to get all the details and guidence on availing our assiatance service.

Get 20% Discount, Now
£19 £14/ Per Page
14 days delivery time

Our writting assistance service is undoubtedly one of the most affordable writting assistance services and we have highly qualified professionls to help you with your work. So what are you waiting for, click below to order now.

Get An Instant Quote

ORDER TODAY!

Our experts are ready to assist you, call us to get a free quote or order now to get succeed in your academics writing.

Get a Free Quote Order Now