PROJECT: Technology Transfer from C/C++


Overview

This project is part of the requirements for the course COM3360 being taught by Prof. Karl Lieberher at Northeastern University. This course is taken through the NTU, National Technological University, program. The purpose of this project was to develop a Demeter/Java program from a C++ program and demonstrate whether there are benefits (less code, shorter development time, more reuseability) resulting from this conversion. This project helped in developing my own understanding of how to use Demeter/Java successfully in place of C++.

The program chosen was a software engineering project that was developed for another course, first in simple C and then in C++. The progression to Demeter/Java seemed a natural next step. Since Java and C++ are very similar in syntax and structure it was unnecessary to convert from C++ to Java code before implementing the Demeter/Java. This turned out to be a valid decision. Converting straight from C++ to Demeter/Java was fairly easy. Actually, the C++ program did not convert directly to Demeter/Java - I just used the logic of the original program and developed different methods of doing the same tasks using traversals and visitors.

Data is read in from three input files containing information about insurance agents, customers and what policies they had purchased and transactions to perform on this data. The format of the input files was specific and the files used are agent.input, insuree.input and trans.input. More details on the format of these files plus other information can be found in the README file for this project. The class dictionary is found in project.cd and the behavior code is found in project.beh.


Project Author

Karen Yahle email: kareny@lexis-nexis.com
Senior Software Engineer, Lexis Nexis, Dayton, Ohio.


Tasks

TASKSDescription
Study the Problem Study and analyze the original program and determine a series of small incremental tasks to implement in Demeter/Java.
Define Use Cases Describe possible use cases for the project.

Define Growth Plan Simplify the the structure of the project into several phases to be worked on step by step, building complexity upon proven functionality.
Implementation After use cases and the growth plan are determined, start to experiment with simple tasks and add complexity as each previous task is successful.

Use Cases

The use cases for the Insurance Database program.

Use CasesDescription
Simple Input The first use case will be to read in and print out the agent list only. Following that, the insuree list will be read in and printed and finally the transactions will be handled. This use case deals only with input and output functionality.
Handle the Simplest Transaction (#1) Implement functionality to handle the simplest of the transactions, experimenting with and refining traversal strategies.
Handle the next Hardest Transactions (#3,4,5) Implement functionality to handle transactions that have an additional query field which is used to refine the transaction. These transactions use the data in the query field (ie. a policytype, a premium amount, an agent name) to fing matches in the agents and/or insurees lists.
Handle the More Complicated Transactions (#2,5) These two transactions require traversing both the agent and insurees lists multiple times to match, extract and tally data and print results.

Growth Plan

Start with simple input/output tasks, verify correctness and slowly build upon it, adding progressively more complex transactions one at a time.

Growth StepsDescription
Phase I Develop the functionality to handle the input files and to output the lists.
Phase II The code to handle transaction #1 - the simplest transaction is implemented and used on which to base the other transactions.
Phase III Transactions 3, 4, and the 5 are implemented. These have somewhat similar functionality with query fields which are read in from the input file and used to process the agent and/or insuree lists.
Phase IV The last two transactions, number 2 and 6 are implemented last since they are similar to each other and are the more complicated ones - traversing the lists looking for and tallying up information as required.

Summary

The size of the code for Demeter/Java implementation was significantly less than for the "C" implementation and the "C++" implementation. This can be seen in the table below. Development time is estimated at about 25 hours and with more experience that time would probably have been cut in half, since each incremental change required recompilation and retesting, often with an error popping up. The strategies I used in the code of defining separate traversals and visitors for each different transaction could probably be refined by using inheritance and in-lining. The end product works as intended but feels a bit cumbersome - I think the code could be made more elegant and reuse implemented more often. Overall, though, I felt that the program lent itself well to the use of Demeter/Java. As mentioned, the original program required a number of parsing functions to be developed, which were taken care of by Demeter/Java for me. That was very nice!


Comparison

LanguageSize : lines and bytes of code
Demeter/Java Totals of project.cd and project.beh: lines - 487, bytes - 15435
Simple C Totals of insuranceDB.c and insure.h: lines - 1514, bytes - 53393
C++ Totals of insure.C and insure.h: lines - 1677, bytes - 46127