Unified Control-Data Flow Diagrams (UCDF) Reference
Iterations
Infinite goto loop
1
2
Fa()
a: f();
goto a;
Fb()
b: f();
goto b;
void f(void)
"Do-while" loop.
Continue, break,
and return
1
do{
f();
} while ( g()==1 );
{
f();
}
2
g();
F()
1
1
int g(void)
"while" loop
end
!1
continue;
break;
return;
end of
function
call
while ( x==1 ){
f();
};
1
F()
1
end
!1
2
{
f();
}
void f(void)
for (int i = 0; i < 3; i++ ){
cout << i;
}
"for" loop
F()
int i
1
3
2
int i = 0;
0
i<3
{
cout << i;
}
cout
X
i++;
!(i<3)
end
Range-based-for loop
int x[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
for( auto &y : x ) {
cout << y << " ";
}
x[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
for( auto &y : x ) {
cout << y << " ";
}
Loops, in terms of control and data flow, are
"pumps". In the case of our example, all we are
interested is that it produces constant flow
of calls to f(). Parameters of the flow can be
shown with a special symbol. In the case of
"goto" and any other loop, it
can be "number of times" symbol (in this
case, "inf" is used which means infinite).
In the case when a logical expression is
evaluated, it can be "informational content"
symbol.
The advantage of this method is that on the
higher level we can assess functionality
without going into details.
Fa()
void f(void)
void f(void)
Here is the low level structure of the loop
formed by a goto statement. Two loops is shown
as an example.
Here is a typical do-while loop diagram on the
low level. Also it is an example how continue,
break, and return statements inside can be
diagrammed.
F()
void f(void)
int g(void)
On the higher level the diagram should be
much simpler.
Low level
x
F()
void f(void)
Higher level
g()==1
x==1
Low level.
Here you can observe that the loop generates
a dataflow from the variable i into cout.
Also, "<<" operator is called
i-number of times, i.e. a control flow is
generated.
The higher level of the same diagram.
We can use conditional expression
i<3, while in fact, this for-loop generates
a fixed number of calls: 3.
The hexagonal symbol used indicates
how many times the call is produced.
F()
[0,2]
This loop produces data in a range,
interval [0,2].
cout
X
To control the dataflow we should use the
symbol "X", but in this case, informational
content symbols serves its role.
cout << y << " ";
3
sizeof(x)
all
cout << y << " ";
sizeof(x)
all
or
The diagram specifies how many times the cout
is called (sizeof(x) times), and that all
content of the array is passed.
inf
Fa()
int g(void)
g()==1
operator<<
A loop as a dataflow
generator from
a vector
Here is the dataflow formed by a loop acting
as a pump which is pumping data from
the vector v into the variable x.
the content of the dataflow is shown as v[i].
The dataflow is, then, available to anything
which reads x. That is propagation
of the flow among the software components.
Dataflow may pass many variables acting as
intermediate storages and many "pumps" and
other code-blocks. But that is the same
data-flow.
Flow diagrams make cause-effect chain clear.
for (int i = 0; i < v.size(); i++ )
x = v[i];
1
v
x
v[i]
anything which reads x
End of the loop
for
x[10]
Alternatively, it can be shown like this.
for (int i = 0; i < v.size(); i++ )
v
x
v[i]
anything which reads x
Next
has
has