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.
Assume that Employee class has method boolean isHighEarner() that returns true if employee's salary is above...
Assume that Employee class has method boolean isHighEarner() that returns true if employee's salary is above average and false otherwise. Write an iterative method highEarners that returns the ArrayList<Employee> of all high earners in the given list. public ArrayList<Employee> highEarners( ArrayList<Employee> list) { }   
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?
Assume that the int.TryParse static method in .NET DOES NOT EXIST. Write your own TryParse method....
Assume that the int.TryParse static method in .NET DOES NOT EXIST. Write your own TryParse method. Create a class named MyInt (so as not to conflict with existing Int32 class) and write the static TryParse method inside the MyInt class. Your MyInt.TryParse method is to duplicate the functionality of the existing .NET int.TryParse method EXACTLY. I want your MyInt.TryParse method to internally use the existing int.Parse method. Write a test console application that takes in a value from the user...
I don't understand why this method will not return true, even when my parameters for boolean...
I don't understand why this method will not return true, even when my parameters for boolean results are met, can anyone help shed some light on my mistake? import java.util.*; public class PasswordChecker{    public static void main (String[]args){ Scanner scan = new Scanner(System.in); System.out.println("Please enter a password that is 8 characters in length."); System.out.println("The password must have at least 3 uppercase letters,"); System.out.println("3 numeric digits, as well as 2 lowercase letters,"); System.out.println("and contain no special characters."); System.out.println(); System.out.println("Enter a...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT