1.代码行(LOC):
代码行(LOC)度量标准是代码中不是注释行或空白行的任何文本行,无论哪种情况,该行中的语句数或语句片段数都应为。 LOC显然由包含程序头文件,任何变量的声明以及可执行和不可执行语句的所有行组成。由于代码行(LOC)仅计算代码的比例,因此您只能利用它来比较或估算使用相同语言并使用相同编码标准进行编程的项目。
代码行示例:
C++
void selSort(int x[], int n) {
//Below function sorts an array in ascending order
int i, j, min, temp;
for (i = 0; i < n - 1; i++) {
min = i;
for (j = i + 1; j < n; j++)
if (x[j] < x[min])
min = j;
temp = x[i];
x[i] = x[min];
x[min] = temp;
}
}
因此,现在,如果LOC只是行数的计数,那么上面显示的函数包含13行代码(LOC)。但是当注释和空白行被忽略时,上面显示的函数包含12行代码(LOC)。
2.函数点(FP):
在函数点指标中,软件保留的功能数量和类型用于查找FPC(函数点计数)。
函数点示例:
查看本文以获得详细示例:函数点(FP)的计算
函数点和LOC都是软件大小的度量单位。为了准确估算项目的工作量,成本和持续时间,必须依赖于开发的软件大小。大多数参数估计模型(例如,建设成本模型(COCOMO))都接受FP或LOC中传达的规模作为输入。
LOC和函数点之间的区别:
Function Point (FP) | Line of Code (LOC) |
Function Point metric is specification-based. | LOC metric is based on analogy. |
Function Point metric is language independent. | LOC metric is dependent on language. |
Function Point metric is user-oriented. | LOC metric is design-oriented. |
Function Point metric is extendible to Line of Code. | It is changeable to FP (i.e, backfiring) |
Function Point is used for data processing systems | LOC is used for calculating the size of the computer program |
Function Point can be used to portray the project time | LOC is used for calculating and comparing the productivity of programmers. |
通常,出于一个非常重要的原因,人们更喜欢表示为函数点的软件的功能大小,即,在任何情况下,无论使用哪种语言,使用函数点度量表示的大小都保持恒定。