Question

In: Computer Science

FileSystem.delete(...) method returns a boolean when you attempt to delete a file that does not exist...

FileSystem.delete(...) method returns a boolean when you attempt to delete a file that does not exist in the file system. 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?

Solutions

Expert Solution

This is a great question.If I were to be a lead developer in this case , would have gone with the same approach.

There are 2 major reason choosing this approach:

1.Control flow with throwing exception is far more complicated than returning a variable(boolean in this case) and even more so if the Exception is a checked one . By choosing exceptions control flow we are  unnecessarily complicating the code which could have been written in a neater manner.And cleaner the code better it is to maintain.

2.Returning a variable allows the client/user who is consuming the apis that we have developed far more flexibility and ease in development.He can use if, while, switch case etc. to handle various situation instead of catching different kinds of exception.

Hence , we can conclude that using the approach without exception is far superior to one which throws Exception and should be used unless absolutely required.


Related Solutions

Language: Python Function name : sort_by_rating Parameters : file (.csv file), category (string), order (boolean) Returns:...
Language: Python Function name : sort_by_rating Parameters : file (.csv file), category (string), order (boolean) Returns: None Description : You want to see what order the items of a particular category in your file would be in if you sorted them by rating. Given a file, a category of clothing, and an order boolean (True for ascending order, False for descending order), create a function that writes a file called “sorted_items.csv” that includes all of the items in the specified...
Write a static method startsWith that inputs two Strings and returns a boolean. If the first...
Write a static method startsWith that inputs two Strings and returns a boolean. If the first input starts with the substring that is the second input, then the method returns true; otherwise, it returns false. For example, startsWith( "radar installation", "rad" ) returns true startsWith( "radar installation", "installation" ) returns false startsWith( "radar installation", "" ) returns true startsWith( "", "a" ) returns false startsWith( "", "" ) returns true
Write a static method endsWith that inputs two Strings and returns a boolean. If the first...
Write a static method endsWith that inputs two Strings and returns a boolean. If the first input ends with the substring that is the second input, then the method returns true; otherwise, it returns false. For example, endsWith( "radar installation", "rad" ) returns false endsWith( "radar installation", "installation" ) returns true endsWith( "radar installation", "" ) returns true endsWith( "", "a" ) returns false endsWith( "", "" ) returns true
When significant influence does exist, the equity method of accounting must be used. Explain how the...
When significant influence does exist, the equity method of accounting must be used. Explain how the fair market method and the equity method of accounting for equity securities differ.
When it comes to dynamic memory allocation and delete[] pointer, what does it mean to say...
When it comes to dynamic memory allocation and delete[] pointer, what does it mean to say that, CRT detected that the application wrote to memory after end of heap buffer? I tried to duplicate the error by deleting the pointer address twice and it didn't produce the same error code so that's not it. What might cause this problem?
What exactly does Sartre mean when he says that "If God does not exist, then everything...
What exactly does Sartre mean when he says that "If God does not exist, then everything is permitted"? Do you agree with him? Why or why not?
Write a method that returns the result when the calling object is multiplied by a scalar...
Write a method that returns the result when the calling object is multiplied by a scalar value. For example, the PolyTerm 2.4x^3 multiplied by -1.2 should return the PolyTerm object representing -2.88x^3. Language: Java. Method name be like: scalarMultiply(double) Some Outputs: Test 1: Coefficient =1, Exponent = 1 scalarMultiply(1.2).coefficient return 1.2; scalarMultiply(1.2).exponent returns 1. Test 2: Coefficient =2.4, Exponent = 3 scalarMultiply(-1.2).coefficient returns -2.88 scalarMultiply(-1.2).exponent return 3 Test 3: Coefficient =-1.5 Exponent = 0 scalarMultiply(0).coefficient returns 0 scalarMultiply(0).exponent returns 3...
1.What happens if you attempt to call a method using a referencevariable that is set...
1.What happens if you attempt to call a method using a reference variable that is set to null?2.Consider the following class declaration:public class Square{   private double side;   public Square (double s){    side = s;}public double getArea(){   return side * side;}public double getSide(){   return side;}}a. Write a toString method for this class. The method should return a string containing the side and area of the square.b. Write a equals method for this class. The method should accept a Square object as...
What exactly does Sartre mean when he says that"if Goddoes not exist, then everything is...
What exactly does Sartre mean when he says that"if God does not exist, then everything is permitted"? Do you agree with him? Why or why not?
What does it mean when a method is overloaded? Give an example of overloading the method...
What does it mean when a method is overloaded? Give an example of overloading the method isNotInRange so that can be called like isNotInRange(100, 97, 122);
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT