Re: Checking for A Blank String
- From: "Tom Leylan" <tleylan@xxxxxxxxxx>
- Date: Sat, 10 Mar 2007 13:32:26 -0500
Let me ask others to consider that "time-to-type" shouldn't be a major
consideration when developing applications. Yes if you are in a typing
contest but no if you are trying to write robust software for a living.
The reason one would choose a "complicated" solution if we honestly consider
typing IsNullOrEmpty complicated is to gain plainness and transparency.
There is nothing about a function named Len() which suggests that it is
testing for Null values and code which disguises what is happening is among
the worst kinds of code.
Using "plain", "simple", "obvious" and "easy-to-understand" as criteria let
each developer ask him/herself what does IsNullOrEmpty() test for and what
is it's return value. If you find it hard to figure out based upon it's
name then by all means choose Len().
I'd also be interested to know which "certain scenarios" throw exceptions I
didn't see it mentioned in the docs. Which exception does it throw?
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@xxxxxx> wrote...
"Göran Andersson" <guffa@xxxxxxxxx> schrieb:
Yes, ok, it's almost only a wrapper.
Perhaps, but the "almost" is the reason I choose to use it over the
other methods.
Why not use String.IsNullOrEmpty()? That is even more specialised for
this situation.
Unfortunately this method will throw exceptions in certain scenarios and
it's much more to type and read. Why choose the compilated solution over
the simpler one?
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
.
- Follow-Ups:
- Re: Checking for A Blank String
- From: Herfried K. Wagner [MVP]
- Re: Checking for A Blank String
- References:
- Re: Checking for A Blank String
- From: Herfried K. Wagner [MVP]
- Re: Checking for A Blank String
- From: \(O\)enone
- Re: Checking for A Blank String
- From: Göran Andersson
- Re: Checking for A Blank String
- From: Herfried K. Wagner [MVP]
- Re: Checking for A Blank String
- From: Göran Andersson
- Re: Checking for A Blank String
- From: \(O\)enone
- Re: Checking for A Blank String
- From: Göran Andersson
- Re: Checking for A Blank String
- From: Herfried K. Wagner [MVP]
- Re: Checking for A Blank String
- Prev by Date: Re: system call
- Next by Date: Re: Checking for A Blank String
- Previous by thread: Re: Checking for A Blank String
- Next by thread: Re: Checking for A Blank String
- Index(es):
Relevant Pages
|