0% found this document useful (0 votes)
14 views5 pages

Analysis_Of_Source_Lines_Of_Code_SLOC_Me

The document analyzes the Source Lines of Code (SLOC) metric, which measures software size by counting lines in source code, and discusses its advantages and disadvantages in software estimation. It highlights issues such as lack of accountability, cohesion with functionality, and the impact of developer experience on SLOC measurements. The conclusion emphasizes that while SLOC is useful for estimation, its limitations make it unreliable as a sole metric.

Uploaded by

oaixnaro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views5 pages

Analysis_Of_Source_Lines_Of_Code_SLOC_Me

The document analyzes the Source Lines of Code (SLOC) metric, which measures software size by counting lines in source code, and discusses its advantages and disadvantages in software estimation. It highlights issues such as lack of accountability, cohesion with functionality, and the impact of developer experience on SLOC measurements. The conclusion emphasizes that while SLOC is useful for estimation, its limitations make it unreliable as a sole metric.

Uploaded by

oaixnaro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

International Journal of Emerging Technology and Advanced Engineering

Website: www.ijetae.com (ISSN 2250-2459, Volume 2, Issue 5, May 2012)

Analysis Of Source Lines Of Code(SLOC) Metric


Kaushal Bhatt1, Vinit Tarey2, Pushpraj Patel3
1,2,3
Kaushal Bhatt MITS ,Datana Ujjain
1
[email protected]
2
[email protected]
3
[email protected]
Abstract—Source lines of code (SLOC) is a software metric However, a code counting utility developed for a
used to measure the size of a software program by counting specific language cannot be used for other languages due to
the number of lines in the text of the program's source code. the syntactical and structural differences among languages.
SLOC is typically used to predict the amount of effort that
will be required to develop a program, as well as to estimate 2. An Intuitive Metric:
programming productivity or maintainability once the Line of Code serves as an intuitive metric for measuring
software is produced.There are some drawbacks in SLOC the size of software because it can be seen and the effect of
metrics that affect the quality of software because of SLOC it can be visualized. Function points are said to be more of
metric output is used as a input in other Software Estimation an objective metric which cannot be imagined as being a
methods Like COCOMO Model.
physical entity, it exists only in the logical space. This way,
Keywords— SLOC, Metrics, Software Estimation, LOC comes in handy to express the size of software among
COCOMO, Performance Analysis programmers with low levels of experience [4].
Disadvantages:-
I. INTRODUCTION 1. Lack of Accountability:
There sometimes is a decidedly dark side to SLOC Lines of code measure suffers from some fundamental
software metric that many of us have observed, but few problems. Some think it isn't useful to measure the
have openly discussed. It is clear to us that we often get productivity of a project using only results from the coding
what we ask for with software metrics and we sometimes phase, which usually accounts for only 30% to 35% of the
get side effects from the metric that overshadow any value overall effort [2].
we might derive from the metrics information. Whether or
2. Lack of Cohesion with Functionality:
not our models are correct, and regardless of how well or
poorly we collect and compute software metrics, people’s Though experiments have repeatedly confirmed that
behaviors change in predictable ways to provide the effort is highly correlated with SLOC, functionality is less
answers management asks for when metrics are applied. well correlated with SLOC. That is, skilled developers may
For this reasons we Consider Source lines of code metrics be able to develop the same functionality with far less code,
for our analysis. SLOC Metric works on Source Lines of so one program with less SLOC may exhibit more
code but when we talk about the different Programming functionality than another similar program. In particular,
Languages the Lines of code to perform task is vary SLOC is a poor productivity measure of individuals,
language to language because different languages have because a developer who develops only a few lines may
different structures. Our in-depth analysis in this field still be more productive than a developer creating more
provide a comprehensive view to understand what SLOC lines of code - even more: some good refactoring like
metric do and how much one can rely on SLOC metric. "extract method" to get rid of redundant code and keep it
clean will mostly reduce the lines of code[2].
II. ADVANTAGE AND DISADVANTAGES OF LOC METRICS 3. Adverse Impact on Estimation:
Advantages:- Because of the fact presented under point 1, estimates
1. Scope for Automation of Counting: based on lines of code can adversely go wrong, in all
possibility.
Since Line of Code is a physical entity; manual counting
effort can be easily eliminated by automating the counting 4. Developer’s Experience:
process. Small utilities may be developed for counting the Implementation of a specific logic differs based on the
SLOC in a program. level of experience of the developer. Hence, number of
lines of code differs from person to person.

150
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, Volume 2, Issue 5, May 2012)
An experienced developer may implement certain 9. Psychology of Programmer:
functionality in fewer lines of code than another developer A programmer whose productivity is being measured in
of relatively less experience does, though they use the same lines of code will have an incentive to write unnecessarily
language. verbose code. The more management is focusing on lines
5. Difference in Languages: of code, the more incentive the programmer has to expand
Consider two applications that provide the same his code with unneeded complexity. This is undesirable
functionality (screens, reports, databases). One of the since increased complexity can lead to increased cost of
applications is written in C++ and the other application maintenance and increased effort required for bug fixing.
written in a language like COBOL. The number of function
points would be exactly the same, but aspects of the III. MEASUREMENT OF LOC METRIC
application would be different. The lines of code needed to For measurement of SLOC Metric We can use Metric
develop the application would certainly not be the same. As Computational Tool (LOC Metrics). [6]
a consequence, the amount of effort required to develop the Tool Compute the following aspects of Source Code.
application would be different (hours per function point).
Unlike Lines of Code, the number of Function Points will 1. Physical Lines: Physical Lines are program's source
remain constant. code including comment lines.
6. Advent of GUI Tools: 2. Logical Lines: Logical Lines are number of executable
statements.
With the advent of GUI-based programming languages
3. Blank Lines: Lines in Code which is Blank.
and tools such as Visual Basic, programmers can write
relatively little code and achieve high levels of 4. Total Lines of code: Total Lines of code include
functionality. For example, instead of writing a program to Physical lines with Blank Lines
create a window and draw a button, a user with a GUI tool 5. Executable Physical: Physical executable source lines of
can use drag-and-drop and other mouse operations to place code is calculated as the total lines of source code minus
components on a workspace. Code that is automatically blank lines and comment lines.[4]
generated by a GUI tool is not usually taken into 6. Executable Logical: Executable Logical is number of
consideration when using SLOC methods of measurement. statements that is executed.
This results in variation between languages; the same task 7. Comment: Comment lines in code.
that can be done in a single line of code (or no code at all)
in one language may require several lines of code in 8. Words in Comment: Total No. of words in comment
another. lines.
7. Problems with Multiple Languages: 9. Header Comment: Comment of Header Part.
10. Header Words: Total words in Header Comment.
In today’s software scenario, software is often developed
in more than one language. Very often, a number of 11. McCab VG Complexity: The McCab complexity is
languages are employed depending on the complexity and directly measures the number of linearly independent paths
requirements. Tracking and reporting of productivity and through a program's source code. The complexity is
defect rates poses a serious problem in this case since computed using the control flow graph of the program: the
defects cannot be attributed to a particular language nodes of the graph correspond to indivisible groups of
subsequent to integration of the system. Function Point commands of a program, and a directed edge connects two
stands out to be the best measure of size in this case. nodes if the second command might be executed
immediately after the first command[7].
8. Lack of Counting Standards:
Mathematical Representation of McCabe complexity is:-
There is no standard definition of what a line of code is.
Do comments count? Are data declarations included? What M = E − N + 2P
happens if a statement extends over several lines? – These Where M= Complexity
are the questions that often arise. Though organizations like E= Number of Edges in graph
SEI and IEEE have published some guidelines in an N= Number of Nodes in graph
attempt to standardize counting, it is difficult to put these P= Number of connected component(exit nodes)
into practice especially in the face of newer and newer
languages being introduced every year.

151
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, Volume 2, Issue 5, May 2012)
Kaner’s Ten Measurement Factors [1] --
1. The purpose of the measure. What the measurement will ("=");
be used for. backspace = new Button ("Backspace");
2. The scope of the measurement. How broadly the clear = new Button ("C");
measurement will be used. }
3. The attribute to be measured. E.g., a product’s readiness
for release. --
4. The appropriate scale for the attribute. Whether the --
attribute’s mathematical properties are rational, interval, --
ordinal, nominal, or absolute.
5. The natural variation of the attribute. A model or public void launchFrame(){
equation describing the natural variation of the attribute.
E.g., a model dealing with why a tester may find more tField.setText("0.");
defects on one day than on another. tField.setEnabled(false);
6. The instrument that measures the attribute. E.g., a count
of new defect reports. --
7. The scale of the instrument. Whether the mathematical --
properties of measures taken with the instruments are p6.add(bAdd);
rational, interval, ordinal, nominal, or absolute. p6.add(equals);
8. The variation of measurements made with this --
instrument. A model or equation describing the natural --
variation or amount of error in the instrument’s GridLayout (6, 1) );
measurements. --
9. The relationship between the attribute and the --
instrument. A model or equation relating the attribute to the f.setMenuBar(menuBar);
instrument. f.pack();
10. The probable side effects of using this instrument to
measure this attribute. E.g., changes in tester behaviors // ACTION LISTENERS
because they know the measurement is being made. --
--
IV. REALIZATION --
fmi1.addActionListener(this);
Code : fmi2.addActionListener(this);
import java.awt.*; fmi3.addActionListener(this);
import javax.swing.*; }
import java.awt.event.*;
public class Calculator implements ActionListener{ /* |------------ START OF ACTION EVENTS ---------
---| */
--
-- public void actionPerformed(ActionEvent a){
--
-- --
fmi1 = new MenuItem(" Copy "); --
fmi2 = new MenuItem(" Paste "); -- tField.setText(value);
fmi3 = new MenuItem(" Quit "); }
EditMenu.add(fmi1); if(a.getSource()==num7){
EditMenu.add(fmi2); value+=7;
-- tField.setText(value);
-- }
-- --
--
152
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, Volume 2, Issue 5, May 2012)
-- Metric Calculation By SLOC calculation Software [3]:-
/* |-- EQUALS ACTION --| */
if(a.getSource()==equals){
value="";
v2 =
Double.parseDouble(tField.getText());
if(o=='+'){
--
--
--
if(o=='%'){
ctr=0;
answer = v1 % v2;
tField.setText("" +answer);
value=""; v1=null; v2=null;
}
else{}
}

/* |-- EQUALS ACTION --| */


--
--
--
// END OF ACTION EVENTS
public static void main (String args[]){
Calculator s = new Calculator();
s.launchFrame();
}
}
The following results has been generated for the
calculator code written in java using the SLOC Calculation
Compilation of Code in tool:-

153
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, Volume 2, Issue 5, May 2012)
V. CONCLUSION
SLOC is most useful Metric in Software Estimation but
Some restrictions that is involved in SLOC Metric makes it
vurnable for relying on it. Here we can present the depth
Analysis of SLOC Metric for the purpose to expose some
of its disadvantages and provide knowledge of SLOC
Metric Measurement.
REFERENCES
[1] Kaner, C. ―Rethinking Software Metrics,‖ Software Testing and
Quality Engineering vol. 2, no. 2 (2000).
[2] The Darker Side of Metrics by Douglas Hoffman
[3] http://www.locmetrics.com
[4] Wheeler, David A. (June 2001). "Counting Source Lines of Code
(SLOC)"
[5] Structured Testing: A Testing Methodology Using the Cyclomatic
Complexity Metric NIST Special Publication
[6] Park, Robert E., et al.. "Software Size Measurement: A Framework
for Counting Source Statements"
[7] Rich Sharpe. "McCabe Cyclomatic Complexity: the proof
in the pudding

154

You might also like