Re: Beginnerquestion about if (personName==null || personName.equals(""))
Re: Beginnerquestion about if (personName==null || personName.equals(""))
- Subject: Re: Beginnerquestion about if (personName==null || personName.equals(""))
- From: Ian Joyner <email@hidden>
- Date: Mon, 10 Sep 2007 10:52:13 +1000
Bertrand Meyer (the originator of DbC, and properties I believe, as
in an NDA feature I can't talk about) has studied and written about
nulls (or Voids as he calls them):
http://se.ethz.ch/~meyer/publications/joop/void.pdf
Ian
On 09/09/2007, at 3:11 AM, Chuck Hill wrote:
On Sep 8, 2007, at 9:53 AM, Mike Schrag wrote:
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.
It also can guarantee that a method does not return null. With
this in place, at least in my own code, there is no need for null
checks as the contract states they are no possible. Of course this
can't apply to user input or the return value of methods that I can
not contract. And, of course, methods that intentionally return
null as a valid result. But DBC does make null handling much less
intrusive.
This thread is about explicitly asking to be able to call methods
on null pointers, which seems like super-un-design-by-contract :)
No, this thread is about the difference between null and empty
string. It got hijacked for the topic of calling methods on null
and I then sub-hijacked it for a shout out to DBC. :-P
Or do you just love to shout "DBC" ;)
Especially to you. :-P
Chuck
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:
40global-village.net
This email sent to email@hidden
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40sportstec.com
This email sent to email@hidden
_______________________________________________
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