Re: Checking for A Blank String



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/>


.



Relevant Pages

  • Re: Maintenance Recomendations -Compact?
    ... Yes, we senior citizens appreciate clear, understandable ... developing applications, I've found that users of all ages do better ... I just never had reason to use Access until it was a requirement ... The ERP DB design is a good, clean ...
    (microsoft.public.access.gettingstarted)
  • Re: Whats the best language to learn...
    ... Debugging is much faster when errors are caught at compile time by a static ... with generic typing and unspecific typing more efficiently than with ... do after you finished programming. ... and there's no reason to force me to specify ...
    (comp.programming)
  • Re: Why COBOL is losing the POWER struggle
    ... reason to prefer one line? ... since this is a CoBOL group - we have all come across ... I make fewer errors typing it out. ... fewer mistakes - for the same desired result. ...
    (comp.lang.cobol)
  • Re: apology to the list
    ... clam, so please i am not some sick MF ... You should see some of the trouble a simple typo got *me* into. ... reason I kept typing "Prince of Peach." ... For some reason I can't type "Baptist" (see, I had to type that very ...
    (rec.pets.cats.anecdotes)
  • Re: I have a situation that I need help with
    ... The usual situation would have been having her right beside me while I did ... She had started typing it herself and it was ... dinner time and I told her that I would type it because it would take me ... you really just doing it for no reason. ...
    (misc.kids)