• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Beginnerquestion about if (personName==null || personName.equals(""))
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Beginnerquestion about if (personName==null || personName.equals(""))


  • Subject: Re: Beginnerquestion about if (personName==null || personName.equals(""))
  • From: Mike Schrag <email@hidden>
  • Date: Sat, 8 Sep 2007 12:53:42 -0400

DBC doesn't REALLY address this, though, right? It says whether my method allows null values or not for certain parameters, and watches my back there, but it still doesn't address what it means to call a method on a null value. This thread is about explicitly asking to be able to call methods on null pointers, which seems like super-un- design-by-contract :)

Or do you just love to shout "DBC" ;)

ms

On Sep 8, 2007, at 12:48 PM, Chuck Hill wrote:


On Sep 8, 2007, at 5:40 AM, Mike Schrag wrote:

The problem with all of this is that the behavior against a null is totally random ... Yeah, str.equals(whatever) when str is null happens to make some sense. But what about list.isEmpty()? false? really? I agree that it's more work to do the checks, but it's right -- you have a null. It's not an instance. You can't call methods on it and you shouldn't be able to. The problem is that if the language gave you an operator (like groovy) to avoid these checks, everyone would use it all the time, because programmers are usually pretty lazy (myself included :) ), which would make the whole thing pointless, and you'd just get random bugs. But I know I'm in the minority here ....

Design by Contract baby!

:-)


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Beginnerquestion about if (personName==null || personName.equals(""))
      • From: Chuck Hill <email@hidden>
References: 
 >Beginnerquestion about if (personName==null || personName.equals("")) (From: Rainer User <email@hidden>)
 >Re: Beginnerquestion about if (personName==null || personName.equals("")) (From: Lachlan Deck <email@hidden>)
 >Re: Beginnerquestion about if (personName==null || personName.equals("")) (From: Kieran Kelleher <email@hidden>)
 >Re: Beginnerquestion about if (personName==null || personName.equals("")) (From: Cornelius Jaeger <email@hidden>)
 >Re: Beginnerquestion about if (personName==null || personName.equals("")) (From: Cornelius Jaeger <email@hidden>)
 >Re: Beginnerquestion about if (personName==null || personName.equals("")) (From: James Cicenia <email@hidden>)
 >Re: Beginnerquestion about if (personName==null || personName.equals("")) (From: Mike Schrag <email@hidden>)
 >Re: Beginnerquestion about if (personName==null || personName.equals("")) (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Beginnerquestion about if (personName==null || personName.equals(""))
  • Next by Date: Re: Beginnerquestion about if (personName==null || personName.equals(""))
  • Previous by thread: Re: Beginnerquestion about if (personName==null || personName.equals(""))
  • Next by thread: Re: Beginnerquestion about if (personName==null || personName.equals(""))
  • Index(es):
    • Date
    • Thread