Outputs is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.
Outputs
API ID: CountOutputAlso Known As: FANOUT (Infomational fan-out)
Languages: C#, C++, Fortran, Java
Targets: Functions, Subprograms
Number of called subprograms plus global variables set.
The number of outputs that are SET. These can be parameters or global variables. So Functions calls + Parameters set/modify + Global Variables set/modify. A non-void return value adds one to the count. Recursive function calls, local variables that are not class static variables, and parameters that are pass by value are not included. Of the two general approachs to calculating FANOUT (informational versus structural) ours is the informational approach.
For example:
int somefunc();
int in = 1;
int out = 1;
int inOutFunc(int in1, int in2, int *inout1, int &inout2, int* out1, int & out2) {
out = in + in1 + in2 + *inout1 + inout2;
*inout1 = in1;
inout2 = in2;
*out1 = in1;
out2 = in2;
in1 = somefunc();
in2 = 2;
int randomint = 3;
in1 = randomint;
return 4;
}
void callingfunc() {
int a,b,c,d;
int myval = inOutFunc(1,2,&a,b,&c,d);
}
inOutFunc sets the global out and the parameters inout1, inout2, out1, and out2 (each modified through a pointer or reference). in1 and in2 are also reassigned later in the function, but since they're passed by value, those changes don't escape the function, so they don't count. inOutFunc also calls somefunc() (a non-recursive call) and has a non-void (int) return type, which adds one more. That's 1 global + 4 parameters set + 1 function called + 1 for the non-void return, for an Outputs count of 7.
See Inputs for the related fan-in metric, and the Outputs Metric interactive report to list the references contributing to it for a given function.
Also known as FANOUT (Infomational fan-out).
Introduced by Henry, Sallie, and Dennis Kafura in "Software Structure Metrics Based on Information Flow." IEEE Transactions on Software Engineering, vol. SE-7, no. 5, 1981, pp. 510-518.
- C#: Method
- C++: Function
- Fortran: Function, Program, Subroutine
- Java: Method