returning null vs returning zero, which would be better?
Posted
by
Dark Star1
on Programmers
See other posts from Programmers
or by Dark Star1
Published on 2012-05-31T09:37:05Z
Indexed on
2012/05/31
10:49 UTC
Read the original article
Hit count: 224
I inherited a project that I am managing and having to maintain pending the redevelopment of the code base. At the moment I am being tasked with adding little feature all over the place and have gotten into the habit of returning null instead of zero in parts of the code where I am working on. The problem is we have a client that is using this code and parts of code that require data from my implemented features recieve a null and dump the stack trace in UI. I would like to avoid this entirely from my input but without the nullPointer exceptions there's the potential that errors would be introduced into the client's data which may go un-noticed. Usually I would have come up with my own error notification system but I have never inherited a project before. so I am unsure whether to continue down this path. I still believe that the stack dump is preferable to un-noticed data corruption/inaccuracies.
© Programmers or respective owner