Apparently, Hadoop framework developers decided to return boolean rather than throwing an Exception. If you were the lead developer, would you have taken the same approach? Why? Why Not?
If I were the lead developer – I would definitely not return some value like bool, but I would throw an exception.
This is because, when some error like IO operation occurs - the function or the code should stop the execution and throw a message (error) explaining what the developer missed to taken into precaution.
Not all functions/codes are excepted to return values - they would just go no to do some steps and stop. If in this case if the function return a 0 in case of error; this would not be caught in the code as it did not stop - the code would blindly go to next stop and the developer would not know until something undesired happened.
Hence, it is always good to throw and error, so the developer may use TRYCATCH code to suppress the error or go properly to rectify the error'ed code, this is a better error handling approach.
Get Answers For Free
Most questions answered within 1 hours.