0
16kviews
What is data flow anomaly ? Explain why the presence of data flow anomaly does not imply that program execution will produce incorrect results.

Similar questions

What is Data Flow Anomaly ? Explain with respect to state transition diagram of a program variable

Marks: Dec2013, Dec2014, Dec2012,June 2015

Year: 8M, 10M

1 Answer
1
674views

Data Flow Anamoly :

  • An anomaly is a deviant or abnormal way of doing something.

  • For example, it is an abnormal situation to successively assign two values to a variable without using the first value.

  • Similarly, it is abnormal to use a value of a variable before assigning value to the variable. Another abnormal situation is to generate a data value and never use it.

  • Following are the three abnormal situations called as Type1, Type2 and Type3 anomalies.

  • These anomalies could be manifestations of potential programming errors.

    1. Defined and Then Defined Again :In this type of anomaly, the computation performed by the first statement is redundant if the second statement performs the intended computation.

    2. Undefined but Referenced : A second form of data flow anomaly is to use an undefined variable in a computation where the variable has not been initialized.

    3. Defined but Not Referenced : A third kind of data flow anomaly is to define a variable and then to undefined it without using it in any subsequent computation.

enter image description here

States: Actions: U : Undefined d: define

D : Defined but not referenced r: Reference

R : Defined and Referenced u: Undefined

A : Abnormal

  • Initially, a variable can remain in an undefined state (U) meaning that just a memory location has been allocated to the variable, but no value has been assigned yet.

  • At a later time, the programmer can perform a computation to define (d) the variable in the form of assigning a value to this variable, i.e. when a variable moves to a “defined but not referenced” (D) state.

  • Later a programmer can reference (r) , that is read the value of the variable, thereby moving the value of the variable to a “defined and referenced” (R) state.

  • The variable remains in the R state as long as the programmer keeps referencing the value of the variable. If a programmer assigns a new value to the variable, it moves back to D state.

  • The programmer can take an action to undefined the variable. , i.e (u).

  • Data flow anomaly can be detected by using the idea of program instrumentation which means incorporating additional code in a program to monitor its execution status.

  • If a variable is in the U state , that is undefined state and the programmer reads the variable , a data flow anomaly is said to have occurred. Similarly , while a variable is in D state and programmer undefines the variable (u) then the variable moves to abnormal state.

  • If the state sequence contain the dd, ur , and du subsequence, then data flow anomaly is said to have occurred.

  • The presence of data flow anomaly in a program does not necessarily mean that execution of the program will result in a failure, it simply means that the program may fail.

Please log in to add an answer.