How do you handle null?
The most common reason for writing null checks is that you run into a null pointer exception. The second most common reason is that you happened to think about it at some certain case.
The problem is that you are not probably handling null in every single method call. This means that there are potential bugs lurking everywhere.
Null pointer exceptions are bad. Would it not be better if you did not have to check for nulls at all?
We all have been taught that reusable code is good. We all know why we should do it but there are some misconceptions about how to do it.
There are two common misconceptions about reusable code:
- Using inheritance in order to achieve code reuse.
- Creating a static utility or helper class in order to reuse methods.
Mostly these misconceptions are the result of procedural thinking. People usually understand how certain object-oriented principles work. However, it is seldom taught what is the purpose of such principles.