Code Quality Measurement : A method to calculate CSI ( Changed Source Instruction) for XSL (Extensible Stylesheet Language)
Original Publication Date: 2005-Aug-02
Included in the Prior Art Database: 2005-Aug-02
Lately, most of the systems are developed by making use of existing base code, rather than building them from scratch. Changes are applied to the base code, to implement the new system's specification. One of the widely accepted metrics for this purpose is to calculate the number of lines of changed source code. Developers are measured by the Lines of Code (LOC) changed, which is called the CSI (Changed Source Instruction). In some language, this can easily be implemented due to its nature, i.e. 1 line of code is indicated by the semi-colon sign ";". Thus CSI can be calculated by calculating the number of lines of code added, deleted or changed. However, this is not the case for XSL files. There is a lack of metrics definition and calculation tool for XSL. There is no clear definition of a line of code in a XSL file. The common practices in the time being are : a. To regard 1 Line of Code as 1 line contained in the physical file, thus the LOC is the number of lines the file contains. The CSI is then calculated by subtracting the LOC of the older and newer version files. b. To compare the 2 versions of files line by line, by using comparison tools, and to calculate the number of lines changed. Thus, both approaches are very questionable since developers can just separate one line of logic into different lines, just to get a big number for his/her performance. In summary, currently there isn’t any clear definition of a Line Of Code (LOC) for XSL files. In addition to that, there isn't metrics / performance indicator, nor tools to calculate CSI for XSL files.
Code Quality Measurement : A method to calculate CSI ( Changed Source Instruction ) for XSL (Extensible Stylesheet Language )
The core idea of this invention is to define logical definition of one line of code of a XSL file. Given this definition, this invention discloses the way to calculate the Shipped Source Instruction (SSI) of an XSL file.
In principal, an XSL file is an XML file. Consider Program C and Program D below. Both programs represent 1 logical unit of code. Each of them is one element. Therefore, we are defining that 1 Element = 1 Line of Code in XSL file.
Due to the nature of an XSL file, which is basically an XML file, therefore any XML parser will be able to read the file and construct XML Document(s) from a XSL file. Since each XML Document is similar to a tree, thus we can traverse the tree to calculate the number of added, deleted or changed elements .
The CSI of a XSL file is the added, deleted or changed LOC the file contains, i.e. the number of elements added, deleted or changed in its Document(s).
The advantages of using this approach, compared to the current manual approaches are the following :
- Although an element is written into a number of rows in the XSL file, it will still be regarded as 1 line of code, thus developers will not gain from doing so. This provides a fair calculation for all parties involved.
- Comments are automatically not counted into account, providing a more accurate number . - Self-contained elements are taken into account, which provides more accurate calculation, as well.
- Due to the nature of this approach, much information can be obtained as the tree is being traversed. Thus, more code analysis can be built into this tool in future. For example, code complexity calculation which may be based on the number of nested elements or the number of attributes, etc . This may call for another invention disclosure.
After constructing tree(s) from an XSL file, we need to traverse them using Depth First Search Method. The flowchart below depicts the process.
XSL Metrics - CSI Calculator Flowchart Using Depth-First Tree Traversal Method
With LRV approach
Below is the step description of the flowchart.
Step # Description
1 Start by getting Documents from XSL file (for both old and new XSL files, w...