Chapter 3 - Source Lines of code: Software Management Course -AUG Unversity

Hadeel Salah
4 min readDec 22, 2021

--

Welcome back! This is chapter 3 of the series explaining the Software Management course for AUG students — The computer system engineering department.

What is SLOC?

Source lines of code (SLOC) are:

  • A software metric that is used to measure the size of a software program by counting the number of lines in the text of the program’s source code.
  • It’s used to predict the amount of effort that will be required to develop a program.
  • It’s used to estimate programming productivity once the software is produced.
  • It can be used to measure either an existing program or a program yet to build.

Disadvantages of SLOC Metrics:

There are many disadvantages, but I will talk about the points that exist in our course.

- The difference in Languages:

Consider two applications that provide the same functionality one is written in Java and the other is written in C#:

  1. The number of function points would be exactly the same, but aspects of the application would be different.
  2. The lines of code needed to develop the application would certainly not be the same. As a consequence, the amount of effort required to develop the application would be different (hours per function point).
  3. Unlike Lines of Code, the number of Function Points will remain constant

- The lack of standardized definition:

Since the SLOC represent a count of unknown units, thus it would be an inaccurate sizing metric for comparison if SLOC measures are stated without definition.

Terminology and Definitions

  • SLOC (Source line of code): non-blank, non-comment, logical source lines and usually measured by thousand (K)
  • DSI(Delivered source instructions): non-comment, logical source lines, and excluded data.
  • Productivity: total number of DSI divided by the total time in person-month required to complete the project. for example, the productivity for 20k lines that should be finished in 4 months is 20k/4=5k

The most popular SLOC measures are:

  1. Physical carriage returns: Included a count only of physical line ending.
  2. Physical SLOC: Included a count of non-blank, non-comment lines in a program source code.“the lines that do not contain blanks or comments”
  3. Logical SLOC: Measures the number of logical programming that may or may not cross over more than one physical line.

Another term You Should Know:

  1. Comment: Comment lines in code
  2. Physical Lines: Physical Lines are the program’s source code including comment lines.
  3. Logical Lines: Logical Lines are a number of executable statements
  4. Blank Lines: Lines in Code which is Blank
  5. Total Lines of code: Total Lines of code include Physical lines with Blank Lines
  6. Executable Physical: Physical executable source lines of code is calculated as the total lines of source code minus blank lines and comment lines.
  7. Executable Logical: Executable Logical is a number of statements that are executed.

Logical SLOC Counting Details:

The logical SLOC can be classified into four categories:

  1. The first category is based on what language statements should be included or excluded category.
  2. The second category is based on the source of SLOC used in the delivered product.
  3. The third category is based on the origin of the counted SLOC
  4. The fourth category is based on which SLOC should be counted in the delivered products.

Table 3.2 States the rules that apply to the first category:

-1-

Let’s see Table 3.1 which contains a detailed definition for counting logical SLOC as used in cost models:

-2-

There are some notes about this table:

  1. In code generation, if you change some code from version x to version y, then, you count the output. (Excluded)
  2. In code converting, if you convert code from language a to language b, then, you count the input. (Included)
  3. If you edit for example 1k lines in a library then you count only the percentage of the editing only from the edited part, and you do not count all of the library.

Let’s see Table 3.3 Page 122:

The previous table shows how you count the Physical carriage returns, Physical lines, and Logical lines.

Remember:

  • Logical Lines are a number of executable statements e.g while, n++or int =… is a logical line
  • Physical carriage returns included a count only of physical line ending. for example, the first line in the table is 1 and the second is 2 (1 for the second line and 1 for the previous line)

--

--

Hadeel Salah

Hunger for Knowledge, adventure, and risk enthusiastic. Software engineering student