assert
is very useful and can save you a lot of backtracking when unexpected errors occur by halting the program at the very first signs of trouble.
On the other hand, it is very easy to abuse assert
.
int quotient(int a, int b){
assert(b != 0);
return a / b;
}
The proper, correct version would be something like:
bool quotient(int a, int b, int &result){
if(b == 0)
return false;
result = a / b;
return true;
}
So... in the long run... in the big picture... I must agree that assert
can be abused. I do it all the time.