I have a small question in my mind. I researched it on the Internet but no-one is providing the exact answer. My question is:
In data flow coverage criteria, say there is a method which finally returns variable x
. When drawing the graph for that method, is that return statement considered to be a use of x
?
Yes, a return
statement uses the value that it returns. I couldn't find an authoritative reference that says so in plain English either, but here are two arguments:
A return
statement passes control from one part of a program to another, just like a method call does. The value being returned is analogous to a function parameter. return
therefore is a use just like being a function parameter is a use.
The other kind of use in data flow analysis is when a value leaves the program and has some effect on the outside world, for example by being printed. If we're analyzing a method, rather than an entire program, return
causes the value to leave the scope which we're analyzing. So it's a use for the same reason that printing is a use.