Analysis_Of_Source_Lines_Of_Code_SLOC_Me
Analysis_Of_Source_Lines_Of_Code_SLOC_Me
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{}
}
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