Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!proxad.net!feeder2-2.proxad.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: toward null-safe cookie cutter Comparators Date: Wed, 16 Nov 2011 14:02:46 -0800 (PST) Organization: http://groups.google.com Lines: 48 Message-ID: <16498462.27.1321480966372.JavaMail.geo-discussion-forums@prgt40> References: Reply-To: comp.lang.java.programmer@googlegroups.com NNTP-Posting-Host: 2620:0:1000:2404:224:d7ff:fe69:5838 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1321480967 17129 127.0.0.1 (16 Nov 2011 22:02:47 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 16 Nov 2011 22:02:47 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2620:0:1000:2404:224:d7ff:fe69:5838; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9984 kensi wrote: > Daniel Pitts wrote: >> I've seen projects where a *core* library had a method "isNull" defined >> thusly: >> >> public boolean isNull(Object o) { >> if (o == null) return true; >> String s = String.valueOf(o); >> if (s.trim().length == 0) { >> return true; >> } >> if ("null".equals(s)) return true; >> if ("(null)".equals(s)) return true; >> } > > Shocking, if true, since the above code won't compile. He said, "thusly", not "thus", thus allowing a little room for transcription error, in this case the omission of the catch-all 'return false;'. His main point, that even with the correction the routine is stupid, is not damaged. -- Lew > > Obviously, someone was told that "null" and "(null)" were appearing > > somewhere and causing problems. Instead of tracking down the source, > > they littered the codebase with these "isNull" checks. I should have my > > legal name changed to "Null Null", and see how many forms on the web > > reject my name :-) > > Why go to the hassle of changing your legal name? It's not like giving > false information to large corporate marketing departments^W^W^W^Wweb > forms is an offense under the law or anything. ;) At most it's a TOS > violation and the account you create won't last long (cf. Facebook, > Google Plus). > > > Imagine the following: > > > > // Commonly used library method handleThing. > > void handleThing(Thing t) { > > AnotherThing at = t.getAnotherThing() > > doSomething(at); > > } > > Comment above is wrong, should be > // Commonly used Law of Demeter violation > HTH. :)