When debugging object oriented (Java) code, sometimes some field of some object is
null while it should not be. I often spend what I feel is way too much time trying to figure out where it should have been set (at which point it's often quickly clear what went wrong).
If it had been a function argument, I'd be easy to trace where it came from by setting a breakpoint and following the stacktrace.
But if I have some ThingFunctions class which gets a ThingList from OtherThing and the Thing inside the list is missing it's id, I usually end up checking all usages of
OtherThing.setThingList and more just to find out who was responsible for setting the id.
Breakpoint don't help much since they only tell me where something happens, not where something doesn't happen.
This takes orders of magnitude more time than following a stacktrace to find why an argument is null. Is there an equally easy solution for debugging this problem? Any general advice? I have a modern IDE, other tools are welcome too.