// minDif finds the min value > 0 
// function assumes values in order (ie. difRed, difGreen, difBlue)
// Analysis
This function uses the variables a, b and c to represent difRed, difGreen and difBlue respectively. It would probably have been better programming practice to return either "a", "b", or "c", instead of the string "difRed", "difGreen" or "difBlue", but this function seems to be fairly localised to this problem. Further, if you ever have a future need for the function, it would be easy work to alter it to return "a", "b", "c", or the values contained within.

Functions like this, however, are generally easier to think of in abstract terms, which is why the variables a, b and c are used in the first place. Because the function is independent of the code (which is why it shouldn't return the strings it does!), the coding of the function should be treated to accept abstract values applicable to a wide range of values.

Close Window