Abstract
A reconfigurable expert system that can be used as a software metrics tool is being developed. The system will critique a source program and produce comments discussing features of the program. Initially, the programs that will be critiqued are student Pascal programs from beginning and intermediate level programming courses. The comments produced are intended to help direct students to produce code that is well structured and readable. This system does not deal with how a program is formatted; that is, the system does not deal with concerns such as blank lines, comment contents and indentation of code.The system is being implemented in Prolog because of its use as a language for creating expert systems and its ability to allow the creation and use of generic data structures. The system has two distinct components. The first component is a source language preprocessor and the second is a rule database that generates comments and listings. The source language preprocessor parses the source program creating a database of Prolog facts and possibly rules that will be used by the rule database. The rule database applies predefined rules about programming style to the database created by the preprocessor and generates a listing of the original program with comments about the style of the program.There are two sets of rules used by the rule database. The first set describes features common to most Algol-like high-level programming languages. This generic set of rules is always used by the rule database. The second set of rules describe language-specific rules to be used when a particular source language is used. Each source language will have its own unique database of rules. The language to be parsed and used by this system is determined by the first fact generated by the preprocessor. This means that only the preprocessor routine needs to know the source language. The backend processor will consult the file determined by the preprocessor for the language specific information. This feature allows a great deal of flexibility in the system. A diagram of the system is presented in Figure 1.Two approaches were considered for implementing this system. The first approach was an implicit graph scheme which is a database scheme for storing and processing the source program. This is the approach adopted for my implementation. I chose this scheme because it was in keeping with the basic structure of Prolog as a language. The second approach involved an explicit graph scheme. This approach has been considered for a future implementation of this system for comparison purposes.The metrics under consideration for this system include control and data flow metrics. Beyond the software metrics that will be studied, style considerations will also be investigated. One style consideration studied will be the length of variable names. For example, if a variable name is less than a predefined length and is not a loop index variable, then a comment that suggests the use of a more descriptive variable name will be made. Another consideration that will be investigated is the use of IF THEN ELSE statements. The system will determine if the use of the IF THEN ELSE construct was justified or if an assignment statement could have been used more efficiently. An example of this is shown in Figure 2. The system will suggest the more elegant solution shown in Figure 3.This system will have a wide range of abilities. It will support a variety of metrics which are easily modifiable to meet the needs of the person using this system. It will be easily reconfigured to a source language by using different preprocessor and language specific rule files. Hopefully, this system will help students to produce more efficient and readable programs.
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.