Lines of code (LOC)

One such software metric is lines of code (LOC), also known as source lines of code (SLOC). This measurement simply represents the size of a software system by determining the number of lines in its source code.

Typically, software systems with more lines of code are greater in complexity and more difficult to maintain than those with fewer lines of code. However, comparisons of LOC between different software systems are really only useful if they involve an order of magnitude difference in lines of code. For example, if one software system has 50,000 lines of code, and another has 48,000 lines of code, you won't be able to make a determination on which software is more maintainable. However, if you were to compare a software system with 10,000 lines of code with one that has 100,000 lines of code, then you are more likely to make a useful determination.

Development tools and integrated development environments (IDEs) can count the number of lines of code for you. However, there are different ways that it can be calculated, and it is debatable which is the most useful. There is also a challenge if a software system uses multiple languages.

The two major ways that it can be calculated are the physical LOC and the logical LOC. The physical LOC typically is just a count of all of the source code lines, excluding comment lines. The logical LOC takes into consideration the actual number of program language statements in an attempt to only count effective lines of code. While the physical LOC is easier to calculate, it is more sensitive to being affected by such things as line spacing and other formatting.