Lines of Code
Lines of Code ( LOC for short ; English for code lines in the sense of the number of program lines; English source lines of code , SLOC ) is a term from software technology . It is a software metric ; H. a measure to describe the size of a code base of a computer program or its growth. In the simplest case, the Lines of Code are the number of lines of the source code that make up the program.
This metric does not allow any direct statements about the efficiency of the programmer , because the number of lines depends on a wide variety of factors: chosen architecture, experience of the programmer, chosen solution, formatting of the source code, programming language used, etc. In addition, the 80/20 rule states , that 80% of the lines are written 20% of the time. Thoroughly testing a program can take a lot of time, while the number of changed or added program lines is very small.
Usually, productivity - including all project activities - of 10 to 50 lines of code per employee and day is expected. A software development project with a total effort of 1,000 person-days (~ 5 person-years) should have produced between 10,000 and 50,000 lines of code.
Calculation types
Lines of Code have a number of common characteristics which are explained using the following example:
1 /* Wie viele Zeilen sind das? */
2 public void ausgabeEinsBisHundert() {
3
4 for (int i = 1; i <= 100; ++i) {
5 System.out.print(" " + i); //hier die Ausgabe der Zahlen aus der Schleife
6 }
7 }
- Lines of Code (LOC)
- Also called physical lines of code. Number of lines including blank lines and comments. In the above example 7. Is often mentioned as a representative of one of the other types of calculation.
- Source Lines of Code (SLOC)
- Number of lines of code without blank lines and comments. In the above example 5.
- Comment Lines of Code (CLOC)
- Number of comment lines, whereby it is not defined whether lines with code and comments are also included. In the example above, this means 1 or 2.
- Non-Comment Lines of Code (NCLOC)
- Also called Non-Comment Source Lines (NCSL) or Effective Lines of Code (ELOC). Number of lines of code without blank lines and comments without headers and footers. Header and footer are in particular the outer opening and closing brackets as well as (at class level) import / include statements and (at method level) method declarations. The above example has NCLOC at method level 3 and class level 5.
- Logical Lines of Code (LLOC)
- Also called Number of Statements (NOS). Counts the number of instructions . Is used, for example, at COCOMO . In the above example 2. In the C programming language, however, the instructions in for loops are independent instructions. In C the above example would have 4 LLOC.
use
Most comparisons of programs across the LOC only look at the orders of magnitude of the number of lines in different projects. Computer programs can consist of as little as a few dozen to hundreds of millions of lines of program. The scope of a program in lines of code does not necessarily have to allow conclusions to be drawn about the complexity or functionality of the program, since the use of external frameworks and program libraries , the programming language used and also the formatting of the source text have a major influence on the lines of code. In particular, conclusions about the invested working time are usually meaningless.
Even when using Logical Lines of Code (LLOC), understanding what is meant by an instruction and how its complexity is to be assessed depends on the programming language used. For example, in an assembler source code comprising several screen pages, the same program can ultimately be formulated as in a few lines of a high-level programming language .
Depending on the programmer and the formatting guidelines used, the above example can be reformulated in the following source code that is completely equivalent in terms of programming:
1 /* Wie viele Zeilen sind das? */
2 public void ausgabeEinsBisHundert() {
3 for (int i = 1; i <= 100; i++) System.out.print(" " + i); // hier die Ausgabe der Zahlen aus der Schleife
4 }
The source code now consists of four physical lines of code (LOC), three SLOC, depending on the calculation, one or two Comment Lines of Code (CLOC), a Non-Comment Line of Code (at method level) and two logical program lines (LLOC).
Since the reduction in code lines made here has reduced readability, the complexity of the program has been increased, which in turn has a negative influence on productivity. Fewer lines of code can therefore result in higher costs.
The size of Lines of Code may be a. Also used to calculate the error density of a program: Depending on the application and also depending on the programming language , a certain amount of program errors should not be exceeded, e.g. B. max. 0.5 errors per KLOC (= kilos = 1000 LOC) in military or hospital systems.
Examples
Here are some examples of the number of lines of program code in different operating systems and application programs .
Publishing year | system | SLOC in millions |
---|---|---|
Operating system kernel | ||
1983 | Multics - Kernel | 0.25 |
1994 | Linux kernel 1.0 ( i386 only ) | <0.2 |
1996 | Linux kernel 2.0 ( IA-32 , Alpha , MIPS , SPARC ) | 0.72 |
1999 | Linux kernel 2.2 | 1.7 |
2001 | Linux kernel 2.4 | 3.2 |
2003 | Linux kernel 2.6.0 | 8.1 |
2005 | XNU 792.x ( Darwin 8.x or Mac OS X 10.4 ) | 2 |
2011 | Linux kernel 2.6.39 and 3.0 | 14.5 |
2012 | Linux kernel 3.2 LTS | 15th |
2012 | Linux kernel 3.6 | 15.9 |
2015 | Linux kernel 4.2 | > 20 |
2018 | Linux kernel 4.15 | 25.3 |
entire operating systems | ||
FreeBSD | 8.8 | |
OpenSolaris | 9.7 | |
1993 | Windows NT 3.1 | 4-5 |
1994 | Windows NT 3.5 | 7-8 |
1996 | Windows NT 4.0 | 11-12 |
2000 | Debian GNU / Linux 2.2 | 55-59 |
2000 | Windows 2000 | > 29 |
2001 | Windows XP | 40 |
2002 | Debian GNU / Linux 3.0 | 104 |
2003 | Windows Server 2003 | 50 |
2005 | Debian GNU / Linux 3.1 | 215 |
2005 | Mac OS X Tiger (10.4) | 86 |
2007 | Debian GNU / Linux 4.0 | 283 |
2007 | Windows Vista | 50 |
2009 | Debian GNU / Linux 5.0 | 324 |
2009 | Windows 7 | 40 |
Other software | ||
1983 | Lotus 1-2-3 1.0 | 0.02 |
1989 | Lotus 1-2-3 3.0 | 0.4 |
2007 | SAP NetWeaver 2007 | 238 |
literature
- SH Kan. 2002. Metrics and Models in Software Quality Engineering . 2nd edition. Addison-Wesley.
- Harry Sneed , Richard Seidl , Manfred Baumgartner: Software in numbers - the measurement of applications . 1st edition. Carl Hanser Verlag , 2010, ISBN 978-3-446-42175-2 .
Individual evidence
- ^ Steve McConnell: Code Complete A Practical Handbook of Software Construction . 2nd Edition. Microsoft Press, 2004, ISBN 978-0-7356-1967-8 , 20.5 The General Principle of Software Quality, pp. 514 (English): "The industry-average productivity for a software product is about 10 to 50 of lines of delivered code per person per day (including all non coding overhead)."
- ↑ Prechelt: SWT2 chap. 1.5 Measurements and dimensions. FU Berlin, October 1, 2012, accessed on March 19, 2020 .
- ↑ Tom Van Vleck, John Gintell, Joachim Pense, Monte Davidoff, Andi Kleen, Doug Quebbeman, Jerry Saltzer: Multics Myths. ( Wiki ) In: Multicians. Retrieved May 21, 2020 (English).
- ↑ Amit Singh: Mac OS X Internals: A Systems Approach . Addison-Wesley Professional, 2006, ISBN 978-0-13-270226-3 , 2.4 ( online ): "The Darwin xnu package consists of roughly a million lines of code, of which about half could be categorized under BSD and a third under Do. The various kernel extensions, not all of which are needed (or loaded) on a given system, together constitute another million lines of code. "
- ↑ Greg Kroah-Hartman, Jonathan Corbet, Amanda McPherson: Linux Kernel Development: How Fast it is Going, Who is Doing It, What They are Doing, and Who is Sponsoring It. (PDF; 0.6 MB) Linux Foundation , March 2012, accessed January 8, 2013 .
- ↑ Thorsten Leemhuis: The innovations of Linux 3.6. In: Heise online . October 1, 2012 . Retrieved May 2, 2013.
- ↑ Thorsten Leemhuis: Linux kernel breaks the 20 million line mark. In: Heise online . June 30, 2015 . Retrieved July 1, 2015.
- ↑ Thorsten Leemhuis: The innovations of Linux 4.15. In: Heise online . February 12, 2018 . P. 9: Outlook on 4.16, scope of changes & changelog. Retrieved May 27, 2020.
- ↑ a b c d e f How Many Lines of Code in Windows? Knowing.NET, December 6, 2005, accessed May 14, 2014 .
- ↑ Jesús M. González-Barahona, Miguel A. Ortuño Pérez, Pedro de las Heras Quirós, José Centeno González, Vicente Matellán Olivera: Counting potatoes: the size of Debian 2.2. (No longer available online.) January 3, 2002, archived from the original on July 4, 2008 .
- ↑ a b c d e Gregorio Robles: Debian Counting. (No longer available online.) Archived from the original on March 14, 2013 .
- ↑ Steve Jobs : Live from WWDC 2006: Steve Jobs Keynote. August 7, 2006, accessed on February 16, 2007 (English, probably also contains a few application programs.): "86 million lines of source code that was ported to run on an entirely new architecture with zero hiccups"
- ↑ a b Mark Wilson: Infographic: How Many Lines Of Code Is Your Favorite App? In: Fast Company magazine online. November 7, 2013, accessed on May 29, 2020 (English): "Windows Vista (2007), for instance, had 50 million lines of code, while Windows 7 shaved that figure down to 40 million."
- ↑ a b Detlef Borchers: 30 years ago: The first killer application. In: Heise online . January 28, 2013 . Retrieved June 14, 2020 .; Quote: "If the first 1-2-3 had less than 20,000 lines of code, version 3 came with 400,000 lines."
- ↑ What SAP says about ABAP's future. Retrieved November 20, 2011 .