Having following general definitions:
fault – a cause of the error (mistake in coding)
error – incorrect state that may lead to failure
failure – deviation of the service from the correct service
What would be the correct application on the following code:
The code should not allow withdrawal when there is a balance of 100 or less
if (Balance<100)
{
return false;
}
else WithDraw();
So as I understand it, the fault is the missing = operator. But what will be the error and failure?
There is a fault (coding or logic mistake) in the code as you said, the missing operator in the comparison. It is possible that no-one ever notices this mistake if there never is balance of exactly 100.
If at some point there is a balance of 100 and the check is done, the error will be exposed. The system will be in incorrect state. It should not have allowed withdrawal, but instead it did. If the withdrawal is allowed, the system is failing to work as it should and user sees the failure.
In this small example it is hard to separate error and failure as the user would probably see the consequences of the error state. If we assume that there is another check somewhere else in the code and because of that the withdrawal is not done, then the system would have been in wrong state (error actualized), but another condition would have masked this one and user would have not seen the failure.