Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #35537

Re: Why not String compare?

Path csiph.com!1.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!news.unit0.net!news.netfront.net!not-for-mail
From Lothar Kimmeringer <news200709@kimmeringer.de>
Newsgroups comp.lang.java.programmer
Subject Re: Why not String compare?
Date Fri, 2 Sep 2016 21:54:49 +0200
Organization Organization?! Only chaos here!
Lines 29
Message-ID <1le6no2qsdcz4.dlg@kimmeringer.de> (permalink)
References <33463070-424f-4fb0-956b-2849f1a400eb@googlegroups.com> <nppu0n$nle$1@dont-email.me> <2dca46af-3b1f-4352-82c6-a413d9dac03c@googlegroups.com>
Reply-To news@kimmeringer.de
NNTP-Posting-Host 79.202.96.68
Mime-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding 7bit
X-Trace adenine.netfront.net 1472846090 68229 79.202.96.68 (2 Sep 2016 19:54:50 GMT)
X-Complaints-To news@netfront.net
NNTP-Posting-Date Fri, 2 Sep 2016 19:54:50 +0000 (UTC)
User-Agent 40tude_Dialog/2.0.15.1de
Xref csiph.com comp.lang.java.programmer:35537

Show key headers only | View raw


Eric Douglas wrote:

> Another example where I needed null to be valid in my custom
> Comparable.  I wrote a custom table (extends JTable).
> Every cell in the table is a custom object.  The cell class
> has a getValue() and a compareTo().  getValue() may return
> null because null has special meaning.

You're only one step away from
http://thedailywtf.com/articles/What_Is_Truth_0x3f_

Since you use customized Objects what prevented you from
declaring a final static MyObject EMPTY_OBJECT = new MyObject()
and do a == EMPTY_OBJECT instead of a == null?

One day you will wonder why your application behaves strangely
and after hours of debugging you find out that somewhere null
is set where your special meaning wasn't intended.


Cheers, Lothar
-- 
Lothar Kimmeringer                E-Mail: spamfang@kimmeringer.de
               PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                 questions!

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Why not String compare? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-26 09:00 -0700
  Re: Why not String compare? Robert Klemme <shortcutter@googlemail.com> - 2016-08-26 18:49 +0200
    Re: Why not String compare? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-26 10:09 -0700
      Re: Why not String compare? Robert Klemme <shortcutter@googlemail.com> - 2016-08-26 22:48 +0200
        Re: Why not String compare? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-26 13:55 -0700
          Re: Why not String compare? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-26 17:29 -0400
          Re: Why not String compare? Lew <lewbloch@gmail.com> - 2016-08-30 22:20 -0700
          Re: Why not String compare? Robert Klemme <shortcutter@googlemail.com> - 2016-08-31 08:17 +0200
            Re: Why not String compare? Andreas Leitgeb <avl@logic.at> - 2016-08-31 09:45 +0000
              Re: Why not String compare? Robert Klemme <shortcutter@googlemail.com> - 2016-08-31 19:24 +0200
                Re: Why not String compare? Andreas Leitgeb <avl@logic.at> - 2016-09-01 10:17 +0000
                Re: Why not String compare? Robert Klemme <shortcutter@googlemail.com> - 2016-09-02 18:29 +0200
  Re: Why not String compare? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-26 13:24 -0400
    Re: Why not String compare? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-26 10:48 -0700
      Re: Why not String compare? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-26 14:50 -0400
        Re: Why not String compare? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-26 12:19 -0700
      Re: Why not String compare? Lothar Kimmeringer <news200709@kimmeringer.de> - 2016-09-01 20:42 +0200
        Re: Why not String compare? Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-09-01 17:57 -0400
    Re: Why not String compare? Eric Douglas <e.d.programmer@gmail.com> - 2016-08-26 11:03 -0700
      Re: Why not String compare? Lothar Kimmeringer <news200709@kimmeringer.de> - 2016-09-02 21:54 +0200

csiph-web