Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Source lines of code
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Measurement methods== Multiple useful comparisons involve only the [[order of magnitude]] of lines of code in a project. Using lines of code to compare a 10,000-line project to a 100,000-line project is far more useful than when comparing a 20,000-line project with a 21,000-line project. While it is debatable exactly how to measure lines of code, discrepancies of an order of magnitude can be clear indicators of software complexity or [[man-hour]]s. There are two major types of SLOC measures: physical SLOC (LOC) and logical SLOC (LLOC). Specific definitions of these two measures vary, but the most common definition of physical SLOC is a count of lines in the text of the program's source code excluding comment lines.<ref>{{citation |url=http://sunset.usc.edu/csse/TECHRPTS/2007/usc-csse-2007-737/usc-csse-2007-737.pdf |title=A SLOC Counting Standard |author1=Vu Nguyen |author2=Sophia Deeds-Rubin |author3=Thomas Tan |author4=Barry Boehm |publisher=Center for Systems and Software Engineering, University of Southern California |year=2007 }}</ref> Logical SLOC attempts to measure the number of executable "statements", but their specific definitions are tied to specific computer languages (one simple logical SLOC measure for [[C (programming language)|C]]-like [[programming language]]s is the number of statement-terminating semicolons). It is much easier to create tools that measure physical SLOC, and physical SLOC definitions are easier to explain. However, physical SLOC measures are more sensitive to logically irrelevant formatting and style conventions than logical SLOC. However, SLOC measures are often stated without giving their definition, and logical SLOC can often be significantly different from physical SLOC. Consider this snippet of C code as an example of the ambiguity encountered when determining SLOC: <syntaxhighlight lang="c"> for (i = 0; i < 100; i++) printf("hello"); /* How many lines of code is this? */ </syntaxhighlight> In this example we have: * 1 physical line of code (LOC), * 2 logical lines of code (LLOC) ([[For loop|for]] statement and [[printf]] statement), * 1 comment line. Depending on the programmer and coding standards, the above "line" of code could be written on multiple separate lines: <syntaxhighlight lang="c"> /* Now how many lines of code is this? */ for (i = 0; i < 100; i++) { printf("hello"); } </syntaxhighlight> In this example we have: * 4 physical lines of code (LOC): is placing braces work to be estimated? * 2 logical lines of code (LLOC): what about all the work writing non-statement lines? * 1 comment line: tools must account for all code and comments regardless of comment placement. Even the "logical" and "physical" SLOC values can have a large number of varying definitions. [[Robert E. Park]] (while at the [[Software Engineering Institute]]) and others developed a framework for defining SLOC values, to enable people to carefully explain and define the SLOC measure used in a project. For example, most software systems reuse code, and determining which (if any) reused code to include is important when reporting a measure.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)