I sometimes see code that is self sabotaging:
public static int getSize(int[] array){
if(array==null) throw new IllegalArgumentException("oh no, you passed null!");
...
}
I find that so incredibly difficult to comprehend. Why would you not just return 0? I'm being serious. I sometimes read code that goes out of its way to not work in the exact scenarios the people that supply that code don't want their code to be used. I don't think I have ever heard a good reason to do that. Like, yeah, you shouldn't depend on the interna of an implementation, but actively making your code less functional only so no one can depened on them?
another thing along these lines that bothers me is: command line tools that fail when you give them 0 arguments