Home Developer Source line of code (SLOC) - what's best for productivity?

Source line of code (SLOC) – what’s best for productivity?

Author

Date

Category

“Measuring programming progress by lines of code is like measuring aircraft building progress by weight.”

– Bill Gates

This discussion of SLOC, or, source line of code (which is also known as lines of code, or, LOC) — is a measure of the number of lines of the program’s source code. It is also an answer to a question on Quora and is  part of our ebook on code quality metrics.

There are at least two different measures of SLOC:
The “physical” SLOC. That’s the total number of lines in the source code. The “logical” SLOC. That’s the number of lines that will be executed.

Intuitively, all developers understand that the higher the SLOC, the larger the number of potential bugs, the higher the maintenance costs, the efforts to develop new features, and so on. The problem is that it’s not possible to standardize or benchmark this metric in any meaningful way: a change in SLOC in itself says nothing about code quality, or developer productivity. To make matter worse, and despite the simplicity of its de nition, there is no consensus on how to measure SLOC. So different static analysis tools will provide different values. Developers therefore cannot use it to make comparisons or draw conclusions.

Although we’re not big fans of SLOC as a standalone metric, if you have to use it, then use the “logical” SLOC. Another practice which we nd useful
is to standardize SLOC by measuring SLOC per le (or per class). When the SLOC per le is far from the average, this is often a ag that something has to be reviewed.

What other metrics should you follow?

I personally think that a much better metric to express productivity is through number of PRs merged or the average time to close of PRs produced by a developer.

There are of course many other traditional metrics that you can track and follow like Cyclomatic complexity, Code churn, Code coverage, Code duplication, etc

If you’re curious about code quality metrics, you can read more about them on our ebook:

SLOC metric


About Codacy

Codacy is used by thousands of developers to analyze billions of lines of code every day!

Getting started is easy – and free! Just use your  GitHub, Bitbucket or Google account to sign up.

GET STARTED

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Subscribe to our newsletter

To be updated with all the latest news, offers and special announcements.

Recent posts

Introducing Pulse to help companies achieve elite engineering performance

At Codacy, we envision a future where everyone can impact the world by crafting complex software with confidence and focus at the speed of...

First QA Engineer in a Startup

This is the story of how I joined a startup as the first QA Engineer in the company.  My name is Bruno Medley, I'm a...

Is your code secure with Codacy?

If you have been in the development business, you are well aware of the fact that data breaches are a part of the development...

8 Common Software Development Mistakes and How to Avoid Them

The world of software development is fast-paced and ever-changing. The queue of feature requests never seems to shrink. With the constant demand for improvements, adherence...

The Bundling and Unbundling of the DevOps market

The DevOps market continues to grow1: The global development and operations (DevOps) market size stood at USD 3,709.1 million in 2018 and is projected to...