You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When developing software, we often have methods that have not yet been implemented. Most of them have a return value that needs to be returned. Of course it is possible to just let the program return null, but that could crash the whole program.
publicintcalculateScore() {
returnnull;
}
So what else can we do when we need to make a return statement?
We can simply throw an exception.
It can be annoying during development to have to switch back and forth between the code we're working on and the throw statement, because it won't compile if a throw statement prevents further code from executing.
When developing software, we often have methods that have not yet been implemented. Most of them have a return value that needs to be returned. Of course it is possible to just let the program return null, but that could crash the whole program.
So what else can we do when we need to make a return statement?
We can simply throw an exception.
It can be annoying during development to have to switch back and forth between the code we're working on and the throw statement, because it won't compile if a throw statement prevents further code from executing.
What if we could just annotate a method with @NotYetImplemented and Lombok would replace all existing code inside the function with an exception?
would be replaced by
We could even modify the exception class to use our own exceptions
When using BuildConfig plugins, we could even specify to generate the throw statement only when a special flag is set
The text was updated successfully, but these errors were encountered: