top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is code metrics.

+3 votes
450 views

How is it calculated? What is cyclomatic complexity?

posted Jul 31, 2014 by Merry

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

Code metrics is a set of software measures that provide developers better insight into the code they are developing. By taking advantage of code metrics, developers can understand which types and/or methods should be reworked or more thoroughly tested.

The following list shows the code metrics results that Visual Studio calculates:
Maintainability Index – Calculates an index value between 0 and 100 that represents the relative ease of maintaining the code. A high value means better maintainability. Color coded ratings can be used to quickly identify trouble spots in your code. A green rating is between 20 and 100 and indicates that the code has good maintainability. A yellow rating is between 10 and 19 and indicates that the code is moderately maintainable. A red rating is a rating between 0 and 9 and indicates low maintainability.

Cyclomatic Complexity – Measures the structural complexity of the code. It is created by calculating the number of different code paths in the flow of the program. A program that has complex control flow will require more tests to achieve good code coverage and will be less maintainable.

Depth of Inheritance – Indicates the number of class definitions that extend to the root of the class hierarchy. The deeper the hierarchy the more difficult it might be to understand where particular methods and fields are defined or/and redefined.

Class Coupling – Measures the coupling to unique classes through parameters, local variables, return types, method calls, generic or template instantiations, base classes, interface implementations, fields defined on external types, and attribute decoration. Good software design dictates that types and methods should have high cohesion and low coupling. High coupling indicates a design that is difficult to reuse and maintain because of its many interdependencies on other types.

Lines of Code – Indicates the approximate number of lines in the code. The count is based on the IL code and is therefore not the exact number of lines in the source code file. A very high count might indicate that a type or method is trying to do too much work and should be split up. It might also indicate that the type or method might be hard to maintain.

Source: http://msdn.microsoft.com/en-us/library/bb385914.aspx

answer Jul 31, 2014 by Salil Agrawal
Similar Questions
+2 votes

I want to know the difference between the visual basic and visual studio. And also explain each of them in detail. Please.

+2 votes

Develop a C# Windows Form Application that allows users to do all of the following.
Read a List of patient's information from a text file (*.txt), the input text file is selected from the Open File Dialog.
Your program should accept any text file with the following format:
a. The file contains columns with Basic information about patients.
b. Columns may be separated by spaces and/or tabs.
c. The first line in the file is the column header.
d. After the header, each line represents a Patient (name, address, phone#, Bdate, gander ,wheight, height and blood type).
e. Successfully imported patients are displayed on a data grid view in a second form and added to a patient list.

  1. The user will be able to display on The Grid view :
    a) Female patients.
    b) Patients with age<45 year. c) Save Over weighted patients on a text file .  Note: To find over weighted patients you have to calculate the BMI value. BMI=Weight/ (Height*Height). If BMI <18.5 >>>>> under weighted.
    18.5<=BMI<=25 >>>>>>>Normal.
    BMI>25 >>>>>>>>>>>> Over Weighted.
+1 vote

Develop a C# windows form application that allows users to do all of the following:
Import a text from a text file (*.txt).The input file is selected from an open file dialog.
Successfully imported text is displayed on a text box.
Analyze a selected character.

For example the selected char is # :
is Digit :False
is letter :False
is letter or Digit :False
is lower :False
is upper :False
is punctuation :True
is symbol :False

then :
Calculate number of lines in the imported text.
Calculate number of words in the imported text.
Calculate number of letters in the imported text.
Calculate number of digits in the imported text.
Calculate number of uppers in the imported text.
Replace a selected word by anything else.

+2 votes

I am converting a Windows Mobile 6.0 dll to Win 10 dll.

Opened a project -->VC++-->Console application-->dll project.

I have added just one liner with below function

switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
    RETAILMSG(TRUE, (TEXT("client.dll: DLL_PROCESS_ATTACH\r\n")));

i have added bbgapi.h in the include which is the header file for RETAILMSG.

error is as below:

LINK2109 : unresolved NKDbgPrintfW

NKDbgPrintfW : is again linked to nkstub.lib but i am not able to find this in NET.

...