Game Development Reference
In-Depth Information
Interfaces
The last ODC defect type that needs to be discussed is the Interface type. An interface
occurs at any point where information is being transferred or exchanged. Inside the
game code, Interface defects occur when something is wrong in the way one module
makes a call to another. If the parameters passed on somehow don't match what the
calling routine intended, then undesired results occur. Interface defects can be intro-
duced in a variety of ways. Fortunately, these too fall into logical categories:
1. Calling a function with the wrong value of one or more arguments
2. Calling a function with arguments passed in the wrong order
3. Calling a function with a missing argument
4. Calling a function with a negated parameter value
5. Calling a function with a bitwise inverted parameter value
6. Calling a function with an argument incremented from its intended value
7. Calling a function with an argument decremented from its intended value
Here is how each of these could be the cause of the Vanish problem. Let's use
ShowDuration , which was introduced earlier in this chapter, and give it the following
function prototype:
void ShowDuration(BOOLEAN_T bShow, int duration);
This routine does not return any value, and takes a project-defined Boolean type to
determine whether or not to show the value, plus a duration value, which is to be dis-
played if it is greater than 0. So, here are the Interface type defect examples for each of
the seven causes:
1. ShowDuration(TRUE, g_vanishSpeed[level]);
In this case, the wrong global array is used to get the duration (speed instead of duration).
This could result in the display of the wrong value or no display at all if a 0 is passed.
2. ShowDuration(g_vanishDuration[level], TRUE);
Let's say the BOOLEAN_T data type is #defined as int , so inside ShowDuration the duration
value (first parameter) will be compared to TRUE , and the TRUE value (second parameter)
will be used as the number to display. If the duration value does not match the #define
for TRUE , then no value will be displayed. Also, if TRUE is #define d as 0 or a negative number,
then no value will be displayed because of our rule for ShowDuration that a duration less
than or equal to zero does not get displayed.
Search WWH ::




Custom Search