Returning boolean instead of declaring a void type in Java?
boolean, java, void
Solution
Usually I use `Exception`s to signal when something went wrong.
Instead of returning `false`, you can `throw` an `Exception` with a detailed message about what the problem was.
Returning `false` doesn't give you much information about the problem.
Then, instead of checking for a `false` return value, just put the method call in `try`/`catch` if you expect that the method could easily fail.
Many people will complain that this method is slower. But, the benefits you gain greatly outweigh the slowdown. Besides, if you are using Java speed shouldn't be your #1 concern.
Problem
Are there any hard and fast rules regarding returning boolean in a method signature to indicate a successful operation as opposed to declaring void? I find that for more critical operations in my calling method I want to know if an operation completed so I can log any issues. Is this an "inappropriate" use of boolean?