main
Exceptions
Many people try to avoid them.
I've worked on very few projects with a good, solid, consistent
handling of Exceptions.
In one project on an old
fashioned J2EE app server, there weren't any exceptions at
all! Only later I realized that all exceptions were wrapped in a
custom Exception that extended RuntimeException so that no one had
to deal with them. Only at the very end a catch-all was put in
place. It would catch the custom Exception and then send a message
to the user that 'Something went wrong'.
Image: Kate Dedetash @ Pexels
Defensive coding
Reality is that you have the Exceptions. No way around it. They are a fact of life. No way to avoid them. Might as well deal with them in the most efficient way.
No need to check for a null-value. Just let the code throw a NPE. Otherwise the next poor b*stard has to do the same.