Should I correct my boss?

Soldato
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
I over heard my boss (chief technical architect) telling someone to never deference by assigning something to null in Java.

At the time I said I thought that was a valid way to make an object eligible for garbage collection.

He then went on to mention pointers, memory leaks and memory hacking. All of which felt a little off to me. I didn't have a clear enough understanding of what he was talking about at the time to provide a good counter argument.

Anyway since I've done a bit of revision on the java garbage collector, Mark and sweep and generational heap space, to know null assignment is perfectly fine in java.

As for the other stuff I worked out he was talking about pointer arithmetic and dangling pointers, none of which is an issue in Java.

So shall I inform him or be quiet and be happy that my suspicions were correct?
 
Last edited:
Depends on the person. Some people would be fine, even happy that their team can improve their knowledge, some will absolutely detest you for it and try to get rid of you.
 
Its valid, but I would regard it as a suspicious code smell. Only in rare cases do you ever need to explicitly use the setting-as-null pattern to dereference something. Variables and data just fall out of scope naturally and the GC will pick them up. The only exceptions I can think of offhand is if you are constructing a data structure with circular references or using JNI.

All the stuff about memory hacking etc is spurious. If a hacker can get at a running instance of your code, you have seriously bigger issues to worry about.
 
I can't comment on the code being right/wrong/valid as I don't know, but regarding your boss it would depend on the person.

My company strongly encourages challenging each other, as long as it is to further the knowledge of the company and what we do, and not a weeing contest being two people. I have corrected my boss before and even my MD on occasion. I have just made sure that I am 100% right beforehand and done it in the right way - generally a well worded email that explains.
 
Back
Top Bottom