This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hello all i have function in my application that it use to catch exception inside it and only return true or false based on the exceptions. this function is api function that external applications are using . now there is demand that this function will throw exceptions , but how can i throw exceptions and also keep the backward capabilities. to the old users. i can add another parameter to the function and then cause it to throw exceptions ? how can it be done technically ? what will be with the old users i don't what them to handle the exceptions
If you need to maintain backwards compatibility then any exceptions you add must be runtime exceptions i.e. extend RuntimeException class. The only way to throw a checked exception is to create a RuntimeException with the checked exception as the cause and then throw the RuntimeException.