Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: null checks Date: Sat, 8 Jul 2017 17:51:45 -0400 Organization: A noiseless patient Spider Lines: 36 Message-ID: References: <70f5af57-8dc0-416c-b2aa-0bbbb47fc7b5@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sat, 8 Jul 2017 21:47:55 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="bb089af208211ccf62e97802cb88dc75"; logging-data="10219"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CVQhdYsXHzQ619gWmMIeN" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 In-Reply-To: Content-Language: en-US Cancel-Lock: sha1:m8Z7BchXmcXl6mBG71mRtg27J/4= Xref: csiph.com comp.lang.java.programmer:36837 On 7/8/2017 5:14 PM, Martin Gregorie wrote: > On Sat, 08 Jul 2017 22:33:36 +0200, Joerg Meier wrote: > >> On Fri, 7 Jul 2017 12:12:04 -0400, Arne Vajhøj wrote: >> >>> I don't like to rely on IDE/checktool to enforce integrity of >>> application. >> >> Why not ? You presumably let a tool do your type checking for you all >> the time. Where is the difference to null checking ? >> > I'm with Arne here. > > Type checking can generally be done at compile time because its static > w.r.t code statements. > > However, the same doesn't apply to null checks. Whether a reference > variable contains null or not depends on what has been assigned to it > while the code was executing. Whether a null value is valid is entirely > dependent on the logic of the code using it and so often cannot be > checked at compile time. ... but sometimes can be, in much the same way that Java can usually diagnose the use of a variable that may not have had a value assigned yet. (By "usually" I don't mean that Java ever fails to diagnose an actual problem, but that it sometimes raises false alarms.) Perhaps we're reading the word "rely" a bit differently. It seems to me that if the tool can give me some help, I can "rely" on that help. I may not "rely entirely" on the tool, but, well, I'll gladly accept all the help I can get ... -- esosman@comcast-dot-net.invalid Twelve hundred ninety-two days to go.