There are several metrics you can deploy to analyze the code size and quality of an application. One of the popular metrics that you can be used is called Lines of Code, also known as LoC. If you are keen to learn more about what LoC means and why it is metric is programming, this article is for you.
Lines of Code or LoC is a method used to measure the size of an application by identifying the actual count of Lines of Code it has. For instance, small software projects usually have somewhere between 500 to 5000 Lines of Code, whereas large ones can have thousands or even millions of Lines of Code (LoC).
Estimating the size of a project:
Usually, the size of a software project can be estimated based on the lines of code it has. It is one of the metrics clients can use to determine how much they can pay for a particular software project.
Any software project will always have code units like classes and functions. Usually, the functions and classes that have several code lines tend to be harder to read or understand than those. So, it is usually best to split up such classes or functions to make them smaller for easy understanding and readability.
LoC is among the most reliable parameters that are used to assess the quality of a software program. You will often realize that most experienced developers usually write less code than amateurs even when the project they are working on is the same.
An efficient language requires writing less code to accomplish a task that would need to write several lines of code if written in another language that is less efficient.
There are two common methods used to measure this parameter that is; physical and logical methods. Here is how the two defer
Physical Lines of Code:
With this method, the lines of code are physically counted while
excluding comments and white spaces.
Logical Lines of Code:
This method measures only the number of executable statements in the code.
Let us use an example below to differentiate between these two;
for (i = 0; i< 100; i++)
In this illustration above this code, the segment has four physical lines of code and two logical ones. The logical lines of code are; the for statement and the print statement.
It is easy and intuitive
Integrated into most code editors
Not a reliable metric to measure a programmer's productivity
The LoC also differ based on the experience of a developer
The LoC will also vary based on the programming language used
It does not have a counting standard.
One of the mistakes that clients and some project supervisors who are not familiar with programming make is using LoC as a metric to measure a programmer's productivity. However, using this metric will not give the right picture because the time spent coding usually varies based on how complex the project is and the experience of the programmer.
This parameter is crucial when it comes to assessing the size and quality of software or code segments. However, it would be misleading to use this parameter to measure a programmer's productivity or the progress of a particular project.
Using LoC alone to measure these two parameters is misleading because different project segments vary in complexity and take different amounts of time to accomplish, so the number of LoC written usually doesn't matter.